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

View File

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

View File

@@ -1,10 +1,5 @@
function resizeFormContent() { window.resizeGameForm = () => {
const label = document.getElementById('first-label'); const label = document.getElementById('first-label');
const targetLabel = document.getElementById('label-description'); const targetLabel = document.getElementById('label-description');
targetLabel.style.width = window.getComputedStyle(label).getPropertyValue("width"); 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.Components.BackdropFilter
@using GameIdeas.BlazorApp.Shared.Constants @using GameIdeas.BlazorApp.Shared.Constants
<div class="popup-wrapper" style="@GetDisplayStyle()"> <CascadingValue Value="this">
<div class="popup-content"> <div class="popup-wrapper" style="@GetDisplayStyle()">
@if (Closable) <div class="popup-content">
{ @if (Closable)
<button @onclick="HandleBackdropFilterClicked">@Icons.Shared.Close</button> {
} <button @onclick="HandleBackdropFilterClicked">@Icons.Shared.Close</button>
@ChildContent }
</div> @ChildContent
</div> </div>
</div>
</CascadingValue>
<BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="@Closable" <BackdropFilter @ref="BackdropFilter" OnClick="HandleBackdropFilterClicked" CloseOnClick="@Closable"
AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" /> AllowBodyScroll="false" Color="BackdropFilterColor.Overlay" />

View File

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

View File

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