feat(theme): BrandBar
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
@* Components/BrandBar.razor *@
|
||||||
|
<div class="brand">
|
||||||
|
@if (Logo is not null) { @Logo }
|
||||||
|
else { <span class="mark">▮</span> }
|
||||||
|
@Product
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter, EditorRequired] public string Product { get; set; } = string.Empty;
|
||||||
|
[Parameter] public RenderFragment? Logo { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace ZB.MOM.WW.Theme.Tests;
|
||||||
|
|
||||||
|
public class BrandBarTests : TestContext
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Renders_product_with_default_mark()
|
||||||
|
{
|
||||||
|
var cut = RenderComponent<BrandBar>(p => p.Add(x => x.Product, "OtOpcUa"));
|
||||||
|
Assert.Contains("OtOpcUa", cut.Markup);
|
||||||
|
Assert.NotNull(cut.Find(".brand .mark")); // default glyph when no Logo
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Custom_logo_replaces_default_mark()
|
||||||
|
{
|
||||||
|
var cut = RenderComponent<BrandBar>(p => p
|
||||||
|
.Add(x => x.Product, "ScadaBridge")
|
||||||
|
.Add(x => x.Logo, (RenderFragment)(b => b.AddMarkupContent(0, "<img class='logo'/>"))));
|
||||||
|
Assert.NotNull(cut.Find(".brand .logo"));
|
||||||
|
Assert.Empty(cut.FindAll(".brand .mark"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
global using Bunit;
|
global using Bunit;
|
||||||
global using Xunit;
|
global using Xunit;
|
||||||
|
global using Microsoft.AspNetCore.Components;
|
||||||
global using ZB.MOM.WW.Theme;
|
global using ZB.MOM.WW.Theme;
|
||||||
global using ZB.MOM.WW.Theme.Components;
|
global using ZB.MOM.WW.Theme.Components;
|
||||||
|
|||||||
Reference in New Issue
Block a user