Adds custom comboboz razor component
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Lumina.Presentation.Web.Common.Models.UI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an item in a combobox.
|
||||||
|
/// </summary>
|
||||||
|
public class ComboboxItem
|
||||||
|
{
|
||||||
|
#region ==================================================================== PROPERTIES =================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the text of the item, that is visible to the user.
|
||||||
|
/// </summary>
|
||||||
|
public string? Text { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value of the item, that is used by the application.
|
||||||
|
/// </summary>
|
||||||
|
public string? Value { get; set; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
@using Lumina.Presentation.Web.Common.Models.UI
|
||||||
|
@using Lumina.Presentation.Web.Core.Services.UI
|
||||||
|
|
||||||
|
@inject ComboboxService _comboboxService
|
||||||
|
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
|
<div class="enlightenment-combobox inline-block w-100 @(IsOpen ? "open" : string.Empty)">
|
||||||
|
<div class="shine-effect"></div>
|
||||||
|
<input type="checkbox" class="enlightenment-toggle-checkbox" @bind="IsOpen" id="@Id" @onclick="ToggleDropdown">
|
||||||
|
<label class="enlightenment-toggle" for="@Id">
|
||||||
|
<span class="enlightenment-selected-text">@(SelectedItem?.Text ?? "No item selected")</span>
|
||||||
|
</label>
|
||||||
|
<div class="enlightenment-dropdown">
|
||||||
|
<div class="shine-effect"></div>
|
||||||
|
<div class="enlightenment-item first-item disabled" @onclick="() => SelectItem(null)">No item selected</div>
|
||||||
|
|
||||||
|
@for (int i = 0; i < Items.Count; i++)
|
||||||
|
{
|
||||||
|
var item = Items[i];
|
||||||
|
var cssClass = $"enlightenment-item {(i == Items.Count - 1 ? "last-item" : string.Empty)}";
|
||||||
|
<div class="@cssClass" @onclick="() => SelectItem(item)">@item.Text</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public List<ComboboxItem> Items { get; set; } = [];
|
||||||
|
[Parameter] public ComboboxItem? SelectedItem { get; set; }
|
||||||
|
[Parameter] public EventCallback<ComboboxItem> SelectedItemChanged { get; set; }
|
||||||
|
|
||||||
|
private bool IsOpen { get; set; }
|
||||||
|
private string Id { get; set; } = $"combobox_{Guid.NewGuid()}";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the component.
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
_comboboxService.ComboboxOpened += CloseIfNotThis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles the dropdown state.
|
||||||
|
/// </summary>
|
||||||
|
private void ToggleDropdown()
|
||||||
|
{
|
||||||
|
IsOpen = !IsOpen;
|
||||||
|
if (IsOpen)
|
||||||
|
_comboboxService.NotifyComboboxOpened(Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the dropdown if the provided <paramref name="openedId"/> is not the current <see cref="Id"/>, or if it's <see langword="null"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="openedId">The optional id of the combobox that initiated the dropdown state change.</param>
|
||||||
|
private void CloseIfNotThis(string? openedId)
|
||||||
|
{
|
||||||
|
if (openedId != Id && IsOpen)
|
||||||
|
{
|
||||||
|
IsOpen = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selects the provided <paramref name="item"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to select.</param>
|
||||||
|
private async Task SelectItem(ComboboxItem? item)
|
||||||
|
{
|
||||||
|
SelectedItem = item;
|
||||||
|
IsOpen = false;
|
||||||
|
await SelectedItemChanged.InvokeAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes the component.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_comboboxService.ComboboxOpened -= CloseIfNotThis;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
.enlightenment-combobox {
|
||||||
|
position: relative;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-toggle-checkbox {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
|
||||||
|
color: #6DCBFE;
|
||||||
|
padding: 3px 24px 3px 18px;
|
||||||
|
width: 100%;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
appearance: none;
|
||||||
|
border-top: #989898 1px solid;
|
||||||
|
border-bottom: #151515 1px solid;
|
||||||
|
border-left: #878787 1px solid;
|
||||||
|
border-right: #202020 1px solid;
|
||||||
|
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141);
|
||||||
|
background-repeat: no-repeat, no-repeat, repeat;
|
||||||
|
background-position: right 10px top 50%, left 7px top 50%, 0 0;
|
||||||
|
background-size: 12px 6px, 3px auto, 100%;
|
||||||
|
user-select: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-toggle:hover {
|
||||||
|
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_lit_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141);
|
||||||
|
background-repeat: no-repeat, no-repeat, repeat;
|
||||||
|
background-position: right 10px top 50%, left 7px top 50%, 0 0;
|
||||||
|
background-size: 12px 6px, 3px auto, 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-selected-text {
|
||||||
|
flex: 1;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-dropdown {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-image: url('../images/ui/metal-plate.png'), linear-gradient(180deg, #505050, #464646, #404040, #363636);
|
||||||
|
background-repeat: repeat, no-repeat;
|
||||||
|
background-position: 3px 3px, 0 0; /* offset the metal-plate image by 3 pixels from the top and left */
|
||||||
|
background-clip: content-box, border-box; /* clip the metal-plate image to the content box */
|
||||||
|
border-top: #989898 1px solid;
|
||||||
|
border-bottom: #151515 1px solid;
|
||||||
|
border-left: #878787 1px solid;
|
||||||
|
border-right: #202020 1px solid;
|
||||||
|
padding: 3px;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-dropdown > .shine-effect:first-child {
|
||||||
|
top: -4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-item {
|
||||||
|
display: block;
|
||||||
|
border-left: 1px solid #232323;
|
||||||
|
border-right: 1px solid #777777;
|
||||||
|
border-top: 1px solid #232323;
|
||||||
|
border-bottom: 1px solid #777777;
|
||||||
|
color: #FFFFFF;
|
||||||
|
padding: 5px 10px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
user-select: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-item.first-item {
|
||||||
|
border-top: 1px solid #232323;
|
||||||
|
margin-top: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-item.last-item {
|
||||||
|
border-bottom: 1px solid #777777;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-item.disabled {
|
||||||
|
color: #AAAAAA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-item:hover {
|
||||||
|
background-image: none;
|
||||||
|
background: linear-gradient(to bottom, #505050, #464646, #404040, #363636);
|
||||||
|
color: #1D8AF9;
|
||||||
|
box-shadow: inset 1px 0 0 0 #777777, inset -1px 0 0 0 #232323, inset 0 1px 0 0 #989898, inset 0 -1px 0 0 #151515;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox.open .enlightenment-dropdown {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox > .shine-effect:first-child {
|
||||||
|
top: 1px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox:hover > .shine-effect:first-child {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox > .shine-effect::before,
|
||||||
|
.enlightenment-combobox > .shine-effect::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -1px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox > .shine-effect::before {
|
||||||
|
width: 3px;
|
||||||
|
height: 2px;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox > .shine-effect::after {
|
||||||
|
width: 10px;
|
||||||
|
height: 3px;
|
||||||
|
border-radius: 5px 5px 0 0;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
filter: blur(3px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.enlightenment-combobox:hover > .shine-effect::before,
|
||||||
|
.enlightenment-combobox:hover > .shine-effect::after {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace Lumina.Presentation.Web.Core.Services.UI;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for managing comboboxes.
|
||||||
|
/// </summary>
|
||||||
|
public class ComboboxService
|
||||||
|
{
|
||||||
|
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||||
|
public event Action<string>? ComboboxOpened;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ===================================================================== METHODS ===================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies that a combobox has been opened.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The id of the combobox that opened.</param>
|
||||||
|
public void NotifyComboboxOpened(string id)
|
||||||
|
{
|
||||||
|
ComboboxOpened?.Invoke(id);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -18,9 +18,4 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.7" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.7" PrivateAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="wwwroot\common\images\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Core.Services.UI;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -20,6 +21,7 @@ public class Program
|
|||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
builder.RootComponents.Add<App>("#app");
|
builder.RootComponents.Add<App>("#app");
|
||||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||||
|
builder.Services.AddSingleton<ComboboxService>();
|
||||||
|
|
||||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 131 B |
|
After Width: | Height: | Size: 494 B |
|
After Width: | Height: | Size: 492 B |
|
After Width: | Height: | Size: 457 B |
|
After Width: | Height: | Size: 461 B |
|
After Width: | Height: | Size: 481 B |
|
After Width: | Height: | Size: 476 B |
|
After Width: | Height: | Size: 505 B |
|
After Width: | Height: | Size: 501 B |
|
After Width: | Height: | Size: 856 B |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 937 B |
|
After Width: | Height: | Size: 826 B |
|
After Width: | Height: | Size: 866 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |