From 458399b1daa17eed7b53ae1c3b12d358cb2e504f Mon Sep 17 00:00:00 2001 From: Cody Mullins <1738479+codymullins@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:33:31 -0400 Subject: [PATCH] update PureLabel styling, add size options for PureTabs --- .../Essentials/PureLabel.razor | 11 ++++- .../Layout/PureTabButton.razor | 45 +++++++++++++------ .../Layout/PureTabs.razor | 41 +++++++---------- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/src/Pure.Blazor.Components/Essentials/PureLabel.razor b/src/Pure.Blazor.Components/Essentials/PureLabel.razor index 6dd0cc3..847baa9 100644 --- a/src/Pure.Blazor.Components/Essentials/PureLabel.razor +++ b/src/Pure.Blazor.Components/Essentials/PureLabel.razor @@ -1,5 +1,5 @@ @inherits PureComponent -
@ChildContent
+ @code { @@ -7,5 +7,12 @@ // touch target should be at least 24px // make it the same here since this field is often combined with // https://www.w3.org/WAI/WCAG21/Understanding/touch-target-size.html - private string AccessibilityStyles => "inline-block py-1"; + private string AccessibilityStyles => "inline-block leading-7"; + + /// + /// The ID of the content that this label is associated with. + /// + [Parameter] + public string? For { get; set; } + } diff --git a/src/Pure.Blazor.Components/Layout/PureTabButton.razor b/src/Pure.Blazor.Components/Layout/PureTabButton.razor index 25bb7bc..602f60c 100644 --- a/src/Pure.Blazor.Components/Layout/PureTabButton.razor +++ b/src/Pure.Blazor.Components/Layout/PureTabButton.razor @@ -1,20 +1,21 @@ @using System.Text - +@inherits PureComponent + @Title + @code { - [Parameter] - public string Title { get; set; } = string.Empty; + private const string BaseCss = "w-1/2 sm:w-auto justify-center sm:justify-start inline-flex items-center"; + [Parameter] public string Title { get; set; } = string.Empty; + + [Parameter] public bool IsActive { get; set; } - [Parameter] - public bool IsActive { get; set; } + [Parameter] public TabVariant Variant { get; set; } - [Parameter] - public TabVariant Variant { get; set; } + [Parameter] public PureSize Size { get; set; } - [Parameter] - public EventCallback OnClick { get; set; } + [Parameter] public EventCallback OnClick { get; set; } private string InternalCss { get; set; } = string.Empty; @@ -22,12 +23,29 @@ { base.OnParametersSet(); - InternalCss = BuildCss(); + BuildCss(); } - public string BuildCss() + protected override void BuildCss() { - var builder = new StringBuilder(); + var builder = new StringBuilder(BaseCss); + + switch (Size) + { + case PureSize.ExtraSmall: + case PureSize.Small: + builder.Append(" sm:px-6 py-1 text-xs"); + break; + case PureSize.Medium: + builder.Append(" sm:px-6 px-3 py-2 text-sm"); + break; + case PureSize.ExtraLarge: + case PureSize.Large: + builder.Append(" sm:px-6 px-4 py-3 text-lg"); + break; + default: + throw new ArgumentOutOfRangeException(); + } switch (Variant) { @@ -48,6 +66,7 @@ throw new ArgumentOutOfRangeException(); } - return builder.ToString(); + InternalCss = builder.ToString(); } + } diff --git a/src/Pure.Blazor.Components/Layout/PureTabs.razor b/src/Pure.Blazor.Components/Layout/PureTabs.razor index 55c7b8e..ce562be 100644 --- a/src/Pure.Blazor.Components/Layout/PureTabs.razor +++ b/src/Pure.Blazor.Components/Layout/PureTabs.razor @@ -1,10 +1,11 @@ - -
-
-
+@inherits PureComponent + +
+
+
@foreach (var tab in Tabs) { - + }
@@ -16,35 +17,23 @@ @code { - // [Text(TextColor.Gray100)] - // [Border(BorderColor.Brand400)] - // [Background(BackgroundColor.Brand300)] - // public string? defaultButtonCss; + [Parameter] public EventCallback OnChanging { get; set; } - // [Text(TextColor.Gray, 900)] // or [Text(TextColor.Gray, Shade = 900)] - // [Border(BorderColor.Brand)] - // [Background(BackgroundColor.Gray, 100)] - // public string? secondaryButtonCss; + [Parameter] public TabVariant Variant { get; set; } - [Parameter] - public RenderFragment? ChildContent { get; set; } - - [Parameter] - public EventCallback OnChanging { get; set; } - - [Parameter] - public TabVariant Variant { get; set; } + [Parameter] public PureSize Size { get; set; } = PureSize.Medium; public PureTabContent? CurrentTab { get; set; } - private string InternalCss { get; set; } + private string InternalCss { get; set; } = ""; - internal List Tabs { get; set; } = new List(); + internal List Tabs { get; set; } = new(); + protected override void OnParametersSet() { base.OnParametersSet(); - InternalCss = BuildCss(); + BuildCss(); } internal void ChangeTab(PureTabContent tab) @@ -55,9 +44,8 @@ CurrentTab = tab; } - public string BuildCss() + protected override void BuildCss() { - return ""; } internal void AddTab(PureTabContent tab) @@ -71,4 +59,5 @@ StateHasChanged(); } + }