Add frontend creation game #13

Merged
Egamorf merged 5 commits from feature/frontend-creation-game into main 2025-04-13 17:21:15 +02:00
6 changed files with 32 additions and 20 deletions
Showing only changes of commit b8eed9b0d7 - Show all commits

View File

@@ -1,3 +1,4 @@
using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
@@ -9,6 +10,7 @@ namespace GameIdeas.BlazorApp.Pages.Games.Components;
public partial class GameCreationForm
{
[Inject] private IJSRuntime Js { get; set; } = default!;
[CascadingParameter] private Popup? Popup { get; set; }
private GameDto GameDto = new();
private EditContext? EditContext;
@@ -17,12 +19,16 @@ public partial class GameCreationForm
protected override void OnInitialized()
{
EditContext = new(GameDto);
if (Popup != null)
{
Popup.StateChanged += async (_, isOpen) => await HandlePopupStateChanged();
}
base.OnInitialized();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
private async Task HandlePopupStateChanged()
{
await Js.InvokeVoidAsync("addResizeGameFormListener");
await base.OnAfterRenderAsync(firstRender);
await Js.InvokeVoidAsync("resizeGameForm");
}
}

View File

@@ -35,6 +35,11 @@ input {
color: var(--white);
}
input[type="date"]::-webkit-calendar-picker-indicator {
filter: invert(1);
cursor: pointer;
}
.description-container {
margin-top: 8px;
display: grid;

View File

@@ -1,10 +1,5 @@
function resizeFormContent() {
window.resizeGameForm = () => {
const label = document.getElementById('first-label');
const targetLabel = document.getElementById('label-description');
targetLabel.style.width = window.getComputedStyle(label).getPropertyValue("width");
}
window.addResizeGameFormListener = () => {
resizeFormContent();
window.addEventListener('resize', resizeFormContent);
};

View File

@@ -1,15 +1,18 @@
@using GameIdeas.BlazorApp.Shared.Components.BackdropFilter
@using GameIdeas.BlazorApp.Shared.Constants
<div class="popup-wrapper" style="@GetDisplayStyle()">
<div class="popup-content">
@if (Closable)
{
<button @onclick="HandleBackdropFilterClicked">@Icons.Shared.Close</button>
}
@ChildContent
</div>
</div>
<CascadingValue Value="this">
<div class="popup-wrapper" style="@GetDisplayStyle()">
<div class="popup-content">
@if (Closable)
{
<button @onclick="HandleBackdropFilterClicked">@Icons.Shared.Close</button>
}
@ChildContent
</div>
</div>
</CascadingValue>
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="@Closable"
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />

View File

@@ -8,9 +8,10 @@ public partial class Popup
[Parameter] public bool IsDrawerOpen { get; set; }
[Parameter] public EventCallback BackdropFilterClicked { get; set; }
[Parameter] public bool Closable { get; set; } = true;
public bool IsOpen { get; set; }
public EventHandler<bool>? StateChanged { get; set; }
private BackdropFilter.BackdropFilter? BackdropFilter;
public bool IsOpen { get; set; }
protected override async Task OnParametersSetAsync()
{
@@ -30,6 +31,7 @@ public partial class Popup
{
IsOpen = true;
await BackdropFilter?.Show()!;
StateChanged?.Invoke(null, IsOpen);
StateHasChanged();
}
@@ -37,6 +39,7 @@ public partial class Popup
{
IsOpen = false;
await BackdropFilter?.Hide()!;
StateChanged?.Invoke(null, IsOpen);
StateHasChanged();
}

View File

@@ -29,7 +29,7 @@
width: 20px;
}
.popup-content button svg {
::deep .popup-content button svg {
height: 18px;
fill: var(--white);
}