diff --git a/SharpRSS.Blazor/Components/App.razor b/SharpRSS.Blazor/Components/App.razor index ae3d110..c969d9a 100644 --- a/SharpRSS.Blazor/Components/App.razor +++ b/SharpRSS.Blazor/Components/App.razor @@ -16,7 +16,8 @@ - +@*Rendermode to 'InteractiveServer' or else MudBlazor will not work with interactivity*@ + @*MudBlazor*@ diff --git a/SharpRSS.Blazor/Components/Layout/ApplicationLayout.razor b/SharpRSS.Blazor/Components/Layout/ApplicationLayout.razor new file mode 100644 index 0000000..189a965 --- /dev/null +++ b/SharpRSS.Blazor/Components/Layout/ApplicationLayout.razor @@ -0,0 +1,25 @@ +@inherits LayoutComponentBase +@layout BaseLayout + + + + + @AppText + + + + + @Body + + +@code { + [CascadingParameter] + public BaseLayout BaseLayout { get; set; } = null!; + public bool DrawerOpen { get; set; } = true; + public string AppText { get; set; } = "SharpRSS"; + + private void ToggleDrawerOpen() + { + DrawerOpen = !DrawerOpen; + } +} \ No newline at end of file diff --git a/SharpRSS.Blazor/Components/Layout/ApplicationLayout.razor.css b/SharpRSS.Blazor/Components/Layout/ApplicationLayout.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/SharpRSS.Blazor/Components/Layout/BaseLayout.razor b/SharpRSS.Blazor/Components/Layout/BaseLayout.razor new file mode 100644 index 0000000..3d2ca24 --- /dev/null +++ b/SharpRSS.Blazor/Components/Layout/BaseLayout.razor @@ -0,0 +1,46 @@ +@inherits LayoutComponentBase + + + + + + + + + @Body + + + + +@code { + public readonly MudTheme MudTheme = new MudTheme(); + private MudThemeProvider? _themeProvider; + private bool _isDarkTheme = true; + + public event EventHandler? OnDarkThemeChanged; + + public bool DarkTheme + { + get => _isDarkTheme; + set + { + _isDarkTheme = value; + ThemeChanged(); + } + } + + private async void ThemeChanged() + { + //TODO: Update user settings + StateHasChanged(); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender && _themeProvider != null) + { + DarkTheme = await _themeProvider.GetSystemPreference(); + _themeProvider.IsDarkModeChanged = EventCallback.Factory.Create(this, x => OnDarkThemeChanged?.Invoke(this, x)); + } + } +} \ No newline at end of file diff --git a/SharpRSS.Blazor/Components/Layout/BaseLayout.razor.css b/SharpRSS.Blazor/Components/Layout/BaseLayout.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/SharpRSS.Blazor/Components/Layout/EmptyLayout.razor b/SharpRSS.Blazor/Components/Layout/EmptyLayout.razor new file mode 100644 index 0000000..d9388c1 --- /dev/null +++ b/SharpRSS.Blazor/Components/Layout/EmptyLayout.razor @@ -0,0 +1,8 @@ +@inherits LayoutComponentBase +@layout BaseLayout + +@Body + +@code { + +} \ No newline at end of file diff --git a/SharpRSS.Blazor/Components/Layout/EmptyLayout.razor.css b/SharpRSS.Blazor/Components/Layout/EmptyLayout.razor.css new file mode 100644 index 0000000..e69de29 diff --git a/SharpRSS.Blazor/Components/Layout/MainLayout.razor b/SharpRSS.Blazor/Components/Layout/MainLayout.razor index d81c772..fb36494 100644 --- a/SharpRSS.Blazor/Components/Layout/MainLayout.razor +++ b/SharpRSS.Blazor/Components/Layout/MainLayout.razor @@ -1,27 +1,18 @@ @inherits LayoutComponentBase +@layout ApplicationLayout - - - +SharpRSS -
- + + + Home + + + +@Body -
-
- About -
- -
- @Body -
-
-
- -
- An unhandled error has occurred. - Reload - 🗙 -
\ No newline at end of file +@code +{ + [CascadingParameter] + public ApplicationLayout ApplicationLayout { get; set; } = null!; +} diff --git a/SharpRSS.Blazor/Components/Pages/Counter.razor b/SharpRSS.Blazor/Components/Pages/Counter.razor deleted file mode 100644 index 818def9..0000000 --- a/SharpRSS.Blazor/Components/Pages/Counter.razor +++ /dev/null @@ -1,20 +0,0 @@ -@page "/counter" -@rendermode InteractiveServer - -Counter - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } - -} \ No newline at end of file diff --git a/SharpRSS.Blazor/Components/Pages/Weather.razor b/SharpRSS.Blazor/Components/Pages/Weather.razor deleted file mode 100644 index f31f2ee..0000000 --- a/SharpRSS.Blazor/Components/Pages/Weather.razor +++ /dev/null @@ -1,67 +0,0 @@ -@page "/weather" -@attribute [StreamRendering] - -Weather - -

Weather

- -

This component demonstrates showing data.

- -@if (forecasts == null) -{ -

- Loading... -

-} -else -{ - - - - - - - - - - - @foreach (var forecast in forecasts) - { - - - - - - - } - -
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
-} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { - // Simulate asynchronous loading to demonstrate streaming rendering - await Task.Delay(500); - - var startDate = DateOnly.FromDateTime(DateTime.Now); - var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; - forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = summaries[Random.Shared.Next(summaries.Length)] - }).ToArray(); - } - - private class WeatherForecast - { - public DateOnly Date { get; set; } - public int TemperatureC { get; set; } - public string? Summary { get; set; } - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } - -} \ No newline at end of file diff --git a/SharpRSS.Blazor/Components/_Imports.razor b/SharpRSS.Blazor/Components/_Imports.razor index c6bdff2..22cab9c 100644 --- a/SharpRSS.Blazor/Components/_Imports.razor +++ b/SharpRSS.Blazor/Components/_Imports.razor @@ -10,4 +10,5 @@ @using SharpRSS.Blazor @using SharpRSS.Blazor.Components @*MudBlazor*@ -@using MudBlazor \ No newline at end of file +@using MudBlazor +@using MudBlazor.Components \ No newline at end of file