Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codymullins committed Mar 22, 2024
1 parent 8d302ff commit 63121f9
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 57 deletions.
Binary file removed src/.DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions src/Pure.Blazor.Components/Common/ElementUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class ElementUtils : IElementUtils

public ElementUtils(IJSRuntime jsRuntime) => JS = jsRuntime;

//_moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>(
// "import", "./_content/PureBlazor.Components/makani.js").AsTask());
/// <summary>
/// Blurs the active element.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion src/Pure.Blazor.Components/Common/PureComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@

protected virtual string ApplyStyle(string style)
{
return Theme == Theme.Off ? "" : style;
if (Theme == Theme.Off)
{
return Styles ?? "";
}

return $"{style} {Styles}";
}

}
12 changes: 5 additions & 7 deletions src/Pure.Blazor.Components/Display/PureCard.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@namespace Pure.Blazor.Components
@using Pure.Blazor.Components.Essentials
@inherits PureComponent

@if (Alignment == PureCardAlignment.Top)
Expand All @@ -8,7 +9,7 @@
{
<img src="@ImageUrl">
}
<div class="px-6 py-4">
<div class="px-2 py-2.5">
@if (!string.IsNullOrWhiteSpace(Title))
{
<Header2>@Title</Header2>
Expand Down Expand Up @@ -41,12 +42,9 @@ else

@code {

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

[Parameter]
public PureCardAlignment Alignment { get; set; }
[Parameter] public PureCardAlignment Alignment { get; set; }

[Parameter]
public string? ImageUrl { get; set; }
[Parameter] public string? ImageUrl { get; set; }
}
11 changes: 11 additions & 0 deletions src/Pure.Blazor.Components/Essentials/PureLabel.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@inherits PureComponent
<div class="@ApplyStyle("font-semibold")">@ChildContent</div>

@code {

// required styles for accessibility, not overridable
// touch target should be at least 24px
// make it the same here since this field is often combined with <PureLink>
// https://www.w3.org/WAI/WCAG21/Understanding/touch-target-size.html
private string AccessibilityStyles => "inline-block py-1";
}
11 changes: 7 additions & 4 deletions src/Pure.Blazor.Components/Essentials/PureLink.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
@using Pure.Blazor.Components.Common
@inherits PureComponent
@inherits PureComponent
@namespace Pure.Blazor.Components

@if (Variant is null or ButtonVariant.Subtle)
{
<a class="@ApplyStyle(PureStyles.Link.Base) @Styles" href="@Url" target="@GetTarget()">@ChildContent</a>
<a class="@AccessibilityStyles @ApplyStyle(PureStyles.Link.Base) @Styles" href="@Url" target="@GetTarget()">@ChildContent</a>
}
else
{
Expand All @@ -19,14 +18,18 @@ else
[Parameter] public string? Url { get; set; }

/// <summary>
/// Style the link as a button
/// Style the link as a button
/// </summary>
[Parameter]
public ButtonVariant? Variant { get; set; }

[Parameter] public LinkTarget Target { get; set; }

// required styles for accessibility, not overridable
// touch target should be at least 24px
private string AccessibilityStyles => "inline-block py-1";
private string InternalCss => $"{PureStyles.Button.Base} {PureStyles.Button.Variants[Variant ?? ButtonVariant.Default][Accent.Brand]} {PureStyles.Button.Sizes[PureSize.Medium]}";

private string GetTarget()
{
return Target switch
Expand Down
11 changes: 11 additions & 0 deletions src/Pure.Blazor.Components/Essentials/PureText.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@inherits PureComponent
<div class="@AccessibilityStyles @Styles">@ChildContent</div>

@code {

// required styles for accessibility, not overridable
// touch target should be at least 24px
// make it the same here since this field is often combined with <PureLink>
// https://www.w3.org/WAI/WCAG21/Understanding/touch-target-size.html
private string AccessibilityStyles => "py-1";
}
27 changes: 13 additions & 14 deletions src/Pure.Blazor.Components/Forms/PureInput.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@namespace Pure.Blazor.Components
@* @using PureBlazor.Components.Components.Forms.Validators *@
@using Pure.Blazor.Components.Forms.Validators
@using System.Text.RegularExpressions
@* @using PureBlazor.Components.Components.Forms *@
@using Pure.Blazor.Components.Forms.Validators
@implements IFormComponent
@inject ILogger<PureInput> Log

Expand Down Expand Up @@ -107,25 +105,25 @@
[CascadingParameter] public PureForm? FormControl { get; set; }

/// <summary>
/// Defaults to immediate mode
/// Defaults to immediate mode
/// </summary>
[Parameter]
public EntryMode Mode { get; set; } = EntryMode.Immediate;

/// <summary>
/// Optional label (recommended)
/// Optional label (recommended)
/// </summary>
[Parameter]
public string? Label { get; set; }

/// <summary>
/// Optional label type
/// Optional label type
/// </summary>
[Parameter]
public PureLabelType LabelType { get; set; }

/// <summary>
/// Optional helper text
/// Optional helper text
/// </summary>
[Parameter]
public string? HelperText { get; set; }
Expand All @@ -135,45 +133,45 @@
[Parameter] public EventCallback<string> ValueChanged { get; set; }

/// <summary>
/// Makes the input required.
/// Makes the input required.
/// </summary>
[Parameter]
public bool? Required { get; set; }

/// <summary>
/// Enforces a minimum string length.
/// Enforces a minimum string length.
/// </summary>
[Parameter]
public int? MinLength { get; set; }

/// <summary>
/// Enforces a maximum string length.
/// Enforces a maximum string length.
/// </summary>
[Parameter]
public int? MaxLength { get; set; }

/// <summary>
/// Enforces a minimum for integers.
/// Enforces a minimum for integers.
/// </summary>
[Parameter]
public int? Min { get; set; }

/// <summary>
/// Enforces a maximum for integers.
/// Enforces a maximum for integers.
/// </summary>
[Parameter]
public int? Max { get; set; }

/// <summary>
/// Validates using the Regular Expression.
/// Validates using the Regular Expression.
/// </summary>
[Parameter]
public string? Regex { get; set; }

[Parameter] public string? Placeholder { get; set; } = " "; // default placeholder to an empty string. required for floating labels.
/// <summary>
/// Invoked when a validator indicates a validation error.
/// Invoked when a validator indicates a validation error.
/// </summary>
[Parameter]
public EventCallback<IList<ValidationResult>> OnError { get; set; }
Expand Down Expand Up @@ -239,4 +237,5 @@

return string.Empty;
}

}
45 changes: 16 additions & 29 deletions src/Pure.Blazor.Components/Forms/PureRadioGroup.razor
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
@using System.Text.RegularExpressions
@using Pure.Blazor.Components.Common

<CascadingValue Value="this">
<CascadingValue Value="this">
<fieldset>
@if (!String.IsNullOrEmpty(Title))
@if (!string.IsNullOrEmpty(Title))
{
<legend class="text-sm font-medium leading-6 text-gray-900">@Title</legend>
}
@ChildContent
@if (@ChildContent is null)
@if (ChildContent is null)
{
@foreach (var option in @Items)
@foreach (var option in Items)
{
<PureRadio Checked="@(option.Checked)" Description="@(option.Description)" Title="@(option.Title)" Value="@(option.Value)" Id="@(option.Id)" />
<PureRadio Checked="@(option.Checked)" Description="@(option.Description)" Title="@(option.Title)" Value="@(option.Value)" Id="@(option.Id)"/>
}

}
else
{
@foreach(var option in @Items)
@foreach (var option in Items)
{
if(option.Value == CheckedValue)
if (option.Value == CheckedValue)
{
@option.ChildContent
}
Expand All @@ -31,23 +27,17 @@

@code {

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

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

[Parameter]
public List<PureRadio> Items { get; set; } = new();
[Parameter] public List<PureRadio> Items { get; set; } = new();

[Parameter, EditorRequired]
public string Name { get; set; }
[Parameter] [EditorRequired] public string Name { get; set; }

[Parameter]
public string CheckedValue { get; set; }
[Parameter] public string CheckedValue { get; set; }

[Parameter]
public EventCallback<string> OnRadioChanged { get; set; }
[Parameter] public EventCallback<string> OnRadioChanged { get; set; }

public Action ValuesChanged;

Expand All @@ -65,14 +55,9 @@
base.OnInitialized();
}

protected override void OnParametersSet()
{
base.OnParametersSet();
}

public async Task OnValueChange(string value)
{
bool valueChanged = value != CheckedValue;
var valueChanged = value != CheckedValue;

CheckedValue = value;
await OnRadioChanged.InvokeAsync(value);
Expand All @@ -81,9 +66,11 @@
ValuesChanged.Invoke();
}
}

public void AddButton(PureRadio radio)
{
Items.Add(radio);
StateHasChanged();
}

}

0 comments on commit 63121f9

Please sign in to comment.