-
Notifications
You must be signed in to change notification settings - Fork 464
[dev-v5][Nav] Part 1 - Add the FluentNav components #4419
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d9e1b5e
Add the Fluent Nav components including docs and tests (100% coverage)
vnbaaij 9e531da
Process review comments
vnbaaij aa6da07
Fix rename errors
vnbaaij dd18730
Add Base tests
vnbaaij 44a0a76
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/nav-part1
vnbaaij c0e06cd
Process review comments
vnbaaij c246230
Merge branch 'users/vnbaaij/dev-v5/nav-part1' of https://github.com/m…
vnbaaij b359d64
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/nav-part1
vnbaaij 4e91f07
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/nav-part1
dvoituron 7e44f4c
Process review comments
vnbaaij df5236e
Fix a test case- Make CascadinParameter internal
vnbaaij 830e9b4
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/nav-part1
dvoituron 7ab2105
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/nav-part1
dvoituron 76fa31c
Process more review comments
vnbaaij eb7968c
Merge branch 'users/vnbaaij/dev-v5/nav-part1' of https://github.com/m…
vnbaaij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
examples/Demo/FluentUI.Demo.Client/Documentation/Components/Nav/Examples/NavDefault.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| @using Microsoft.FluentUI.AspNetCore.Components | ||
| @using Microsoft.FluentUI.AspNetCore.Components.Extensions | ||
| @inject IDialogService DialogService | ||
|
|
||
| <h3>NavDefault</h3> | ||
|
|
||
| <FluentStack Orientation="Orientation.Horizontal" HorizontalGap="15"> | ||
| <FluentNav @ref="@nav" | ||
| UseHeader="@_useHeader" | ||
| UseIcons="@_useIcons" | ||
| UseSingleExpanded="@(!_useMultipleExpanded)" | ||
| AppTitle="Contoso" | ||
| AppIcon="@(new Icons.Regular.Size32.Person())" | ||
| Density="@_density"> | ||
| <FluentNavItem Href="/Nav" Icon="@(new Icons.Regular.Size20.Board())">Dashboard</FluentNavItem> | ||
| <FluentNavItem OnClick="@ShowInformationAsync" Icon="@(new Icons.Regular.Size20.MegaphoneLoud())">Announcements</FluentNavItem> | ||
| <FluentNavItem Disabled="true" Href="@_link">Employee Spotlight</FluentNavItem> | ||
| <FluentNavItem OnClick="@ShowInformationAsync" Icon="@(new Icons.Regular.Size20.PersonSearch())">Profile Search</FluentNavItem> | ||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.PersonMoney())">Performance Reviews</FluentNavItem> | ||
|
|
||
| <FluentNavSectionHeader Title="Employee Management" /> | ||
|
|
||
| <FluentNavCategory Title="Job Postings" Icon="@(new Icons.Regular.Size20.NotePin())"> | ||
|
|
||
| <FluentNavItem OnClick="@ShowInformationAsync">Openings</FluentNavItem> | ||
| <FluentNavItem OnClick="@ShowInformationAsync">Submissions</FluentNavItem> | ||
|
|
||
| </FluentNavCategory> | ||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.People())">Interviews</FluentNavItem> | ||
|
|
||
| <FluentNavSectionHeader Title="Benefits" /> | ||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.HeartPulse())">Health Plans</FluentNavItem> | ||
|
|
||
| <FluentNavCategory Id="retirement" Title="Retirement" Icon="@(new Icons.Regular.Size20.Person())"> | ||
|
|
||
| <FluentNavItem>Plan Information</FluentNavItem> | ||
| <FluentNavItem>Fund Performance</FluentNavItem> | ||
|
|
||
| </FluentNavCategory> | ||
|
|
||
| <FluentDivider /> | ||
|
|
||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.BoxMultiple())">Training Programs</FluentNavItem> | ||
|
|
||
| <FluentNavCategory Title="Career Development" Icon="@(new Icons.Regular.Size20.PeopleStar())"> | ||
|
|
||
| <FluentNavItem>Openings</FluentNavItem> | ||
| <FluentNavItem>Submissions</FluentNavItem> | ||
|
|
||
| </FluentNavCategory> | ||
|
|
||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.ArrowTrendingLines())">Workforce Data</FluentNavItem> | ||
| <FluentNavItem Href="@_link" Icon="@(new Icons.Regular.Size20.DocumentBulletListMultiple())">Reports</FluentNavItem> | ||
| </FluentNav> | ||
|
|
||
| <FluentStack Orientation="Orientation.Vertical" VerticalGap="5"> | ||
| <FluentRadioGroup @bind-Value="@_density" Label="Density" Wrap="true"> | ||
| <FluentRadio Label="Medium" Value="NavDensity.Medium" /> | ||
| <FluentRadio Label="Small" Value="NavDensity.Small" /> | ||
| </FluentRadioGroup> | ||
|
|
||
| <FluentSwitch @bind-Value="@_useIcons" Label="Use Icons" /> | ||
| <FluentSwitch @bind-Value="@_useMultipleExpanded" Label="Allow multiple expanded categories" /> | ||
| <FluentSwitch @bind-Value="@_useHeader" Label="Use Header" /> | ||
|
|
||
| <FluentButton Disabled="@(!nav!.UseHeader)" OnClick="ToggleNavAsync">Toggle Navigation</FluentButton> | ||
|
|
||
| <FluentText>Programmatically control expanded/collapsed state</FluentText> | ||
| <span> | ||
| <FluentButton OnClick="ExpandRetirementAsync">Expand 'Retirement'</FluentButton> | ||
| <FluentButton OnClick="CollapseRetirementAsync">Collapse 'Retirement'</FluentButton> | ||
| </span> | ||
| </FluentStack> | ||
|
|
||
| </FluentStack> | ||
|
|
||
| @code | ||
| { | ||
| private FluentNav nav = default!; | ||
| NavDensity _density; | ||
| bool _useHeader = false; | ||
| bool _useIcons = true; | ||
| bool _useMultipleExpanded = true; | ||
| private readonly string? _link = "https://fluentui-blazor-v5.azurewebsites.net/"; | ||
|
|
||
| private async Task ShowInformationAsync() | ||
| { | ||
| await DialogService.ShowInfoAsync("This is a message"); | ||
| } | ||
|
|
||
| private async Task ToggleNavAsync() | ||
| { | ||
| if (nav.UseHeader) | ||
| { | ||
| await nav.ToggleNavAsync(); | ||
| } | ||
| } | ||
|
|
||
| private async Task ExpandRetirementAsync() | ||
| { | ||
| await nav.ExpandCategoryAsync("retirement"); | ||
| } | ||
|
|
||
| private async Task CollapseRetirementAsync() | ||
| { | ||
| await nav.CollapseCategoryAsync("retirement"); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
examples/Demo/FluentUI.Demo.Client/Documentation/Components/Nav/FluentNav.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| title: Nav | ||
| route: /Nav | ||
| icon: Navigation | ||
| --- | ||
|
|
||
| # Nav | ||
|
|
||
| Nav, or navigation, provides a list of links that lets people move through the main sections of an app or site. It’s a high-level wayfinding component that’s always easily accessible but can be minimized to free up space. | ||
|
|
||
| Nav only supports one level of nesting and might not show all available items. | ||
|
|
||
| ## Selection | ||
| The selection indicator tells people at a glance which page is active. If a nav sub-item is the active page and the category is closed, the selection indicator will display on the nav category. | ||
|
|
||
| ## Grouping | ||
| Navs can be organized with up to two levels of hierarchy. Simple navs list the spaces in a site or app as links on the same level. For more complex navs, links can be grouped into categories for easier interaction. | ||
|
|
||
| Create a simple nav using nav items. These are first-level links that give people a quick understanding of the main parts of an experience. | ||
|
|
||
| Create a complex nav using nav categories and sub-items. Nav categories expand and collapse so people only see the information they need. Nav sub-items group related links within that category and let people navigate to those sub-pages. Nav categories act as accordions and show or hide information; they’re not links and won’t lead to site or app locations. | ||
|
|
||
| By using the `UseSingleExpanded` parameter, you can ensure that only one nav category is expanded at a time. When a new category is expanded, any previously expanded category will automatically collapse. | ||
|
|
||
| ## Divider | ||
| Use the `FluentDivider` to separate groups of nav items. This helps people scan and find what they need more quickly. The right styling will automatically be applied when using the divider inside the `FluentNav` | ||
|
|
||
| ## Icons | ||
| Whenever possible, use icons with nav category labels. They create additional visual emphasis and differentiate nav categories from the nav subitems within them. Use simple and recognizable icons that are easy to understand. | ||
|
|
||
| If icons aren’t technically possible or difficult to pick due to an overwhelming number of nav items, remove them. If nav categories don’t include an icon, subitems are indented to maintain a clear hierarchy. | ||
|
|
||
| ## Items | ||
| Nav doesn’t support an icon-only layout. | ||
|
|
||
| A `NavItem` can contain either an `Href` or an `OnClick` handler. | ||
|
|
||
| When a `NavItem` is used inside a `NavCategory`, the `Icon` parameter is ignored. No icon will be displayed. | ||
|
|
||
| In the example below, the first (and third and fifth) item has an `Href` that navigates to an external site, while the second (and fourth) item has an `OnClick` handler that triggers a method in the component. | ||
|
|
||
| {{ NavDefault }} | ||
|
|
||
| ## API FluentNav | ||
|
|
||
| {{ API Type=FluentNav }} | ||
|
|
||
| ## API FluentNavCategory | ||
|
|
||
| {{ API Type=FluentNavCategory }} | ||
|
|
||
| ## API FluentNavItem | ||
| {{ API Type=FluentNavItem }} | ||
|
|
||
| ## API FluentNavSectionHeader | ||
| {{ API Type=FluentNavSectionHeader }} | ||
|
|
||
| ## Migrating to v5 | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| There is no direct migration path for the `FluentNavMenu` from v4 | ||
| to the `FluentNav` in v5. This is due to the fact that in the v4 component | ||
| it was possible to have multiple levels of nesting, while in v5 only one level is supported. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| @namespace Microsoft.FluentUI.AspNetCore.Components | ||
| @using Microsoft.FluentUI.AspNetCore.Components.Extensions | ||
| @inherits FluentComponentBase | ||
|
|
||
| <CascadingValue Value="this" IsFixed="true"> | ||
| <div class="fluent-nav-container@(_navOpen ? "" : " collapsed")"> | ||
| <div id="@Id" | ||
| role="navigation" | ||
| class="@ClassValue" | ||
| style="@StyleValue" | ||
| density="@Density.ToAttributeValue()" | ||
| @attributes="@AdditionalAttributes"> | ||
| @if (UseHeader) | ||
| { | ||
| <header role="none" class="nav-header"> | ||
| <FluentButton Appearance="@ButtonAppearance.Transparent" | ||
| IconStart="@ToggleIcon" | ||
| Title="@Localizer[Localization.LanguageResource.Nav_ToggleTitle]" | ||
| IconOnly="true" | ||
| OnClick="@ToggleNavAsync"/> | ||
| </header> | ||
| } | ||
| <div class="nav-body"> | ||
| @if (!string.IsNullOrEmpty(AppTitle)) | ||
| { | ||
| <a href="@AppLink" class="appitem"> | ||
| @if (AppIcon is not null) | ||
| { | ||
| <FluentIcon Value="AppIcon" /> | ||
| } | ||
| @AppTitle | ||
| </a> | ||
| } | ||
| @ChildContent | ||
| </div> | ||
| </div> | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </CascadingValue> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.