Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Blazor project templates #51028

Closed

Conversation

EdCharbeneau
Copy link

Improve Blazor project templates

Better a11y

  • Overall better HTML semantics by changing the structure of the layout in markup. Visually the rendering is the same as .NET 7. A new Header.razor​​ component was added to accommodate the new layout.
  • Collapsible navigation was rewritten to use a small bit of inline JavaScript instead of the improvised checkbox approach. The menu has proper aria-* attributes and sets focus to the first link when opened, per WCAG guidelines.
  • Removed :focus​ override, this is bad practice for a11y.​

Bootstrap 5.3 / themes

  • Updated to Bootstrap 5.3 and embraced Bootstrap throughout the sample layout. This eliminated ~100 lines of unnecessary CSS code and simplified the HTML too. Now MainLayout.razor.css only contains error ui​ CSS code.
  • Enabled theming via Bootstrap 5.3's CSS variables (aka Custom Properties). This allows runtime theme changes and future proofs the code for Bootstrap vnext.
  • Automatic light/dark mode detected and applied via user preferences. This is a no-code solution enabled by CSS variables. Developers can remove this feature by uncommenting a single line of code in App.razor
  • Made use of inline svg​ icons. This enables light/dark​ themes to control icon color.
  • Added --bl-*​ (opt-in) CSS variables to control the theme of the NavBar component. This allows devs to easily ditch the gradient if they want to customize the template.​

Code improvements

  • Reduced complexity of CSS code throughout, app.css​ is much smaller and cleaner. Used updated semantics for mediaqueries. 
  • Avoided CSS variables where code could be generated in  SampleContent == false​ templates.
  • Add/Removed blazor-error-ui​ CSS code based on template interactivity. The markup was removed in the prior version, but not the CSS.

Fixes issue: #50927

Overall better HTML semantics by changing the structure of the layout in markup. Visually the rendering is the same as .NET 7. A new Header.razor​​ component was added to accommodate the new layout.
Collapsible navigation was rewritten to use a small bit of inline JavaScript instead of the improvised checkbox approach. The menu has proper aria-* attributes and sets focus to the first link when opened, per WCAG guidelines.
Removed :focus​ override, this is bad practice for a11y.​
Bootstrap 5.3 / themes
Updated to Bootstrap 5.3 and embraced Bootstrap throughout the sample layout. This eliminated ~100 lines of unnecessary CSS code and simplified the HTML too. Now MainLayout.razor.css only contains error ui​ CSS code.
Enabled theming via Bootstrap 5.3's CSS variables (aka Custom Properties). This allows runtime theme changes and future proofs the code for Bootstrap vnext.
Automatic light/dark mode detected and applied via user preferences. This is a no-code solution enabled by CSS variables. Developers can remove this feature by uncommenting a single line of code in App.razor
Made use of inline svg​ icons. This enables light/dark​ themes to control icon color.
Added --bl-*​ (opt-in) CSS variables to control the theme of the NavBar component. This allows devs to easily ditch the gradient if they want to customize the template.​
Code improvements
Reduced complexity of CSS code throughout, app.css​ is much smaller and cleaner. Used updated semantics for mediaqueries.
Avoided CSS variables where code could be generated in  SampleContent == false​ templates.
Add/Removed blazor-error-ui​ CSS code based on template interactivity. The markup was removed in the prior version, but not the CSS.

Fixes issue: dotnet#50927
@ghost ghost added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member labels Sep 29, 2023
@ghost
Copy link

ghost commented Sep 29, 2023

Thanks for your PR, @EdCharbeneau. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant