Skip to content

Commit

Permalink
IconSize is wrong when generated by a button #347 (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvreddy04 authored Oct 1, 2023
1 parent a074849 commit 8f31429
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<div>Fancy larger or smaller buttons? Add <code>Size="Size.Large"</code> or <code>Size="Size.Small"</code> for additional sizes.</div>
<Demo Type="typeof(Button_Demo_04_Sizes_A)" />
<Demo Type="typeof(Button_Demo_04_Sizes_B)" />
<Demo Type="typeof(Button_Demo_04_Sizes_C)" />

<SectionHeading Size="HeadingSize.H2" Text="Disabled state" PageUrl="@pageUrl" HashTagName="disabled-state" />
<div>Make buttons look inactive by adding the <code>Disabled="true"</code> boolean parameter to any <code>Button</code> component. Disabled buttons have <code>pointer-events: none</code> applied to, preventing hover and active states from triggering.</div>
Expand Down Expand Up @@ -56,7 +57,7 @@
<Demo Type="typeof(Button_Demo_08_Loading_Spinner)" />

<SectionHeading Size="HeadingSize.H2" Text="Show/Hide loading spinner" PageUrl="@pageUrl" HashTagName="show-hide-loading-spinner" />
<Demo Type="typeof(Button_Demo_08_Show_Hide_Loading_Spinner)" />
<Demo Type="typeof(Button_Demo_08_Show_Hide_Loading_Spinner)" Tabs="true" />

<SectionHeading Size="HeadingSize.H2" Text="Show Tooltip" PageUrl="@pageUrl" HashTagName="show-tooltip" />
<div class="mb-3">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Button Color="ButtonColor.Primary" Size="Size.ExtraLarge"> Extra large button </Button>
<Button Color="ButtonColor.Secondary" Size="Size.Large"> Large button </Button>
<Button Color="ButtonColor.Success" Size="Size.Medium"> Medium button </Button>
<Button Color="ButtonColor.Danger" Size="Size.Small"> Small button </Button>
<Button Color="ButtonColor.Warning" Size="Size.ExtraSmall"> Extra small button </Button>
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
<Button @ref="saveButton" Color="ButtonColor.Primary" @onclick="async () => await OnSaveClick()">Save</Button>

<Button @ref="saveButton1" Color="ButtonColor.Primary" Size="Size.ExtraLarge" @onclick="OnSave1Click">
<Icon Name="IconName.Activity"></Icon>
</Button>
<Button @ref="saveButton2" Color="ButtonColor.Primary" Size="Size.Large" @onclick="OnSave2Click">
<Icon Name="IconName.Activity"></Icon>
</Button>
<Button @ref="saveButton3" Color="ButtonColor.Primary" Size="Size.Medium" @onclick="OnSave3Click">
<Icon Name="IconName.Activity"></Icon>
</Button>
<Button @ref="saveButton4" Color="ButtonColor.Primary" Size="Size.Small" @onclick="OnSave4Click">
<Icon Name="IconName.Activity"></Icon>
</Button>
<Button @ref="saveButton5" Color="ButtonColor.Primary" Size="Size.ExtraSmall" @onclick="OnSave5Click">
<Icon Name="IconName.Activity"></Icon>
</Button>
@code {
private Button saveButton;
private Button saveButton1, saveButton2, saveButton3, saveButton4, saveButton5;

private async Task OnSave1Click()
{
saveButton1?.ShowLoading("Loading...");

await Task.Delay(3000); // API call
saveButton1?.HideLoading();
}

private async Task OnSave2Click()
{
saveButton2?.ShowLoading("Loading...");

await Task.Delay(3000); // API call
saveButton2?.HideLoading();
}

private async Task OnSave3Click()
{
saveButton3?.ShowLoading("Loading...");

await Task.Delay(3000); // API call
saveButton3?.HideLoading();
}

private async Task OnSave4Click()
{
saveButton4?.ShowLoading("Loading...");

await Task.Delay(3000); // API call
saveButton4?.HideLoading();
}

private async Task OnSaveClick()
private async Task OnSave5Click()
{
saveButton?.ShowLoading("Saving details...");
saveButton5?.ShowLoading("Loading...");

await Task.Delay(5000); // API call
await Task.Delay(3000); // API call
saveButton?.HideLoading();
saveButton5?.HideLoading();
}
}
}
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Button/Button.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void ShowLoading(string text = "")
StateHasChanged();
}

