Files
radzen-blazor/Radzen.Blazor/QueryStringThemeService.cs

193 lines
7.3 KiB
C#
Raw Normal View History

5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
using System;
using System.Collections.Generic;
using System.Reflection;
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace Radzen
{
/// <summary>
/// Options for the <see cref="QueryStringThemeService" />.
/// </summary>
public class QueryStringThemeServiceOptions
{
/// <summary>
/// Gets or sets the query string parameter for the theme.
/// </summary>
public string ThemeParameter { get; set; } = "theme";
/// <summary>
/// Gets or sets the query string parameter for the wcag compatible color theme.
/// </summary>
public string WcagParameter { get; set; } = "wcag";
/// <summary>
/// Gets or sets the query string parameter for the right to left theme.
/// </summary>
public string RightToLeftParameter { get; set; } = "rtl";
}
/// <summary>
/// Persist the current theme in the query string. Requires <see cref="ThemeService" /> to be registered in the DI container.
/// </summary>
public class QueryStringThemeService : IDisposable
{
private readonly NavigationManager navigationManager;
private readonly ThemeService themeService;
#if NET7_0_OR_GREATER
private readonly IDisposable? registration;
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
#endif
private readonly QueryStringThemeServiceOptions? options;
private readonly PropertyInfo? hasAttachedJSRuntimeProperty;
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
/// <summary>
/// Initializes a new instance of the <see cref="QueryStringThemeService" /> class.
/// </summary>
public QueryStringThemeService(NavigationManager navigationManager, ThemeService themeService, IOptions<QueryStringThemeServiceOptions> options)
{
ArgumentNullException.ThrowIfNull(navigationManager);
ArgumentNullException.ThrowIfNull(themeService);
ArgumentNullException.ThrowIfNull(options);
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
this.navigationManager = navigationManager;
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
this.themeService = themeService;
this.options = options.Value;
hasAttachedJSRuntimeProperty = navigationManager.GetType().GetProperty("HasAttachedJSRuntime");
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
var state = GetStateFromQueryString(navigationManager.Uri);
if (state.theme != null && RequiresChange(state))
{
themeService.SetTheme(new ThemeOptions
{
Theme = state.theme,
Wcag = state.wcag,
RightToLeft = state.rightToLeft,
TriggerChange = true
});
}
themeService.ThemeChanged += OnThemeChanged;
#if NET7_0_OR_GREATER
try
{
registration = navigationManager.RegisterLocationChangingHandler(OnLocationChanging);
}
catch (NotSupportedException)
{
// HttpNavigationManager does not support that
}
#endif
}
private bool RequiresChange((string? theme, bool? wcag, bool? rightToLeft) state) =>
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
(state.theme != null && !string.Equals(themeService.Theme, state.theme, StringComparison.OrdinalIgnoreCase)) ||
themeService.Wcag != state.wcag || themeService.RightToLeft != state.rightToLeft;
#if NET7_0_OR_GREATER
private ValueTask OnLocationChanging(LocationChangingContext context)
{
var state = GetStateFromQueryString(context.TargetLocation);
if (RequiresChange(state))
{
context.PreventNavigation();
navigationManager.NavigateTo(GetUriWithStateQueryParameters(context.TargetLocation), replace: true);
}
return ValueTask.CompletedTask;
}
#endif
private (string? theme, bool? wcag, bool? rightToLeft) GetStateFromQueryString(string uri)
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
{
var queryString = uri.Contains('?', StringComparison.Ordinal) ? uri[(uri.IndexOf('?', StringComparison.Ordinal) + 1)..] : string.Empty;
var query = HttpUtility.ParseQueryString(queryString.Contains('#', StringComparison.Ordinal) ? queryString[..queryString.IndexOf('#', StringComparison.Ordinal)] : queryString);
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
bool? wcag = options?.WcagParameter != null ? (query.Get(options.WcagParameter) != null ? query.Get(options.WcagParameter) == "true" : null) : null;
bool? rtl = options?.RightToLeftParameter != null ? (query.Get(options.RightToLeftParameter) != null ? query.Get(options.RightToLeftParameter) == "true" : null) : null;
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
return (query?.Get(options?.ThemeParameter), wcag, rtl);
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
}
private string GetUriWithStateQueryParameters(string uri)
{
var parameters = new Dictionary<string, object?>
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
{
{ options?.ThemeParameter ?? string.Empty, themeService?.Theme?.ToLowerInvariant() ?? string.Empty },
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
};
if (themeService?.Wcag != null && options?.WcagParameter != null)
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
{
parameters.Add(options.WcagParameter, themeService.Wcag.Value ? "true" : "false");
}
if (themeService?.RightToLeft != null && options?.RightToLeftParameter != null)
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
{
parameters.Add(options.RightToLeftParameter, themeService.RightToLeft.Value ? "true" : "false");
}
return navigationManager.GetUriWithQueryParameters(uri, new Dictionary<string, object?>(parameters));
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
}
private void OnThemeChanged()
{
if (hasAttachedJSRuntimeProperty is null || hasAttachedJSRuntimeProperty.GetValue(navigationManager) is true)
{
var state = GetStateFromQueryString(navigationManager.Uri);
navigationManager.NavigateTo(GetUriWithStateQueryParameters(navigationManager.Uri),
forceLoad: state.rightToLeft != themeService.RightToLeft);
}
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
}
/// <inheritdoc />
public void Dispose()
{
themeService.ThemeChanged -= OnThemeChanged;
#if NET7_0_OR_GREATER
registration?.Dispose();
#endif
GC.SuppressFinalize(this);
5.0 (#1603) * Initial commit Update spacing css classes in demos Update spacing css classes in demos Improve Notification layout and styles Fix Notification with custom position in RTL mode Update spacing css classes in demos Add box-sizing: border-box to components Remove bootstrap css from App.razor Fix text-align in tabs demos Rename CSS classes and update markup in RadzenDatePicker Remove bootstrap scss Tabs anchor element should inherit the text color Update margins in typography Remove bootstrap instructions from get started page Remove bootstrap css from demos Update premium themes Add variable fonts Remove legacy color tokens and token maps Remove --rz-form-group-margin-bottom as it is not used Add base color tokens Add Base style values Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Remove -styles scss map and use and styles maps instead Format button's styles Reset body margin to 0 Splitter icons should use --rz-icon-font-family Add styles for image and svg Replace MaterialIcons font with MaterialSymbols variable font Update RadzenButton's demos Update RadzenBadge's demos Update Colors demo page Update RadzenProgressBars' demos Use Base instead of Secondary button style in Confirm Dialog Update DataGrid Hierarchy demos Unify DataGrid filter buttons Replace light with base button styles Replace secondary with base button style RadzenTheme, RadzenThemeSwitch and ThemeService. Reorder base color variables Add rtl mode animation to ProgressBar Update SpeechToTextButton default button style and animation Add CookieThemeService. Fix base color variable value in software theme Add Software Dark and Humanistic Dark themes Update RadzenThemeSwitch Default base text button should inherit color from its parent element Update ColoPicker background for transparent color preview Add Material Dark theme Material Dark theme is now free Remove ambiguous method name. Update demos configurator Update premium themes Update the services to follow the options pattern for DI registration. Improve RadzenThemeSwitch to use the current theme. Rename ThemeSwitch to AppearanceToggle and add a demo page Update SplitButton's dropdown icon demo Create getting-started.html Update getting-started.html Update getting-started.html Add --rz-grid-group-header-item-color and fix column footer color Fix demos code snippet colors Add changelog and update demo status badges Update Changelog Persist the current theme. Update getting-started.html Rename getting-started.html to md. Render the theme CSS class at RadzenLayout level. Hide the right sidebar by default. Isolate CSS variables in a single rule Revamp the getting started help article. Remove nested README.md. Link getting started instructions. Add Scheduler highlight background color css variable Sidebar border right should be inline-end Inputs should inherit font-family Buttons in code viewer and event console should use base button style Add Standard Dark theme Update Changelog Sidebar border right in themes should be inline-end Render RadzenTheme only when needed. Add cursor pointer to SidebarToggle Fix AppearanceToggle margin Update default theme colors Update standard theme colors Fix filter color in humanistic dark theme Update software dark theme colors Add humanistic dark wcag theme Add software dark wcag theme Add standard dark wcag theme Buttons for add and remove now use base button style Update Get Started styling Update Dark WCAG theme colors Update SideBar transition styles Remove theme name css class Add premium themes code fixed more code fixes * Update Icon demo page content * Fix --rz-grid-filter-buttons-background-color in Standard theme * Remove obsolete fonts * tests fixed --------- Co-authored-by: yordanov <vasil@yordanov.info>
2024-07-18 16:24:20 +03:00
}
}
/// <summary>
/// Extension methods to register the <see cref="QueryStringThemeService" />.
/// </summary>
public static class QueryStringThemeServiceCollectionExtensions
{
/// <summary>
/// Adds the <see cref="QueryStringThemeService" /> to the service collection.
/// </summary>
public static IServiceCollection AddRadzenQueryStringThemeService(this IServiceCollection services)
{
services.AddOptions<QueryStringThemeServiceOptions>();
services.AddScoped<QueryStringThemeService>();
return services;
}
/// <summary>
/// Adds the <see cref="QueryStringThemeService" /> to the service collection with the specified condiguration.
/// </summary>
public static IServiceCollection AddRadzenQueryStringThemeService(this IServiceCollection services, Action<QueryStringThemeServiceOptions> configure)
{
services.Configure(configure);
services.AddScoped<QueryStringThemeService>();
return services;
}
}
}