Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 58 additions & 56 deletions examples/Demo/Shared/Pages/AppBar/Examples/AppBarClick.razor
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
@inject IDialogService DialogService

<FluentStack Orientation="Orientation.Vertical" Style="height: 330px;">
<FluentAppBar Style="height: 100%;">
<FluentAppBarItem Href="/"
Match="NavLinkMatch.All"
IconRest="HomeIcon()"
IconActive="HomeIcon(active: true)"
Text="Home"
OnClick="HandleOnClick" />
<FluentAppBarItem Href="/AppBar"
IconRest="AppBarIcon()"
IconActive="AppBarIcon(active: true)"
Text="AppBar"
OnClick="HandleOnClick" />
<FluentAppBarItem IconRest="WhatsNewIcon()"
IconActive="WhatsNewIcon(active: true)"
Text="What's New"
OnClick="ShowSuccessAsync" />
<FluentAppBarItem Href="@(null)"
IconRest="IconsIcon()"
IconActive="IconsIcon(active: true)"
Text="Icons"
OnClick="ShowWarningAsync" />
<FluentAppBarItem Href="/Dialog"
IconRest="DialogIcon()"
IconActive="DialogIcon(active: true)"
Text="Dialog"
OnClick="HandleOnClick" />
</FluentAppBar>
<div style="background-color: var(--neutral-layer-3); overflow: auto; resize: vertical; height: 356px; width: 86px; padding: 10px;">
<FluentAppBar Style="height: 100%; background-color: var(--neutral-layer-2);">
<FluentAppBarItem Href="/"
Match="NavLinkMatch.All"
IconRest="HomeIcon()"
IconActive="HomeIcon(active: true)"
Text="Home"
OnClick="HandleOnClick" />
<FluentAppBarItem Href="/AppBar"
IconRest="AppBarIcon()"
IconActive="AppBarIcon(active: true)"
Text="AppBar"
OnClick="HandleOnClick" />
<FluentAppBarItem IconRest="WhatsNewIcon()"
IconActive="WhatsNewIcon(active: true)"
Text="What's New"
OnClick="ShowSuccessAsync" />
<FluentAppBarItem Href="@(null)"
IconRest="IconsIcon()"
IconActive="IconsIcon(active: true)"
Text="Icons"
OnClick="HandleOnClick" />
<FluentAppBarItem Href="/Dialog"
IconRest="DialogIcon()"
IconActive="DialogIcon(active: true)"
Text="Dialog"
OnClick="HandleOnClick" />
</FluentAppBar>
</div>
</FluentStack>

@code {
private static Icon HomeIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Home()
: new Icons.Regular.Size24.Home();
private static Icon HomeIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Home()
: new Icons.Regular.Size24.Home();

private static Icon AppBarIcon(bool active = false) =>
active ? new Icons.Filled.Size24.AppsList()
: new Icons.Regular.Size24.AppsList();
private static Icon AppBarIcon(bool active = false) =>
active ? new Icons.Filled.Size24.AppsList()
: new Icons.Regular.Size24.AppsList();

private static Icon WhatsNewIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Info()
: new Icons.Regular.Size24.Info();
private static Icon WhatsNewIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Info()
: new Icons.Regular.Size24.Info();

private static Icon IconsIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Symbols()
: new Icons.Regular.Size24.Symbols();
private static Icon IconsIcon(bool active = false) =>
active ? new Icons.Filled.Size24.Symbols()
: new Icons.Regular.Size24.Symbols();

private static Icon DialogIcon(bool active = false) =>
active ? new Icons.Filled.Size24.AppGeneric()
: new Icons.Regular.Size24.AppGeneric();
private static Icon DialogIcon(bool active = false) =>
active ? new Icons.Filled.Size24.AppGeneric()
: new Icons.Regular.Size24.AppGeneric();


private void HandleOnClick(IAppBarItem item)
{
private void HandleOnClick(IAppBarItem item)
{

DemoLogger.WriteLine($"Clicked {item.Text}!");
}
DemoLogger.WriteLine($"Clicked {item.Text}!");
}

private async Task ShowSuccessAsync(IAppBarItem item)
{
var dialog = await DialogService.ShowSuccessAsync($"You clicked {item.Text}");
var result = await dialog.Result;
}
private async Task ShowSuccessAsync(IAppBarItem item)
{
var dialog = await DialogService.ShowSuccessAsync($"You clicked {item.Text}");
var result = await dialog.Result;
}

private async Task ShowWarningAsync(IAppBarItem item)
{
var dialog = await DialogService.ShowWarningAsync($"Are you sure? {item.Text}");
var result = await dialog.Result;
}
private async Task ShowWarningAsync(IAppBarItem item)
{
var dialog = await DialogService.ShowWarningAsync($"Are you sure? {item.Text}");
var result = await dialog.Result;
}
}
Comment thread
vnbaaij marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<FluentStack Orientation="Orientation.Vertical" Style="height: 100%;">
<FluentSwitch @bind-Value="_showSearch" CheckedMessage="Show" UncheckedMessage="Hide" Label="Show search in popover" />
<div style="background-color: var(--neutral-layer-3); overflow: auto; resize: vertical; height: 356px; width: 500px; padding: 10px;">
<div style="background-color: var(--neutral-layer-3); overflow: auto; resize: vertical; height: 356px; width: 86px; padding: 10px;">
Comment thread
vnbaaij marked this conversation as resolved.
Outdated
<FluentAppBar
Items="@_apps.OrderBy(a => a.Order)"
Style="width: 68px; height: 100%; background-color: var(--neutral-layer-2);"
Style="height: 100%; background-color: var(--neutral-layer-2);"
PopoverVisibilityChanged="HandlePopover"
PopoverShowSearch="@_showSearch">
</FluentAppBar>
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/AppBar/FluentAppBar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private async Task InitializeOverflowAsync()
}
}

private Task TogglePopoverAsync() => HandlePopoverToggleAsync(!_showMoreItems);
internal Task TogglePopoverAsync() => HandlePopoverToggleAsync(!_showMoreItems);

private async Task HandlePopoverKeyDownAsync(FluentKeyCodeEventArgs args)
{
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Components/AppBar/FluentAppBarItem.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ protected async Task OnClickHandlerAsync(MouseEventArgs ev)
{
if (OnClick.HasDelegate)
{
if (Overflow is true)
{
await Owner.AppBar.TogglePopoverAsync();
}

await OnClick.InvokeAsync(this);
}
}
Expand Down
Loading