protected virtual RenderFragment ProvideDefaultLoadingTemplate() => builder => { builder.AddMarkupContent(0, $"<span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span> {loadingText}"); };
protected virtual RenderFragment ProvideDefaultLoadingTemplate() => builder => { builder.AddMarkupContent(0, $"<span class=\"spinner-border spinner-border-{BootstrapClassProvider.ToSize(Size == Size.None ? Size.Medium : Size)}\" role=\"status\" aria-hidden=\"true\"></span> {loadingText}"); };

private void SetAttributes()
{
Expand Down
74 changes: 74 additions & 0 deletions blazorbootstrap/wwwroot/blazor.bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
--bb-tooltip-dark: var(--bs-dark);
--bb-tooltip-color-white: var(--bs-white);
--bb-tooltip-color-dark: var(--bs-black);
/* border */
--bs-border-radius-xs: 0.125rem;
--bs-border-radius-md: 0.375rem;
}

/* preload */
Expand Down Expand Up @@ -383,3 +386,74 @@ main {
--bs-tooltip-bg: var(--bb-tooltip-dark);
--bs-tooltip-color: var(--bb-tooltip-color-white);
}

/* button */
.btn-xs {
--bs-btn-padding-y: 0.125rem;
--bs-btn-padding-x: 0.25rem;
--bs-btn-font-size: 0.75rem;
--bs-btn-border-radius: var(--bs-border-radius-sm);
}

.btn-sm {
--bs-btn-padding-y: 0.25rem;
--bs-btn-padding-x: 0.5rem;
--bs-btn-font-size: 0.875rem;
--bs-btn-border-radius: var(--bs-border-radius-sm);
}

.btn-md {
--bs-btn-padding-y: 0.375rem;
--bs-btn-padding-x: 0.75rem;
--bs-btn-font-size: 1rem;
--bs-btn-border-radius: var(--bs-border-radius-md);
}

.btn-lg {
--bs-btn-padding-y: 0.5rem;
--bs-btn-padding-x: 1rem;
--bs-btn-font-size: 1.25rem;
--bs-btn-border-radius: var(--bs-border-radius-lg);
}
.btn-xl {
--bs-btn-padding-y: 0.625rem;
--bs-btn-padding-x: 1.25rem;
--bs-btn-font-size: 1.5rem;
--bs-btn-border-radius: var(--bs-border-radius-lg);
}

/* button > spinner */
.spinner-border-xs {
--bs-spinner-width: 0.5rem;
--bs-spinner-height: 0.5rem;
--bs-spinner-border-width: 0.125em;
--bs-spinner-vertical-align: 0;
}

.spinner-border-sm {
--bs-spinner-width: 0.75rem;
--bs-spinner-height: 0.75rem;
--bs-spinner-border-width: 0.15em;
--bs-spinner-vertical-align: 0;
}

.spinner-border-md {
--bs-spinner-width: 1rem;
--bs-spinner-height: 1rem;
--bs-spinner-border-width: 0.175em;
--bs-spinner-vertical-align: -0.125em;
}

.spinner-border-lg {
--bs-spinner-width: 1.25rem;
--bs-spinner-height: 1.25rem;
--bs-spinner-border-width: 0.2em;
--bs-spinner-vertical-align: -0.125em;
}

.spinner-border-xl {
--bs-spinner-width: 1.5rem;
--bs-spinner-height: 1.5rem;
--bs-spinner-border-width: 0.225em;
--bs-spinner-vertical-align: -0.125em;
}

0 comments on commit 8f31429

Please sign in to comment.