Skip to content

Commit

Permalink
PureHeader customization updates
Browse files Browse the repository at this point in the history
  • Loading branch information
codymullins committed Apr 2, 2024
1 parent 5c75b9d commit aa04e9a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all"/>
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1"/>
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pure.Blazor.Components\Pure.Blazor.Components.csproj" />
<ProjectReference Include="..\Pure.Blazor.Components\Pure.Blazor.Components.csproj"/>
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\app.css">
Expand Down
6 changes: 3 additions & 3 deletions src/Pure.Blazor.Components.Docs/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
@inherits LayoutComponentBase
@using Pure.Blazor.Components.Common
@inject NavigationManager Nav
@inject IElementUtils ElementUtils
@inject ILogger<MainLayout> Log

<PureHeader Title="pureblazor components">
<PureHeader Title="pureblazor components" Accent="Accent.Brand" Height="PureSize.ExtraLarge">
@* <PureDarkModeToggle /> *@
<a aria-label="GitHub Repository" href="https://github.com/pureblazor/components" target="_blank" class="mr-5 hover:text-white cursor-pointer">
<img src="GitHub-Mark-Light-64px.png" width="32" alt="GitHub logo"/>
Expand All @@ -17,6 +16,7 @@
</article>

@code {

protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
Expand All @@ -42,4 +42,4 @@
}
}

}
}
2 changes: 1 addition & 1 deletion src/Pure.Blazor.Components/Common/Accent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public enum Accent
Brand,
Success,
Danger,
Warning
Warning,
}
7 changes: 2 additions & 5 deletions src/Pure.Blazor.Components/Common/PureComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

protected override void OnParametersSet()
{
if (prevStyles != Styles)
{
prevStyles = Styles;
BuildCss();
}
// todo: figure out how to build css less
BuildCss();
}

[CascadingParameter] public ThemeProvider? ThemeProvider { get; set; } = new();
Expand Down
41 changes: 34 additions & 7 deletions src/Pure.Blazor.Components/Layout/PureHeader.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@namespace Pure.Blazor.Components
@inherits PureComponent
@namespace Pure.Blazor.Components

<header class="text-gray-400 bg-gray-900 body-font border-b border-slate-600">
<div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center">
<header class="@containerCss">
<div class="container mx-auto flex flex-wrap flex-col md:flex-row items-center @innerContainerCss">
<a class="flex title-font font-medium items-center text-gray-100" href="/">
<span class="text-xl">@Title</span>
</a>
Expand All @@ -14,9 +15,35 @@
</header>

@code {
[Parameter]
public string Title { get; set; }
private string containerCss = "";
private string innerContainerCss = "";

[Parameter] public string? Title { get; set; }

[Parameter] public string ContainerCss { get; set; } = "text-gray-200 bg-brand-900 body-font border-b border-brand-600";

[Parameter] public Accent Accent { get; set; } = Accent.Brand;

[Parameter] public PureSize Height { get; set; } = PureSize.Medium;

protected override void BuildCss()
{
containerCss = Accent switch
{
Accent.Default => "text-gray-400 bg-gray-900 body-font border-b border-slate-600",
Accent.Brand => "text-gray-200 bg-brand-900 body-font border-b border-brand-600",
_ => ""
};

innerContainerCss = Height switch
{
PureSize.ExtraSmall => "px-5 py-1",
PureSize.Small => "px-5 py-2",
PureSize.Medium => "px-5 py-3",
PureSize.Large => "px-5 py-5",
PureSize.ExtraLarge => "px-5 py-6",
_ => ""
};
}

[Parameter]
public RenderFragment? ChildContent { get; set; }
}

0 comments on commit aa04e9a

Please sign in to comment.