-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathThemeSelector.razor
More file actions
54 lines (48 loc) · 1.73 KB
/
ThemeSelector.razor
File metadata and controls
54 lines (48 loc) · 1.73 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
@namespace LumexUI.Docs.Client.Components
@rendermode InteractiveWebAssembly
<LumexSelect TValue="ThemeColor"
LabelPlacement="@LabelPlacement.Outside"
Value="@_themeColor"
ValueChanged="@HandleThemeChange"
Class="max-w-40">
<ChildContent>
@foreach( var color in Enum.GetValues<ThemeColor>()[1..] )
{
<LumexSelectItem @key="@color" Value="@color">
<div class="flex gap-2 items-center">
<span class="w-4 h-4 border border-default-900/10 rounded-full shrink-0 @_themeColorMap[color]" />
@color.ToString()
</div>
</LumexSelectItem>
}
</ChildContent>
<ValueContent Context="color">
<div class="flex gap-2 items-center">
<span class="w-4 h-4 border border-default-900/10 rounded-full shrink-0 @_themeColorMap[color]" />
@color.ToString()
</div>
</ValueContent>
</LumexSelect>
@code {
[Inject] private DocsThemeService ThemeService { get; set; } = default!;
private readonly Dictionary<ThemeColor, string> _themeColorMap = new()
{
[ThemeColor.Default] = "bg-default",
[ThemeColor.Primary] = "bg-primary",
[ThemeColor.Secondary] = "bg-secondary",
[ThemeColor.Success] = "bg-success",
[ThemeColor.Warning] = "bg-warning",
[ThemeColor.Danger] = "bg-danger",
[ThemeColor.Info] = "bg-info"
};
private ThemeColor _themeColor = ThemeColor.Default;
private void HandleThemeChange( ThemeColor color )
{
if( color is ThemeColor.None )
{
return;
}
_themeColor = color;
ThemeService.SetThemeColor( color );
}
}