refactoring select list

This commit is contained in:
2025-03-02 17:55:17 +01:00
parent 713378ef9c
commit ce0c43b48a
6 changed files with 55 additions and 41 deletions

View File

@@ -11,12 +11,17 @@
} }
/***** Navigation Theme *****/ /***** Navigation Theme *****/
.navigation {
padding: 4px 8px;
width: 100%;
}
.navigation .selected { .navigation .selected {
display: none; display: none;
} }
.navigation .select-label:hover { .navigation:hover {
color: var(--light-grey); background: var(--violet-selected);
} }
/***** Sort Theme *****/ /***** Sort Theme *****/

View File

@@ -5,9 +5,13 @@
<div class="select-button"> <div class="select-button">
@Button @Button
</div> </div>
<div @ref=Container class="select-container" tabindex="1000" <div @ref=Container @onfocusout=HandleFocusOut
@onfocusout=HandleFocusOut> class="select-container @(AlignRight ? "align-right" : "")"
<div class="select-content @(ContentVisile ? string.Empty : "invisible") @(Enum.GetName(Theme)?.ToLower())"> tabindex="1000">
@if (ContentVisile)
{
<div class="select-content @(Enum.GetName(Theme)?.ToLower())">
@foreach (var item in Headers) @foreach (var item in Headers)
{ {
<SelectListElement TItem="TItem" <SelectListElement TItem="TItem"
@@ -27,6 +31,7 @@
Theme="Theme" /> Theme="Theme" />
} }
</div> </div>
}
</div> </div>
</div> </div>

View File

@@ -47,7 +47,6 @@ public partial class SelectList<TItem>
selectedValue.IsSelected = true; selectedValue.IsSelected = true;
Value = selectedValue.Item; Value = selectedValue.Item;
await ValueChanged.InvokeAsync(Value); await ValueChanged.InvokeAsync(Value);
Close();
} }
private async Task HandleHeaderClicked(SelectElement<TItem> selectedValue) private async Task HandleHeaderClicked(SelectElement<TItem> selectedValue)

View File

@@ -1,16 +1,23 @@
.select-content { .select-list {
position: relative;
}
.select-container {
margin-top: 4px;
position: absolute;
}
.align-right {
right: 0;
}
.select-content {
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: var(--small-radius); border-radius: var(--small-radius);
position: fixed;
animation-name: fade-in; animation-name: fade-in;
animation-duration: 0.4s; animation-duration: 0.4s;
margin-top: 4px;
}
.invisible {
display: none;
} }
.line { .line {
@@ -18,19 +25,16 @@
border-bottom: 2px solid var(--light-grey); border-bottom: 2px solid var(--light-grey);
} }
/***** Navigation Theme *****/ /***** Navigation Theme *****/
.select-content.navigation { .select-content.navigation {
gap: 4px;
background: var(--violet); background: var(--violet);
box-shadow: var(--drop-shadow); box-shadow: var(--drop-shadow);
padding: 4px 6px;
} }
/***** Sort Theme *****/ /***** Sort Theme *****/
.select-content.sort { .select-content.sort {
gap: 4px;
background: var(--black); background: var(--black);
box-shadow: var(--drop-shadow); box-shadow: var(--drop-shadow);
padding: 4px 6px;
} }

View File

@@ -24,7 +24,8 @@
<SelectList TItem="AddType" <SelectList TItem="AddType"
Items="SelectElements" Items="SelectElements"
ValueChanged=HandleAddTypeClickedAsync ValueChanged=HandleAddTypeClickedAsync
Theme="SelectListTheme.Navigation"> Theme="SelectListTheme.Navigation"
AlignRight=true>
<Button> <Button>
<div class="second-button button"> <div class="second-button button">
<svg class="button-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <svg class="button-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">

View File

@@ -42,7 +42,7 @@
flex-direction: row; flex-direction: row;
background: var(--violet); background: var(--violet);
border-radius: var(--small-radius); border-radius: var(--small-radius);
overflow: hidden; overflow: visible;
} }
.button { .button {