-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathMainLayout.razor
More file actions
157 lines (140 loc) · 5.54 KB
/
MainLayout.razor
File metadata and controls
157 lines (140 loc) · 5.54 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@namespace MudExtensions.Docs.Shared
@inject NavigationManager NavigationManager
@inject MudExtensionsDocsService DocsService
@inherits LayoutComponentBase
<style>
@(_fontPicker?.ImportFontStyleText(font))
</style>
<MudScrollbar Width="8" Color="primary" HoverColor="secondary" />
<CascadingValue Value="this" IsFixed="true">
<MudLayout>
<MudAppBar Class="background-gradient-animation mud-width-full" Style="background: var(--mud-palette-background) !important;" Dense="true" Elevation="0">
<MudIconButton Class="ms-n2" Icon="@Icons.Material.Filled.Menu" OnClick="@(() => _drawerOpen = !_drawerOpen)"></MudIconButton>
<MudText Style="color: var(--mud-palette-text-primary); cursor: pointer" @onclick="@(() => NavigationManager.NavigateTo("/"))"><b>MudExtensions</b></MudText>
<MudSpacer />
<div class="d-flex">
<MudToggleIconButton @bind-Toggled="IsDarkMode" Style="color: var(--mud-palette-text-primary) !important" Icon="@Icons.Material.Filled.DarkMode" ToggledIcon="@Icons.Material.Filled.LightMode"/>
<MudIconButton Style="color: var(--mud-palette-text-primary) !important" Icon="@Icons.Material.Filled.Settings" OnClick="@ToggleOpen"/>
@if (_open == true)
{
<MudPopover Class="pa-4" Open="_open" AnchorOrigin="Origin.TopLeft" TransformOrigin="Origin.BottomRight" Style="width: 320px; height: 400px">
<MudStack Justify="Justify.SpaceBetween">
<MudSwitchM3 @bind-Value="_showFontPicker" Color="Color.Secondary" Label="Font Picker"/>
<MudSlider T="int" Value="_borderRadius" ValueChanged="BorderRadiusChanged" Min="0" Max="50" Color="Color.Secondary" ValueLabel="true" />
<MudText Class="mt-n2" Typo="Typo.subtitle2">Border Radius</MudText>
<MudButton Class="mud-width-full" OnClick="@ToggleOpen">Close</MudButton>
</MudStack>
</MudPopover>
}
</div>
</MudAppBar>
<MudDrawer @bind-Open="@_drawerOpen" Elevation="1" Variant="@DrawerVariant.Responsive" ClipMode="DrawerClipMode.Docked">
<MudNavMenu Color="Color.Secondary" Bordered="true">
<MudNavLink Href="/api">Api</MudNavLink>
<MudNavGroup Title="Components">
@foreach (var comp in DocsService.GetAllComponentInfo())
{
<MudNavLink Href="@($"/{comp.Title?.ToLowerInvariant()}")">@comp.Title?.Replace("Mud", "")</MudNavLink>
}
</MudNavGroup>
<MudNavGroup Title="Not Documented">
<MudNavLink>FontPicker</MudNavLink>
<MudNavLink>Toggle</MudNavLink>
</MudNavGroup>
</MudNavMenu>
</MudDrawer>
<MudMainContent Class="pt-13">
@if (_showFontPicker)
{
<div class="pa-4">
<MudFontPicker @ref="@_fontPicker" Label="Font Picker" StaticInputText="true" FontChanged="FontChanged" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" Clearable="true" MaxItems="null"/>
</div>
}
@Body
</MudMainContent>
</MudLayout>
</CascadingValue>
<style>
.appbar-style {
background: var(--mud-palette-secondary) !important;
transition: background-color .6s;
}
.appbar-style:hover {
background: linear-gradient(to right, var(--mud-palette-primary) , var(--mud-palette-secondary)) !important;
}
.appbar-style .reverse-color {
color: var(--mud-palette-primary) !important;
transition: background-color .6s;
}
.appbar-style:hover .reverse-color {
color: var(--mud-palette-secondary) !important;
}
</style>
<MudThemeProvider Theme="_theme" @bind-IsDarkMode="IsDarkMode" DefaultScrollbar="true" />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
@code {
MudFontPicker _fontPicker = new();
string font = "Roboto";
internal bool IsDarkMode = false;
bool _open = false;
bool _drawerOpen = false;
bool _showFontPicker = false;
int _borderRadius = 12;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
if (_fontPicker != null)
{
_fontPicker.Font = "Roboto";
FontChanged();
}
}
}
MudTheme _theme = new MudTheme()
{
LayoutProperties = new LayoutProperties()
{
DefaultBorderRadius = $"12px"
},
};
private void FontChanged()
{
font = _fontPicker?.Font ?? "Roboto";
_theme = new MudTheme()
{
LayoutProperties = new LayoutProperties()
{
DefaultBorderRadius = $"{_borderRadius}px"
},
Typography = new Typography()
{
Default = new DefaultTypography()
{
FontFamily = new[] { font, "Roboto", "Poppins", "Helvetica", "sans-serif" }
},
}
};
StateHasChanged();
}
private void ToggleOpen()
{
_open = !_open;
}
private void BorderRadiusChanged(int val)
{
_borderRadius = val;
FontChanged();
}
private string Version
{
get
{
var v = typeof(MudAnimate).Assembly.GetName().Version;
return $"v {v?.Major}.{v?.Minor}.{v?.Build}";
}
}
}