mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 13:37:35 +08:00
822ce2dd36
* feat: add themes * add docs theming styles * fix the RTL for FixedWidgets * fix aliyun theme * fix docs style
32 lines
876 B
C#
32 lines
876 B
C#
using System.Threading.Tasks;
|
|
using AntDesign.Docs.Localization;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AntDesign.Docs.Shared
|
|
{
|
|
public partial class FixedWidgets
|
|
{
|
|
[Inject] private ILanguageService Language { get; set; }
|
|
[Inject] private IJSRuntime JS { get; set; }
|
|
|
|
private ElementReference _linkRef;
|
|
|
|
private string _themeFileUrl;
|
|
|
|
|
|
private async Task ChangeTheme(string theme)
|
|
{
|
|
_themeFileUrl = $"_content/AntDesign.Docs/css/docs.{theme}.css";
|
|
|
|
await JS.InvokeVoidAsync(JSInteropConstants.SetDomAttribute, "body", new Dictionary<string, string>
|
|
{
|
|
["data-theme"] = theme
|
|
});
|
|
|
|
await JS.InvokeVoidAsync(JSInteropConstants.AddElementToBody, _linkRef);
|
|
}
|
|
}
|
|
}
|