Fix form sizing
This commit is contained in:
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
@using GameIdeas.BlazorApp.Shared.Components.BackdropFilter
|
@using GameIdeas.BlazorApp.Shared.Components.BackdropFilter
|
||||||
@using GameIdeas.BlazorApp.Shared.Constants
|
@using GameIdeas.BlazorApp.Shared.Constants
|
||||||
|
|
||||||
|
<CascadingValue Value="this">
|
||||||
<div class="popup-wrapper" style="@GetDisplayStyle()">
|
<div class="popup-wrapper" style="@GetDisplayStyle()">
|
||||||
<div class="popup-content">
|
<div class="popup-content">
|
||||||
@if (Closable)
|
@if (Closable)
|
||||||
@@ -10,6 +11,8 @@
|
|||||||
@ChildContent
|
@ChildContent
|
||||||
</div>
|
</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" />
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user