-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented custom theming system based on MudThemeProvider. Used for…
… DiffViewers.
- Loading branch information
1 parent
1092e63
commit a121158
Showing
14 changed files
with
108 additions
and
20 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
samples/DotNetElements.CrudExample/.config/dotnet-tools.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-ef": { | ||
"version": "8.0.3", | ||
"commands": [ | ||
"dotnet-ef" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using MudBlazor.Utilities; | ||
|
||
namespace DotNetElements.Web.Blazor; | ||
|
||
public static class DnePalette | ||
{ | ||
public const string DiffLineUnchanged = "--dne-palette-diff-line-unchanged"; | ||
public const string DiffLineUnchangedDark = "#0D1117"; | ||
public const string DiffLineUnchangedLight = "#FFFFFF"; | ||
|
||
public const string DiffLineOld = "--dne-palette-diff-line-old"; | ||
public const string DiffLineOldDark = "#25171C"; | ||
public const string DiffLineOldLight = "#FFEBE9"; | ||
|
||
public const string DiffLineNew = "--dne-palette-diff-line-new"; | ||
public const string DiffLineNewDark = "#12261E"; | ||
public const string DiffLineNewLight = "#E6FFEC"; | ||
|
||
public const string DiffPieceDeleted = "--dne-palette-diff-piece-deleted"; | ||
public const string DiffPieceDeletedDark = "#792E2E"; | ||
public const string DiffPieceDeletedLight = "#FFC1C0"; | ||
|
||
public const string DiffPieceInserted = "--dne-palette-diff-piece-inserted"; | ||
public const string DiffPieceInsertedDark = "#1D572D"; | ||
public const string DiffPieceInsertedLight = "#ABF2BC"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@inherits DneThemingProvider | ||
|
||
<DneThemingProvider Theme="Theme" DefaultScrollbar="DefaultScrollbar" IsDarkMode="IsDarkMode" IsDarkModeChanged="IsDarkModeChanged" /> | ||
<MudPopoverProvider /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@inherits MudThemingProvider | ||
|
||
@{ | ||
base.BuildRenderTree(__builder); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Text; | ||
|
||
namespace DotNetElements.Web.Blazor; | ||
|
||
partial class DneThemingProvider : MudThemingProvider | ||
{ | ||
protected override void GenerateTheme(StringBuilder theme) | ||
{ | ||
base.GenerateTheme(theme); | ||
|
||
theme.AppendLine($"{DnePalette.DiffLineUnchanged}: {(IsDarkMode ? DnePalette.DiffLineUnchangedDark : DnePalette.DiffLineUnchangedLight)};"); | ||
theme.AppendLine($"{DnePalette.DiffLineOld}: {(IsDarkMode ? DnePalette.DiffLineOldDark : DnePalette.DiffLineOldLight)};"); | ||
theme.AppendLine($"{DnePalette.DiffLineNew}: {(IsDarkMode ? DnePalette.DiffLineNewDark : DnePalette.DiffLineNewLight)};"); | ||
theme.AppendLine($"{DnePalette.DiffPieceDeleted}: {(IsDarkMode ? DnePalette.DiffPieceDeletedDark : DnePalette.DiffPieceDeletedLight)};"); | ||
theme.AppendLine($"{DnePalette.DiffPieceInserted}: {(IsDarkMode ? DnePalette.DiffPieceInsertedDark : DnePalette.DiffPieceInsertedLight)};"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<MudDialogProvider /> | ||
<MudSnackbarProvider /> | ||
<DneThemeProvider @ref="@mudThemeProvider" @bind-IsDarkMode="@DarkModeActive" /> | ||
|
||
@code | ||
{ | ||
[Parameter, EditorRequired] | ||
public bool DarkModeActive { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<bool> DarkModeActiveChanged { get; set; } | ||
|
||
private DneThemeProvider mudThemeProvider = default!; | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
DarkModeActive = await mudThemeProvider.GetSystemPreference(); | ||
if (DarkModeActiveChanged.HasDelegate) | ||
await DarkModeActiveChanged.InvokeAsync(DarkModeActive); | ||
} | ||
} | ||
} |