In order to Initialize all services, go to the Program.cs file at the project root, add NVServices.AddNovaDesignSystem(builder.Services);
to the Main method.
It will initialize all services from Nova Framework.
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Nova.Services;
using NovaDev;
using System;
using System.Net.Http;
using Microsoft.Extensions.DependencyInjection;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient {BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)});
NVServices.AddNovaDesignSystem(builder.Services);
await builder.Build().RunAsync();
DisplaySidebar show or hide the sidebar.
Parameter Name | Type |
---|---|
show | bool |
bool
@inject Nova.Services.NVAppStateService AppState;
public void ShowSideBar()
{
AppState.DisplaySidebar(true);
}
public void HideSideBar()
{
AppState.DisplaySidebar(false);
}
SetHeaderColor is used to change the main color of the app.
It set the value of private string _headerColor AppState class.
Parameter Name | Type |
---|---|
color | string |
string
@inject Nova.Services.NVAppStateService AppState;
<NVButton OnClick="@(AppState.SetHeaderColor("primary"))">
Primary
</NVButton>
<NVButton OnClick="@(AppState.SetHeaderColor("Secondary"))">
Secondary
</NVButton>
GetHeaderColor is used to retrieve the current main color associated to the header of the app.
Get the value of the private string _headerColor.
Parameter Name | Type |
---|---|
color | string |
string
<NVBlock>@(AppState.GetHeaderColor())</NVBlock>
<div>primary</div>
Check if the sidebar is visible or not.
bool
@inject Nova.Services.NVAppStateService AppState;
<NVBlock>
@($"{(AppState.IsSidebarVisible() ? "visible" : "hidden")}")
<NVBlock>
<div>visible</div>
Show or hide the sidebar of the app.
bool
@implements IDisposable;
@inject Nova.Services.NVAppStateService AppState;
<NVBlock OnClick="@(() => AppState.ToggleDisplaySidebar())">
@($"{(AppState.IsSidebarVisible() ? "visible" : "hidden")}")
<NVBlock>
@code {
protected override void OnInitialized()
{
base.OnInitialized();
AppState.OnChange += StateHasChanged;
_isSidebarVisible = AppState.IsSidebarVisible();
}
public void Dispose()
{
AppState.OnChange -= StateHasChanged;
}
}
<div>visible</div>