-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathSpeedDialExample1.razor
More file actions
81 lines (75 loc) · 3.44 KB
/
SpeedDialExample1.razor
File metadata and controls
81 lines (75 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@namespace MudExtensions.Docs.Examples
<MudGrid>
<MudItem xs="12" sm="8">
<div Class="relative pa-4 d-flex align-center justify-center" Style="height: 500px; background-color: var(--mud-palette-background-gray)">
<MudSpeedDial Origin="_origin" Padding="_padding" OpenOnHover="_openOnHover" OpenOnClick="_openOnClick" IconOnOpen="@_openIcon" Color="Color.Primary" OnMainButtonClick="@(() => ButtonClick("Main button clicked."))">
<MudFab Size="Size.Small" IconSize="Size.Small" StartIcon="@Icons.Custom.Brands.MudBlazor" OnClick="@(() => ButtonClick("First button clicked."))" />
<MudFab Size="Size.Small" IconSize="Size.Small" StartIcon="@Icons.Custom.Brands.MudBlazor" Color="Color.Secondary" OnClick="@(() => ButtonClick("Second button clicked."))" />
<MudFab Size="Size.Small" IconSize="Size.Small" StartIcon="@Icons.Custom.Brands.MudBlazor" Color="Color.Tertiary" OnClick="@(() => ButtonClick("Third button clicked."))" />
</MudSpeedDial>
@if (_show)
{
<div style="width: 300px">
<MudProgressLinear @key="_key" Value="_progressValue" Color="Color.Primary" />
<MudText Typo="Typo.h6">@_text</MudText>
</div>
}
</div>
</MudItem>
<MudItem xs="12" sm="4">
<MudStack Spacing="4">
<MudSelect @bind-Value="_origin" Variant="Variant.Outlined" Label="Origin">
<MudSelectItem Value="Origin.TopLeft">Top - Left</MudSelectItem>
<MudSelectItem Value="Origin.TopRight">Top - Right</MudSelectItem>
<MudSelectItem Value="Origin.TopCenter">Top - Center</MudSelectItem>
<MudSelectItem Value="Origin.BottomLeft">Bottom - Left</MudSelectItem>
<MudSelectItem Value="Origin.BottomRight">Bottom - Right</MudSelectItem>
<MudSelectItem Value="Origin.BottomCenter">Bottom - Center</MudSelectItem>
</MudSelect>
<MudNumericField @bind-Value="_padding" Variant="Variant.Outlined" Label="Padding" />
<MudCheckBox @bind-Value="_openOnHover" Color="Color.Secondary" Label="Open On Hover" />
<MudCheckBox @bind-Value="_openOnClick" Color="Color.Secondary" Label="Open On Click" />
<MudSwitchM3 @ref="_switch" T="bool" Value="_differentIconOnOpen" ValueChanged="@(() => IconChanged(_switch?.Value))" Color="Color.Secondary" Label="Different Icon When Open" />
</MudStack>
</MudItem>
</MudGrid>
@code {
MudSwitchM3<bool>? _switch;
Origin _origin = Origin.TopRight;
int _padding = 0;
bool _show;
int _progressValue;
string? _text;
int _key;
bool _openOnHover = true;
bool _openOnClick = true;
bool _differentIconOnOpen = true;
string _openIcon = Icons.Material.Filled.Close;
private async Task ButtonClick(string text)
{
_show = true;
await Task.Delay(1);
_progressValue = 100;
_key++;
_text = text;
while (0 < _progressValue)
{
await Task.Delay(20);
_progressValue -= 2;
StateHasChanged();
}
_show = false;
}
private void IconChanged(bool? value)
{
_differentIconOnOpen = value ?? false;
if (_differentIconOnOpen == true)
{
_openIcon = Icons.Material.Filled.Close;
}
else
{
_openIcon = "";
}
}
}