Skip to content

Commit

Permalink
MudThemeProvider: Set clearer boundary between MudThemeProvider and M…
Browse files Browse the repository at this point in the history
…udTheme regarding palettes (#3654)
  • Loading branch information
just-the-benno committed Jan 2, 2022
1 parent f1e65cd commit 1251cdf
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
@namespace MudBlazor.Docs.Examples
@page "/iframe/docs/examples/themeprovider/darkpalette"

<MudThemeProvider Theme="_theme" />
<MudThemeProvider Theme="_theme" @bind-IsDarkMode="_isDarkMode"/>
<MudSwitch Color="Color.Primary" Class="ma-4" T="bool" CheckedChanged="DarkMode" Label="Toggle Light/Dark Mode"/>

<MudText Class="ma-4">This is an example text!</MudText>

@code{

private MudTheme _theme = new();
private bool _isDarkMode = false;

void DarkMode(bool value) {
_theme.IsDarkMode = value;
void DarkMode(bool value)
{
_isDarkMode = value;
}
}
2 changes: 1 addition & 1 deletion src/MudBlazor.Docs/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PageTitle>MudBlazor - Blazor Component Library</PageTitle>

<MudRTLProvider RightToLeft="@_rightToLeft">
<MudThemeProvider Theme="_theme"/>
<MudThemeProvider Theme="_theme" @bind-IsDarkMode="_isDarkMode"/>
<MudDialogProvider FullWidth="true" MaxWidth="MaxWidth.ExtraSmall" />
<MudSnackbarProvider />

Expand Down
3 changes: 2 additions & 1 deletion src/MudBlazor.Docs/Shared/MainLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class MainLayout : LayoutComponentBase
{
private bool _drawerOpen = false;
private bool _rightToLeft = false;
private bool _isDarkMode = false;
private NavMenu _navMenuRef;

[Inject] private NavigationManager NavigationManager { get; set; }
Expand Down Expand Up @@ -90,7 +91,7 @@ private void OnSwipe(SwipeDirection direction)
#region Theme
private void DarkMode()
{
_theme.IsDarkMode = !_theme.IsDarkMode;
_isDarkMode = !_isDarkMode;
}

private MudTheme _theme = new();
Expand Down

0 comments on commit 1251cdf

Please sign in to comment.