-
-
Notifications
You must be signed in to change notification settings - Fork 26
feat(components): introduce Spinner component #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a2d216
feat(spinner): add baseline implementation
desmondinho 8442bf9
feat(spinner): add variants and styles
desmondinho 8b8ce3b
feat(spinner): add slots
desmondinho fff4b7c
docs(spinner): add Spinner page
desmondinho 85d6d69
docs: nits
desmondinho 66e94a1
test(spinner): add tests
desmondinho 9c12bcc
docs: map static assets
desmondinho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Examples/Colors.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <div class="flex gap-8"> | ||
| <LumexSpinner Label="Default" LabelColor="@ThemeColor.Default" Color="@ThemeColor.Default" /> | ||
| <LumexSpinner Label="Primary" LabelColor="@ThemeColor.Primary" Color="@ThemeColor.Primary" /> | ||
| <LumexSpinner Label="Secondary" LabelColor="@ThemeColor.Secondary" Color="@ThemeColor.Secondary" /> | ||
| <LumexSpinner Label="Success" LabelColor="@ThemeColor.Success" Color="@ThemeColor.Success" /> | ||
| <LumexSpinner Label="Warning" LabelColor="@ThemeColor.Warning" Color="@ThemeColor.Warning" /> | ||
| <LumexSpinner Label="Danger" LabelColor="@ThemeColor.Danger" Color="@ThemeColor.Danger" /> | ||
| <LumexSpinner Label="Info" LabelColor="@ThemeColor.Info" Color="@ThemeColor.Info" /> | ||
| </div> |
1 change: 1 addition & 0 deletions
1
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Examples/Label.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <LumexSpinner Label="Loading..." /> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Examples/Sizes.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <div class="flex gap-4"> | ||
| <LumexSpinner Size="@Size.Small" /> | ||
| <LumexSpinner Size="@Size.Medium" /> | ||
| <LumexSpinner Size="@Size.Large" /> | ||
| </div> |
1 change: 1 addition & 0 deletions
1
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Examples/Usage.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <LumexSpinner /> |
8 changes: 8 additions & 0 deletions
8
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Examples/Variants.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <div class="flex gap-8"> | ||
| <LumexSpinner Variant="@SpinnerVariant.Ring" Label="Ring" /> | ||
| <LumexSpinner Variant="@SpinnerVariant.Arc" Label="Arc" /> | ||
| <LumexSpinner Variant="@SpinnerVariant.ArcGradient" Label="Arc Gradient" /> | ||
| <LumexSpinner Variant="@SpinnerVariant.DotsWave" Label="Dots Wave" /> | ||
| <LumexSpinner Variant="@SpinnerVariant.DotsFade" Label="Dots Fade" /> | ||
| <LumexSpinner Variant="@SpinnerVariant.Classic" Label="Classic" /> | ||
| </div> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/PreviewCodes/Colors.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @rendermode InteractiveWebAssembly | ||
|
|
||
| <PreviewCode Code="@new(name: null, snippet: "Spinner.Code.Colors")"> | ||
| <LumexUI.Docs.Client.Pages.Components.Spinner.Examples.Colors /> | ||
| </PreviewCode> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/PreviewCodes/Label.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @rendermode InteractiveWebAssembly | ||
|
|
||
| <PreviewCode Code="@new(name: null, snippet: "Spinner.Code.Label")"> | ||
| <LumexUI.Docs.Client.Pages.Components.Spinner.Examples.Label /> | ||
| </PreviewCode> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/PreviewCodes/Sizes.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @rendermode InteractiveWebAssembly | ||
|
|
||
| <PreviewCode Code="@new(name: null, snippet: "Spinner.Code.Sizes")"> | ||
| <LumexUI.Docs.Client.Pages.Components.Spinner.Examples.Sizes /> | ||
| </PreviewCode> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/PreviewCodes/Usage.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @rendermode InteractiveWebAssembly | ||
|
|
||
| <PreviewCode Code="@new(name: null, snippet: "Spinner.Code.Usage")"> | ||
| <LumexUI.Docs.Client.Pages.Components.Spinner.Examples.Usage /> | ||
| </PreviewCode> |
5 changes: 5 additions & 0 deletions
5
docs/LumexUI.Docs.Client/Pages/Components/Spinner/PreviewCodes/Variants.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @rendermode InteractiveWebAssembly | ||
|
|
||
| <PreviewCode Code="@new(name: null, snippet: "Spinner.Code.Variants")"> | ||
| <LumexUI.Docs.Client.Pages.Components.Spinner.Examples.Variants /> | ||
| </PreviewCode> |
87 changes: 87 additions & 0 deletions
87
docs/LumexUI.Docs.Client/Pages/Components/Spinner/Spinner.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| @page "/docs/components/spinner" | ||
| @layout DocsContentLayout | ||
|
|
||
| @using LumexUI.Docs.Client.Pages.Components.Spinner.PreviewCodes | ||
|
|
||
| <DocsSection Title="Usage"> | ||
| <p> | ||
| The spinner component provides a visual loading indicator, | ||
| commonly used to show ongoing processes. | ||
| </p> | ||
| <Usage /> | ||
|
|
||
| <DocsSection Title="Label"> | ||
| <p>Add a label to the spinner to provide context about what is loading.</p> | ||
| <Label /> | ||
| </DocsSection> | ||
|
|
||
| <DocsSection Title="Sizes"> | ||
| <p>Adjust the size of the spinner.</p> | ||
| <Sizes /> | ||
| </DocsSection> | ||
|
|
||
| <DocsSection Title="Colors"> | ||
| <p>Customize the spinner color.</p> | ||
| <Colors /> | ||
| </DocsSection> | ||
|
|
||
| <DocsSection Title="Variants"> | ||
| <p>Choose different spinner styles.</p> | ||
| <Variants /> | ||
| </DocsSection> | ||
| </DocsSection> | ||
|
|
||
| <DocsSlotsSection Slots="@_slots"> | ||
| <div> | ||
| <h4 class="font-semibold">Spinner</h4> | ||
| <ul> | ||
| <li><Code>Class</Code>: The CSS class names to style the wrapper.</li> | ||
| <li><Code>Classes</Code>: The CSS class names to style the slots.</li> | ||
| </ul> | ||
| </div> | ||
| </DocsSlotsSection> | ||
|
|
||
| <DocsApiSection Components="@_apiComponents" /> | ||
|
|
||
| @code { | ||
| [CascadingParameter] private DocsContentLayout Layout { get; set; } = default!; | ||
|
|
||
| private readonly Heading[] _headings = new Heading[] | ||
| { | ||
| new("Usage", [ | ||
| new("Label"), | ||
| new("Sizes"), | ||
| new("Colors"), | ||
| new("Variants") | ||
| ]), | ||
| new("Custom Styles"), | ||
| new("API") | ||
| }; | ||
|
|
||
| private readonly Slot[] _slots = new Slot[] | ||
| { | ||
| new(nameof(SpinnerSlots.Base), "The main container for the spinner component."), | ||
| new(nameof(SpinnerSlots.Wrapper), "The wrapper of the circles."), | ||
| new(nameof(SpinnerSlots.Label), "The label associated with the spinner."), | ||
| new(nameof(SpinnerSlots.Circle1), "The first animated circle in circular spinner variants."), | ||
| new(nameof(SpinnerSlots.Circle2), "The second animated circle in circular spinner variants."), | ||
| new(nameof(SpinnerSlots.Dots), "A set of animated dots used in dot-based spinner variants."), | ||
| new(nameof(SpinnerSlots.Bars), "A set of animated bars used in bar-based spinner variants."), | ||
| }; | ||
|
|
||
| private readonly string[] _apiComponents = new string[] | ||
| { | ||
| nameof(LumexSpinner) | ||
| }; | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| Layout.Initialize( | ||
| title: "Spinner", | ||
| category: "Components", | ||
| description: "Spinners indicate loading states with a visual cue.", | ||
| headings: _headings, | ||
| linksProps: new ComponentLinksProps( "Spinner", isServer: true ) | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright (c) LumexUI 2024 | ||
| // LumexUI licenses this file to you under the MIT license | ||
| // See the license here https://github.com/LumexUI/lumexui/blob/main/LICENSE | ||
|
|
||
| namespace LumexUI.Common; | ||
|
|
||
| /// <summary> | ||
| /// Specifies the visual variants for the <see cref="LumexSpinner"/>. | ||
| /// </summary> | ||
| public enum SpinnerVariant | ||
| { | ||
| Ring, | ||
|
|
||
| Arc, | ||
|
|
||
| ArcGradient, | ||
|
|
||
| DotsWave, | ||
|
|
||
| DotsFade, | ||
|
|
||
| Classic | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| @namespace LumexUI | ||
| @inherits LumexComponentBase | ||
|
|
||
| @using S = SpinnerSlots; | ||
|
|
||
| @if( Variant is SpinnerVariant.DotsWave or SpinnerVariant.DotsFade ) | ||
| { | ||
| <div class="@GetStyles(nameof(S.Base))" | ||
| style="@Style" | ||
| data-slot="base" | ||
| aria-label="@AriaLabel" | ||
| @attributes="@AdditionalAttributes"> | ||
| <div class="@GetStyles(nameof(S.Wrapper))" data-slot="wrapper"> | ||
| @foreach( var index in Enumerable.Range( 0, 3 ) ) | ||
| { | ||
| <span class="@GetStyles(nameof(S.Dots))" | ||
| style="--index: @index" | ||
| data-slot="dots" /> | ||
| } | ||
| </div> | ||
|
|
||
| @_renderLabel | ||
| </div> | ||
| } | ||
| else if( Variant is SpinnerVariant.Ring ) | ||
| { | ||
| <div class="@GetStyles(nameof(S.Base))" | ||
| style="@Style" | ||
| data-slot="base" | ||
| aria-label="@AriaLabel" | ||
| @attributes="@AdditionalAttributes"> | ||
| <svg class="@GetStyles(nameof(S.Wrapper))" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| data-slot="wrapper"> | ||
| <circle class="@GetStyles(nameof(S.Circle1))" | ||
| cx="12" | ||
| cy="12" | ||
| r="10" | ||
| stroke="currentColor" | ||
| stroke-width="4" | ||
| data-slot="circle1" /> | ||
| <path class="@GetStyles(nameof(S.Circle2))" | ||
| d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" | ||
| fill="currentColor" | ||
| data-slot="circle2" /> | ||
| </svg> | ||
|
|
||
| @_renderLabel | ||
| </div> | ||
| } | ||
| else if( Variant is SpinnerVariant.Classic ) | ||
| { | ||
| <div class="@GetStyles(nameof(S.Base))" | ||
| style="@Style" | ||
| data-slot="base" | ||
| aria-label="@AriaLabel" | ||
| @attributes="@AdditionalAttributes"> | ||
| <div class="@GetStyles(nameof(S.Wrapper))" data-slot="wrapper"> | ||
| @foreach( var index in Enumerable.Range( 0, 12 ) ) | ||
| { | ||
| <span class="@GetStyles(nameof(S.Bars))" | ||
| style="--index: @index" | ||
| data-slot="bars" /> | ||
| } | ||
| </div> | ||
|
|
||
| @_renderLabel | ||
| </div> | ||
| } | ||
| else | ||
| { | ||
| <div class="@GetStyles(nameof(S.Base))" | ||
| style="@Style" | ||
| data-slot="base" | ||
| aria-label="@AriaLabel" | ||
| @attributes="@AdditionalAttributes"> | ||
| <div class="@GetStyles(nameof(S.Wrapper))" data-slot="wrapper"> | ||
| <span class="@GetStyles(nameof(S.Circle1))" data-slot="circle1" /> | ||
| <span class="@GetStyles(nameof(S.Circle2))" data-slot="circle2" /> | ||
| </div> | ||
|
|
||
| @_renderLabel | ||
| </div> | ||
| } | ||
|
|
||
| @code { | ||
| private void RenderLabel( RenderTreeBuilder __builder ) | ||
| { | ||
| if( string.IsNullOrEmpty( Label ) && ChildContent is null ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| <span class="@GetStyles(nameof(S.Label))" data-slot="label"> | ||
| @(string.IsNullOrEmpty( Label ) ? ChildContent : Label) | ||
| </span> | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.