Skip to content

Commit

Permalink
Few bugfixes, 1 I accidentally made in the refactor (Icon classes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucasharskamp committed Dec 11, 2024
1 parent ab28b35 commit 5267d6b
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 106 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Alert Color="AlertColor.Primary"> <Icon Name="IconName.InfoCircleFill" class="me-2"></Icon>An example alert with an icon </Alert>
<Alert Color="AlertColor.Success"> <Icon Name="IconName.CheckCircleFill" class="me-2"></Icon>A simple success alert with an icon </Alert>
<Alert Color="AlertColor.Danger"> <Icon Name="IconName.ExclamationTriangleFill" class="me-2"></Icon>A simple danger alert with an icon </Alert>
<Alert Color="AlertColor.Warning"> <Icon Name="IconName.ExclamationTriangleFill" class="me-2"></Icon>A simple warning alert with an icon </Alert>
<Alert Color="AlertColor.Primary"> <Icon Name="IconName.InfoCircleFill" Class="me-2" /> An example alert with an icon </Alert>
<Alert Color="AlertColor.Success"> <Icon Name="IconName.CheckCircleFill" Class="me-2"/> A simple success alert with an icon </Alert>
<Alert Color="AlertColor.Danger"> <Icon Name="IconName.ExclamationTriangleFill" Class="me-2" />A simple danger alert with an icon </Alert>
<Alert Color="AlertColor.Warning"> <Icon Name="IconName.ExclamationTriangleFill" Class="me-2" />A simple warning alert with an icon </Alert>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Alert Color="@alertColor" Dismissable="false"> <Icon Name="@alertIconName" class="me-2"></Icon>@alertMessage </Alert>
<Alert Color="@alertColor" Dismissable="false"> <Icon Name="@alertIconName" Class="me-2" />@alertMessage </Alert>

<Button Color="ButtonColor.Success" @onclick="ShowSuccessAlert"> Success Alert </Button>
<Button Color="ButtonColor.Danger" @onclick="ShowDangerAlert"> Danger Alert </Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Button @ref="saveButton1" Color="ButtonColor.Primary" Size="ButtonSize.ExtraLarge" @onclick="OnSave1Click">
<Icon Name="IconName.Activity"></Icon>
<Icon Name="IconName.Activity" />
</Button>
<Button @ref="saveButton2" Color="ButtonColor.Primary" Size="ButtonSize.Large" @onclick="OnSave2Click">
<Icon Name="IconName.Activity"></Icon>
<Icon Name="IconName.Activity"/>
</Button>
<Button @ref="saveButton3" Color="ButtonColor.Primary" Size="ButtonSize.Medium" @onclick="OnSave3Click">
<Icon Name="IconName.Activity"></Icon>
<Icon Name="IconName.Activity"/>
</Button>
<Button @ref="saveButton4" Color="ButtonColor.Primary" Size="ButtonSize.Small" @onclick="OnSave4Click">
<Icon Name="IconName.Activity"></Icon>
<Icon Name="IconName.Activity"/>
</Button>
<Button @ref="saveButton5" Color="ButtonColor.Primary" Size="ButtonSize.ExtraSmall" @onclick="OnSave5Click">
<Icon Name="IconName.Activity"></Icon>
<Icon Name="IconName.Activity"/>
</Button>
@code {
private Button saveButton1 = default!, saveButton2 = default!, saveButton3 = default!, saveButton4 = default!, saveButton5 = default!;
Expand Down
58 changes: 22 additions & 36 deletions blazorbootstrap/Components/Button/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ private void SetAttributes()

AdditionalAttributes["title"] = TooltipTitle;

AdditionalAttributes["data-bs-custom-class"] = EnumExtensions.TooltipColorClassMap[TooltipColor]!;
if (TooltipColor != TooltipColor.None)
{
AdditionalAttributes["data-bs-custom-class"] = EnumExtensions.TooltipColorClassMap[TooltipColor]!;
}
}
else // button disabled (or) tooltip text empty
{
Expand Down Expand Up @@ -317,8 +320,7 @@ public override Task SetParametersAsync(ParameterView parameters)
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Block { get; set; }
[Parameter] public bool Block { get; set; }

private string ButtonTypeString { get; set; } = "";

Expand All @@ -328,44 +330,39 @@ public override Task SetParametersAsync(ParameterView parameters)
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter] public RenderFragment? ChildContent { get; set; }

/// <summary>
/// Gets or sets the button color.
/// </summary>
/// <remarks>
/// Default value is <see cref="ButtonColor.None" />.
/// </remarks>
[Parameter]
public ButtonColor Color { get; set; } = ButtonColor.None;
[Parameter] public ButtonColor Color { get; set; } = ButtonColor.None;

/// <summary>
/// Gets or sets the button disabled state.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Disabled { get; set; }
[Parameter] public bool Disabled { get; set; }

/// <summary>
/// If <see langword="true" />, shows the loading spinner or a <see cref="LoadingTemplate" />.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Loading { get; set; }
[Parameter] public bool Loading { get; set; }

/// <summary>
/// Gets or sets the button loading template.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public RenderFragment? LoadingTemplate { get; set; }
[Parameter] public RenderFragment? LoadingTemplate { get; set; }

/// <summary>
/// Gets or sets the loading text.
Expand All @@ -374,17 +371,15 @@ public override Task SetParametersAsync(ParameterView parameters)
/// <remarks>
/// Default value is 'Loading...'.
/// </remarks>
[Parameter]
public string LoadingText { get; set; } = "Loading...";
[Parameter] public string LoadingText { get; set; } = "Loading...";

/// <summary>
/// Gets or sets the button outline.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Outline { get; set; }
[Parameter] public bool Outline { get; set; }

/// <summary>
/// Gets or sets the position.
Expand All @@ -393,80 +388,71 @@ public override Task SetParametersAsync(ParameterView parameters)
/// <remarks>
/// Default value is <see cref="Position.None" />.
/// </remarks>
[Parameter]
public Position Position { get; set; } = Position.None;
[Parameter] public Position Position { get; set; } = Position.None;

/// <summary>
/// Gets or sets the button size.
/// </summary>
/// <remarks>
/// Default value is <see cref="ButtonSize.None" />.
/// </remarks>
[Parameter]
public ButtonSize Size { get; set; } = ButtonSize.None;
[Parameter] public ButtonSize Size { get; set; } = ButtonSize.None;

/// <summary>
/// Gets or sets the button tab index.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public int? TabIndex { get; set; }
[Parameter] public int? TabIndex { get; set; }

/// <summary>
/// Gets or sets the link button target.
/// </summary>
/// <remarks>
/// Default value is <see cref="Target.None" />
/// </remarks>
[Parameter]
public Target Target { get; set; } = Target.None;
[Parameter] public Target Target { get; set; } = Target.None;

/// <summary>
/// Gets or sets the link button href attribute.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public string? To { get; set; }
[Parameter] public string? To { get; set; }

/// <summary>
/// Gets or sets the button tooltip color.
/// </summary>
/// <remarks>
/// Default value is <see cref="TooltipColor.None" />.
/// </remarks>
[Parameter]
public TooltipColor TooltipColor { get; set; } = TooltipColor.None;
[Parameter] public TooltipColor TooltipColor { get; set; } = TooltipColor.None;

/// <summary>
/// Gets or sets the button tooltip placement.
/// </summary>
/// <remarks>
/// Default value is <see cref="TooltipPlacement.Top" />.
/// </remarks>
[Parameter]
public TooltipPlacement TooltipPlacement { get; set; } = TooltipPlacement.Top;
[Parameter] public TooltipPlacement TooltipPlacement { get; set; } = TooltipPlacement.Top;

/// <summary>
/// Gets or sets the button tooltip title.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public string TooltipTitle { get; set; } = default!;
[Parameter] public string? TooltipTitle { get; set; }

/// <summary>
/// Gets or sets the button type.
/// </summary>
/// <remarks>
/// Default value is <see cref="ButtonType.Button" />.
/// </remarks>
[Parameter]
public ButtonType Type { get; set; } = ButtonType.Button;
[Parameter] public ButtonType Type { get; set; } = ButtonType.Button;

#endregion

Expand Down Expand Up @@ -516,7 +502,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
}
else if (ChildContent != null)
{
builder.AddContent(16, ChildContent);
builder.AddContent(8, ChildContent);
}
builder.CloseElement();
}
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Callout/Callout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
<div class="@(BootstrapClass.CalloutHeading) mb-2">
<strong>
<Icon Name="@IconName" class="me-2"></Icon>@Heading
<Icon Name="@IconName" Class="me-2" />@Heading
</strong>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
{
<Button @ref="closeButton"
Class="border-0 position-absolute end-0"
Style="@DeleteButtonStyle"
style="@DeleteButtonStyle"
Disabled="@Disabled"
@onclick="ClearInputTextAsync">

<Icon Name="IconName.XLg"></Icon>
<Icon Name="IconName.XLg" />

</Button>
}
Expand Down
4 changes: 2 additions & 2 deletions blazorbootstrap/Components/Grid/GridColumnFilter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
else if (PropertyTypeName == StringConstants.PropertyTypeNameEnum)
{
<Dropdown>
<DropdownToggleButton Class="px-1" Style="@FilterStyle">
<DropdownToggleButton Class="px-1" style="@FilterStyle">
@if (string.IsNullOrWhiteSpace(FilterValue))
{
<span class="px-2">@EnumFilterSelectText</span>
Expand All @@ -53,7 +53,7 @@
<span class="px-2">@FilterValue</span>
}
</DropdownToggleButton>
<DropdownMenu Class="bb-dropdown-menu-enum" Style="max-height: var(--bb-grid-filter-dropdown-max-height); overflow-x: hidden; overflow-y: auto;">
<DropdownMenu Class="bb-dropdown-menu-enum" style="max-height: var(--bb-grid-filter-dropdown-max-height); overflow-x: hidden; overflow-y: auto;">
@if (PropertyType is not null)
{
@foreach (var item in Enum.GetValues(PropertyType!))
Expand Down
11 changes: 8 additions & 3 deletions blazorbootstrap/Components/Icon/Icon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public override Task SetParametersAsync(ParameterView parameters)
{
switch (parameter.Name)
{
case "class": Class = (string)parameter.Value!; break;
case nameof(Class): Class = (string)parameter.Value!; break;
case nameof(Color): Color = (IconColor)parameter.Value; break;
case nameof(CustomIconName): CustomIconName = (string)parameter.Value; break;
Expand All @@ -79,10 +80,14 @@ public override Task SetParametersAsync(ParameterView parameters)
/// <inheritdoc />
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
var cssClasses = $"{Class} {BootstrapIconUtility.IconSize(Size)} {EnumExtensions.IconColorClassMap[Color]}";
if (!String.IsNullOrWhiteSpace(CustomIconName))
var cssClasses = $"{Class} {BootstrapIconUtility.IconSizeClassMap[Size]} {EnumExtensions.IconColorClassMap[Color]}";
if (String.IsNullOrEmpty(CustomIconName))
{
cssClasses += $" {BootstrapIconUtility.IconPrefix} {BootstrapIconUtility.Icon(Name)} {CustomIconName}";
cssClasses += $" {BootstrapIconUtility.IconPrefix} {BootstrapIconUtility.Icon(Name)}";
}
else
{
cssClasses += $" {CustomIconName}";
}
builder.OpenElement(0, "i");
builder.AddAttribute(1, "id", Id);
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Modals/Modal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@if (ShowCloseButton)
{
<Icon Color="@CloseIconColor" Name="IconName.XLg" role="button" @onclick="(async() => await HideAsync())"></Icon>
<Icon Color="@CloseIconColor" Name="IconName.XLg" role="button" @onclick="(async() => await HideAsync())" />
}
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Pagination/PaginationLink.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@if (Enum.IsDefined(typeof(IconName), LinkIcon) && LinkIcon != IconName.None)
{
<span aria-hidden="true">
<Icon Name="LinkIcon"/>
<Icon Name="LinkIcon" />
</span>
}
else
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/PdfViewer/PdfViewer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Tooltip Class="me-2" Title="Next Page" role="button">
<Icon Name="IconName.ChevronDown" Size="IconSize.x5" @onclick="NextPageAsync" />
</Tooltip>
<NumberInput Class="form-control-sm text-center" TValue="int" Style="width:60px;" Value="@pageNumber" ValueExpression="() => pageNumber" ValueChanged="(value) => PageNumberChangedAsync(value)" Placeholder="Enter page number" />
<NumberInput Class="form-control-sm text-center" TValue="int" style="width:60px;" Value="@pageNumber" ValueExpression="() => pageNumber" ValueChanged="(value) => PageNumberChangedAsync(value)" Placeholder="Enter page number" />
<div class="align-self-center ps-2">of @pagesCount</div>
</div>
<div class="d-flex align-items-center">
Expand Down
Loading

0 comments on commit 5267d6b

Please sign in to comment.