diff --git a/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor b/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor index 2858d1aa1..c2ad8e129 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor @@ -1,6 +1,5 @@ @namespace BlazorBootstrap.Demo.RCL - -@inherits LayoutComponentBase +@inherits MainLayoutBase @@ -64,6 +63,33 @@ Open Collective + + @@ -74,79 +100,13 @@ @Body - - -@code { - private string version = default!; - private string docsUrl = default!; - private string blogUrl = default!; - private string githubUrl = default!; - private string twitterUrl = default!; - private string linkedInUrl = default!; - private string openCollectiveUrl = default!; - private string githubIssuesUrl = default!; - private string githubDiscussionsUrl = default!; - private string stackoverflowUrl = default!; - - [Inject] public IConfiguration Configuration { get; set; } = default!; - - protected override void OnInitialized() - { - version = $"v{Configuration["version"]}"; // example: v0.6.1 - docsUrl = $"{Configuration["urls:docs"]}"; - blogUrl = $"{Configuration["urls:blog"]}"; - githubUrl = $"{Configuration["urls:github"]}"; - twitterUrl = $"{Configuration["urls:twitter"]}"; - linkedInUrl = $"{Configuration["urls:linkedin"]}"; - openCollectiveUrl = $"{Configuration["urls:opencollective"]}"; - githubIssuesUrl = $"{Configuration["urls:github_issues"]}"; - githubDiscussionsUrl = $"{Configuration["urls:github_discussions"]}"; - stackoverflowUrl = $"{Configuration["urls:stackoverflow"]}"; - - base.OnInitialized(); - } -} + diff --git a/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor.cs b/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor.cs new file mode 100644 index 000000000..278295750 --- /dev/null +++ b/BlazorBootstrap.Demo.RCL/Components/Layout/EmptyLayout.razor.cs @@ -0,0 +1,5 @@ +namespace BlazorBootstrap.Demo.RCL; + +public partial class EmptyLayout : MainLayoutBase +{ +} diff --git a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayout.razor b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayout.razor index a81e746b9..2298ef346 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayout.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayout.razor @@ -1,5 +1,4 @@ @namespace BlazorBootstrap.Demo.RCL - @inherits MainLayoutBase
diff --git a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBase.cs b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBase.cs index 2c7a5d8db..92ce935ec 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBase.cs +++ b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBase.cs @@ -2,22 +2,32 @@ public class MainLayoutBase : LayoutComponentBase { - private string version = default!; - private string docsUrl = default!; - private string blogUrl = default!; - private string githubUrl = default!; - private string twitterUrl = default!; - private string linkedInUrl = default!; - private string openCollectiveUrl = default!; - private string githubIssuesUrl = default!; - private string githubDiscussionsUrl = default!; - private string stackoverflowUrl = default!; + internal string version = default!; + internal string docsUrl = default!; + internal string blogUrl = default!; + internal string githubUrl = default!; + internal string twitterUrl = default!; + internal string linkedInUrl = default!; + internal string openCollectiveUrl = default!; + internal string githubIssuesUrl = default!; + internal string githubDiscussionsUrl = default!; + internal string stackoverflowUrl = default!; internal Sidebar2 sidebar2 = default!; internal IEnumerable navItems = default!; [Inject] public IConfiguration Configuration { get; set; } = default!; + [Inject] protected IJSRuntime JS { get; set; } = default!; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + await JS.InvokeVoidAsync("initializeTheme"); + + await base.OnAfterRenderAsync(firstRender); + } + protected override void OnInitialized() { version = $"v{Configuration["version"]}"; // example: v0.6.1 @@ -33,6 +43,14 @@ protected override void OnInitialized() base.OnInitialized(); } + internal Task SetAutoTheme() => SetTheme("system"); + + internal Task SetDarkTheme() => SetTheme("dark"); + + internal Task SetLightTheme() => SetTheme("light"); + + internal async Task SetTheme(string themeName) => await JS.InvokeVoidAsync("setTheme", themeName); + internal virtual async Task Sidebar2DataProvider(Sidebar2DataProviderRequest request) { if (navItems is null) diff --git a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBaseFooter.razor b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBaseFooter.razor index 42c32ab15..c35d8360e 100644 --- a/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBaseFooter.razor +++ b/BlazorBootstrap.Demo.RCL/Components/Layout/MainLayoutBaseFooter.razor @@ -1,11 +1,11 @@ @namespace BlazorBootstrap.Demo.RCL @inherits ComponentBase -