ant-design-blazor/site/AntDesign.Docs/Shared/FixedWidgets.razor.cs
James Yeung 822ce2dd36 feat: add built-in themes (#1286)
* feat: add themes

* add docs theming styles

* fix the RTL for FixedWidgets

* fix aliyun theme

* fix docs style
2021-03-31 19:23:32 +08:00

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);
}
}
}