-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): introduce the Select and Listbox components (#121)
* feat(listbox): add baseline implementation of ListBox and ListBoxItem components * feat(listbox): add `Color` and `Variant` params to Listbox and ListboxItem components * refactor(listbox): move Items list into the context * feat: add a new `transition-colors-shadow` transition * feat: defer content rendering to collect the items first * feat: allow single and multiple selection * feat: add start/end content parameters * feat: add `Description` param to the ListboxItem * feat: add Disabled state * feat: add OnClick callback on the ListboxItem component * chore: XML summaries * feat(docs): add baseline for the listbox component page * feat(popover): add `MatchRefWidth` parameter to the popover component * feat(popover): add 2-way-bindable `Opened` param to the popover component * feat(popover): make the `Id` a public param * feat(listbox-item): rename `Id` param to `Value` * chore(input): nits * feat(extensions): add baseline implementation of the Select component * refactor: allow binding to a single item or multiple items * feat: implement slots for the listbox and listbox item components * feat(docs): complete the listbox component page * feat(popover): add `MatchRefWidth` parameter to the popover component * feat(popover): add 2-way-bindable `Opened` param to the popover component * feat(popover): make the `Id` a public param * chore(input): nits * feat(extensions): add baseline implementation of the Select component * feat: add `TextValue` param to the SelectItem component * fix: styles * chore(listbox): nits * chore: improve rendering logic * feat(plugin): add 'scrollbar-hide' CSS utility * feat: implement slots * feat: add `ListboxMaxHeight` parameter * feat: add `DisabledItems` parameter * feat: add `ValueContent` parameter * chore: nits * chore: add missing XML docs * fix(listbox): apply CSS classes of an individual listbox item to its slots * feat: add `PopoverClasses` and `ListboxClasses` parameters * feat(docs): add the `New` component status badge * feat(docs): add the Select page * test(popover): fix broken tests * chore: exclude slots from code coverage; nits * refactor: move value(s) selection logic into the listbox component * test: add tests * feat(popover): add `MatchRefWidth` parameter to the popover component * feat(popover): add 2-way-bindable `Opened` param to the popover component * feat(popover): make the `Id` a public param * chore(input): nits * feat(extensions): add baseline implementation of the Select component * feat: add `TextValue` param to the SelectItem component * fix: styles * feat(popover): add `MatchRefWidth` parameter to the popover component * feat(popover): add 2-way-bindable `Opened` param to the popover component * feat(popover): make the `Id` a public param * feat(listbox-item): rename `Id` param to `Value` * feat(extensions): add baseline implementation of the Select component * chore(listbox): nits * chore: improve rendering logic * feat(plugin): add 'scrollbar-hide' CSS utility * feat: implement slots * feat: add `ListboxMaxHeight` parameter * feat: add `DisabledItems` parameter * feat: add `ValueContent` parameter * chore: add missing XML docs * fix(listbox): apply CSS classes of an individual listbox item to its slots * feat: add `PopoverClasses` and `ListboxClasses` parameters * feat(docs): add the `New` component status badge * feat(docs): add the Select page * test(popover): fix broken tests * chore: fix part of incorrectly merged code * docs(listbox): replace the "Selection" section with "Two-way Data Binding" * test: add tests * docs(listbox/select): nits
- Loading branch information
1 parent
be127f9
commit c1f620b
Showing
96 changed files
with
4,639 additions
and
47 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
...Docs.Client/Common/Enums/NavItemStatus.cs → ...cs.Client/Common/Enums/ComponentStatus.cs
This file contains 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 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 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 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 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
46 changes: 46 additions & 0 deletions
46
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/ColorsVariants.razor
This file contains 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,46 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string" Color="@_color" Variant="@_variant"> | ||
<LumexListboxItem>New file</LumexListboxItem> | ||
<LumexListboxItem>Edit file</LumexListboxItem> | ||
<LumexListboxItem>Share file</LumexListboxItem> | ||
<LumexListboxItem Color="@ThemeColor.Danger" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> | ||
|
||
<fieldset> | ||
<legend class="text-small text-default-500">Color</legend> | ||
<div class="flex flex-wrap gap-2"> | ||
<InputRadioGroup @bind-Value="@_color"> | ||
@foreach (var color in Enum.GetValues<ThemeColor>()) | ||
{ | ||
<label> | ||
<InputRadio Value="@color" /> | ||
@color | ||
</label> | ||
} | ||
</InputRadioGroup> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend class="text-small text-default-500">Variant</legend> | ||
<div class="flex flex-wrap gap-2"> | ||
<InputRadioGroup @bind-Value="@_variant"> | ||
@foreach (var variant in Enum.GetValues<ListboxVariant>()) | ||
{ | ||
<label> | ||
<InputRadio Value="@variant" /> | ||
@variant | ||
</label> | ||
} | ||
</InputRadioGroup> | ||
</div> | ||
</fieldset> | ||
|
||
@code { | ||
private ThemeColor _color = ThemeColor.Default; | ||
private ListboxVariant _variant = ListboxVariant.Solid; | ||
} |
83 changes: 83 additions & 0 deletions
83
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/CustomStyles.razor
This file contains 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,83 @@ | ||
<link href="https://unpkg.com/[email protected]/css/boxicons.min.css" rel="stylesheet"> | ||
|
||
<LumexListbox TValue="string" | ||
Variant="@ListboxVariant.Flat" | ||
Classes="@_classes" | ||
ItemClasses="@_itemClasses"> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("bug"), "bg-success/15 text-success-600"))" | ||
EndContent="@_counter(7)"> | ||
Issues | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("git-pull-request"), "bg-primary/15 text-primary"))" | ||
EndContent="@_counter(6)"> | ||
Pull Requests | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("conversation"), "bg-secondary/15 text-secondary"))" | ||
EndContent="@_counter(3)"> | ||
Discussions | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("play-circle"), "bg-warning/15 text-warning"))" | ||
EndContent="@_counter(2)"> | ||
Actions | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("layout"), "bg-default/30 text-foreground"))" | ||
EndContent="@_counter(1)"> | ||
Projects | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("purchase-tag"), "bg-primary/15 text-primary"))" | ||
EndContent="@_counter(12)" | ||
Class="h-auto"> | ||
<ChildContent> | ||
<div class="flex flex-col gap-1"> | ||
<span>Releases</span> | ||
<div class="px-2 py-1 rounded-small bg-default-100 ring-1 ring-default-200/30 ring-inset group-hover:bg-default-200/50"> | ||
<p class="text-tiny">v1.0.0-preview.4</p> | ||
<p class="text-tiny text-default-500"> | ||
3 months ago · <span class="text-success-600">Latest</span> | ||
</p> | ||
</div> | ||
</div> | ||
</ChildContent> | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("group"), "bg-orange-500/15 text-orange-500"))" | ||
EndContent="@_counter(2)"> | ||
Contributors | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("show"), "bg-warning/15 text-warning"))" | ||
EndContent="@_counter(3)"> | ||
Watchers | ||
</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_iconWrapper(new(_icon("certification"), "bg-danger/15 text-danger"))"> | ||
<ChildContent>License</ChildContent> | ||
<EndContent> | ||
<span class="text-small text-default-400">MIT</span> | ||
</EndContent> | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
|
||
@code { | ||
private RenderFragment<(RenderFragment ChildContent, string Class)> _iconWrapper = props => | ||
@<div class="flex items-center rounded-small justify-center w-7 h-7 @props.Class"> | ||
@props.ChildContent | ||
</div>; | ||
|
||
private RenderFragment<string> _icon = icon => | ||
@<LumexIcon Icon="@($"bx bx-{icon}")" Size="@new("18")" />; | ||
|
||
private RenderFragment<int> _counter = counter => | ||
@<div class="flex items-center gap-1 text-default-400"> | ||
<span class="text-small">@counter</span> | ||
<LumexIcon Icon="@Icons.Rounded.ChevronRight" Size="@new("20")" /> | ||
</div>; | ||
|
||
private ListboxSlots _classes = new() | ||
{ | ||
Root = "p-0 bg-surface1 max-w-72 shadow-small rounded-medium", | ||
List = "gap-0 divide-y divide-default-200/50" | ||
}; | ||
|
||
private ListboxItemSlots _itemClasses = new() | ||
{ | ||
Root = "px-3 first:rounded-t-medium last:rounded-b-medium rounded-none gap-3 h-12 hover:bg-default/15" | ||
}; | ||
} |
44 changes: 44 additions & 0 deletions
44
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/Description.razor
This file contains 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,44 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string" Variant="@ListboxVariant.Flat"> | ||
<LumexListboxItem Description="Create a new file" | ||
StartContent="@_newFile"> | ||
New file | ||
</LumexListboxItem> | ||
<LumexListboxItem Description="Edit the file" | ||
StartContent="@_editFile"> | ||
Edit file | ||
</LumexListboxItem> | ||
<LumexListboxItem Description="Share the file" | ||
StartContent="@_shareFile"> | ||
Share file | ||
</LumexListboxItem> | ||
<LumexListboxItem Description="Delete the file" | ||
Color="@ThemeColor.Danger" | ||
StartContent="@_deleteFile" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> | ||
|
||
@code { | ||
private RenderFragment _newFile = | ||
@<LumexIcon Icon="@Icons.Rounded.LibraryAdd" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _editFile = | ||
@<LumexIcon Icon="@Icons.Rounded.EditSquare" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _shareFile = | ||
@<LumexIcon Icon="@Icons.Rounded.Share" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _deleteFile = | ||
@<LumexIcon Icon="@Icons.Rounded.Delete" | ||
Size="@new("20")" | ||
Class="shrink-0" />; | ||
} |
11 changes: 11 additions & 0 deletions
11
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/Disabled.razor
This file contains 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,11 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string"> | ||
<LumexListboxItem>New file</LumexListboxItem> | ||
<LumexListboxItem Disabled="@true">Edit file</LumexListboxItem> | ||
<LumexListboxItem>Share file</LumexListboxItem> | ||
<LumexListboxItem Color="@ThemeColor.Danger" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/DisabledItems.razor
This file contains 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,12 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string" DisabledItems="@(["new", "delete"])"> | ||
<LumexListboxItem Value="@("new")">New file</LumexListboxItem> | ||
<LumexListboxItem Value="@("edit")">Edit file</LumexListboxItem> | ||
<LumexListboxItem Value="@("share")">Share file</LumexListboxItem> | ||
<LumexListboxItem Value="@("delete")" | ||
Color="@ThemeColor.Danger" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/EmptyContent.razor
This file contains 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,7 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string"> | ||
<EmptyContent> | ||
<span class="text-small">No items \(o_o)/</span> | ||
</EmptyContent> | ||
</LumexListbox> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/StartEndContent.razor
This file contains 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,34 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string" Variant="@ListboxVariant.Flat"> | ||
<LumexListboxItem StartContent="@_newFile">New file</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_editFile">Edit file</LumexListboxItem> | ||
<LumexListboxItem StartContent="@_shareFile">Share file</LumexListboxItem> | ||
<LumexListboxItem Color="@ThemeColor.Danger" | ||
StartContent="@_deleteFile" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> | ||
|
||
@code { | ||
private RenderFragment _newFile = | ||
@<LumexIcon Icon="@Icons.Rounded.LibraryAdd" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _editFile = | ||
@<LumexIcon Icon="@Icons.Rounded.EditSquare" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _shareFile = | ||
@<LumexIcon Icon="@Icons.Rounded.Share" | ||
Size="@new("20")" | ||
Class="text-default-500 shrink-0" />; | ||
|
||
private RenderFragment _deleteFile = | ||
@<LumexIcon Icon="@Icons.Rounded.Delete" | ||
Size="@new("20")" | ||
Class="shrink-0" />; | ||
} |
17 changes: 17 additions & 0 deletions
17
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/TwoWayDataBindingMultiple.razor
This file contains 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,17 @@ | ||
<div class="w-full flex flex-col gap-2"> | ||
<div class="max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox @bind-Values="@_selectedValues"> | ||
<LumexListboxItem Value="@("cat")">Cat</LumexListboxItem> | ||
<LumexListboxItem Value="@("dog")">Dog</LumexListboxItem> | ||
<LumexListboxItem Value="@("elephant")">Elephant</LumexListboxItem> | ||
<LumexListboxItem Value="@("lion")">Lion</LumexListboxItem> | ||
</LumexListbox> | ||
</div> | ||
<p class="text-small text-default-500"> | ||
Selected values: @(string.Join(", ", _selectedValues)) | ||
</p> | ||
</div> | ||
|
||
@code { | ||
private ICollection<string> _selectedValues = ["cat"]; | ||
} |
17 changes: 17 additions & 0 deletions
17
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/TwoWayDataBindingSingle.razor
This file contains 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,17 @@ | ||
<div class="w-full flex flex-col gap-2"> | ||
<div class="max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox @bind-Value="@_selectedValue"> | ||
<LumexListboxItem Value="@("cat")">Cat</LumexListboxItem> | ||
<LumexListboxItem Value="@("dog")">Dog</LumexListboxItem> | ||
<LumexListboxItem Value="@("elephant")">Elephant</LumexListboxItem> | ||
<LumexListboxItem Value="@("lion")">Lion</LumexListboxItem> | ||
</LumexListbox> | ||
</div> | ||
<p class="text-small text-default-500"> | ||
Selected value: @_selectedValue | ||
</p> | ||
</div> | ||
|
||
@code { | ||
private string _selectedValue = "cat"; | ||
} |
11 changes: 11 additions & 0 deletions
11
docs/LumexUI.Docs.Client/Pages/Components/Listbox/Examples/Usage.razor
This file contains 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,11 @@ | ||
<div class="w-full max-w-60 px-1 py-2 border border-default-200 rounded-small"> | ||
<LumexListbox TValue="string"> | ||
<LumexListboxItem>New file</LumexListboxItem> | ||
<LumexListboxItem>Edit file</LumexListboxItem> | ||
<LumexListboxItem>Share file</LumexListboxItem> | ||
<LumexListboxItem Color="@ThemeColor.Danger" | ||
Class="text-danger"> | ||
Delete file | ||
</LumexListboxItem> | ||
</LumexListbox> | ||
</div> |
Oops, something went wrong.