Skip to content

Commit c865ac5

Browse files
authored
Added Watch Example That Shows New TimeZone Parameter Usage (#618)
1 parent 6a7efdc commit c865ac5

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@namespace MudExtensions.Docs.Examples
2+
@inject ISnackbar Snackbar
3+
@using MudBlazor.Extensions
4+
@using MudExtensions.Utilities
5+
6+
<MudGrid>
7+
<MudItem xs="12" sm="8">
8+
<MudStack Class="mud-width-full" AlignItems="AlignItems.Center">
9+
<MudWatch @ref="_watch" Interval="TimeSpan.FromSeconds(1)" Mode="WatchMode.Watch"
10+
Wheel="_wheel" ShowHour="_showHour" ShowMinute="_showMinute" ShowSecond="_showSecond" ShowMillisecond="_showMillisecond"
11+
TimeZone="_selectedTimeZone" />
12+
</MudStack>
13+
</MudItem>
14+
15+
<MudItem xs="12" sm="4">
16+
<MudStack Spacing="4">
17+
<MudSelectExtended @bind-Value="_selectedTimeZone" Label="TimeZone" Dense="true" SearchBox="true" ToStringFunc="@(tz => $"{tz.DisplayName} ({tz.Id})")">
18+
@foreach (var tz in _timeZones)
19+
{
20+
<MudSelectItemExtended Value="tz">
21+
@tz.DisplayName (@tz.Id)
22+
</MudSelectItemExtended>
23+
}
24+
25+
</MudSelectExtended>
26+
<MudSwitchM3 @bind-Value="_wheel" Color="Color.Secondary" Label="Wheel" />
27+
<div class="d-flex flex-wrap gap-4">
28+
<MudSwitchM3 @bind-Value="_showHour" Color="Color.Secondary" Label="Show Hour" />
29+
<MudSwitchM3 @bind-Value="_showMinute" Color="Color.Secondary" Label="Show Minute" />
30+
<MudSwitchM3 @bind-Value="_showSecond" Color="Color.Secondary" Label="Show Second" />
31+
<MudSwitchM3 @bind-Value="_showMillisecond" Color="Color.Secondary" Label="Show Millisecond" />
32+
</div>
33+
</MudStack>
34+
</MudItem>
35+
</MudGrid>
36+
37+
@code {
38+
MudWatch _watch = new();
39+
bool _wheel;
40+
bool _showHour = true;
41+
bool _showMinute = true;
42+
bool _showSecond = true;
43+
bool _showMillisecond = false;
44+
45+
private List<TimeZoneInfo> _timeZones = new();
46+
private TimeZoneInfo _selectedTimeZone = TimeZoneInfo.Utc;
47+
48+
protected override void OnInitialized()
49+
{
50+
_timeZones = TimeZoneInfo.GetSystemTimeZones().ToList();
51+
_selectedTimeZone = TimeZoneInfo.Local;
52+
}
53+
}

docs/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Watch/WatchPage.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
<ExampleCard ComponentName="Watch" ExampleName="WatchExample1" Title="Usage" Description="MudWatch has classic and wheel views with other design options.">
66
<WatchExample1 />
77
</ExampleCard>
8+
9+
<ExampleCard ComponentName="Watch" ExampleName="WatchExample2" Title="TimeZone" Description="MudWatch supports dynamic time zones.">
10+
<WatchExample2 />
11+
</ExampleCard>
812
</ExamplePage>

0 commit comments

Comments
 (0)