ant-design-blazor/site/AntDesign.Docs/Shared/MainFooter.razor.cs
James Yeung 0b738663a1 docs: dynamic primary color changing (#1332)
* feat(docs): change color dynamically

* docs: dynamic primary color changing

* fix file path

* delete the script
2021-04-10 12:34:41 +08:00

43 lines
1.2 KiB
C#

using System.Threading.Tasks;
using AntDesign.Docs.Localization;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace AntDesign.Docs.Shared
{
public partial class MainFooter
{
// region: color
private static string _colorHex = "#1890ff";
[Inject] private IJSRuntime JS { get; set; }
[Inject] private MessageService Message { get; set; }
[Inject] private ILanguageService Language { get; set; }
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
Language.LanguageChanged += (sender, args) =>
{
InvokeAsync(StateHasChanged);
};
}
private async Task ChangeColor(ChangeEventArgs args)
{
_colorHex = args.Value.ToString();
await Message.Loading(Language.Resources["app.footer.primary-color-changing"]);
await JS.InvokeVoidAsync("changeColor", _colorHex, DotNetObjectReference.Create(this));
}
[JSInvokable]
public void OnColorChanged()
{
Message.Success(Language.Resources["app.footer.primary-color-changed"]);
}
}
}