-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #842 from EdiWang/dev/theme-refact
Refact System Theme
- Loading branch information
Showing
8 changed files
with
98 additions
and
35 deletions.
There are no files selected for viewing
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,18 @@ | ||
using MediatR; | ||
using Moonglade.Data; | ||
using Moonglade.Data.Entities; | ||
using Moonglade.Data.Specifications; | ||
|
||
namespace Moonglade.Setup; | ||
|
||
public class CleanupLegacySystemThemeCommand : IRequest; | ||
|
||
public class CleanupLegacySystemThemeCommandHandler(MoongladeRepository<BlogThemeEntity> repo) | ||
: IRequestHandler<CleanupLegacySystemThemeCommand> | ||
{ | ||
public async Task Handle(CleanupLegacySystemThemeCommand request, CancellationToken ct) | ||
{ | ||
var existingThemes = await repo.ListAsync(new ThemeByTypeSpec(ThemeType.System), ct); | ||
await repo.DeleteRangeAsync(existingThemes, ct); | ||
} | ||
} |
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,30 @@ | ||
using Moonglade.Data.Entities; | ||
|
||
namespace Moonglade.Theme; | ||
|
||
public static class ThemeFactory | ||
{ | ||
public static IEnumerable<BlogThemeEntity> GetSystemThemes() | ||
{ | ||
return new List<BlogThemeEntity> | ||
{ | ||
CreateTheme(100, "Word Blue (Default)", "#2a579a", "#1a365f", "#3e6db5"), | ||
CreateTheme(101, "Excel Green", "#165331", "#0E351F", "#0E703A"), | ||
CreateTheme(102, "PowerPoint Orange", "#983B22", "#622616", "#C43E1C"), | ||
CreateTheme(103, "OneNote Purple", "#663276", "#52285E", "#7719AA"), | ||
CreateTheme(104, "Outlook Blue", "#035AA6", "#032B51", "#006CBF"), | ||
CreateTheme(105, "Metal Blue", "#4E5967", "#333942", "#6e7c8e") | ||
}; | ||
} | ||
|
||
private static BlogThemeEntity CreateTheme(int id, string themeName, string color1, string color2, string color3) | ||
{ | ||
return new() | ||
{ | ||
Id = id, | ||
ThemeName = themeName, | ||
CssRules = $"{{\"--accent-color1\": \"{color1}\",\"--accent-color2\": \"{color2}\",\"--accent-color3\": \"{color3}\"}}", | ||
ThemeType = 0 | ||
}; | ||
} | ||
} |