From 0a7fb1f0afafc8b20882caba6fd9f1c8872b4651 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Sat, 27 Dec 2025 19:31:44 +0100 Subject: [PATCH] del UndoButton --- .../Components/Game/UndoButton.razor | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 src/Koogle.Web/Components/Game/UndoButton.razor diff --git a/src/Koogle.Web/Components/Game/UndoButton.razor b/src/Koogle.Web/Components/Game/UndoButton.razor deleted file mode 100644 index e8519b3..0000000 --- a/src/Koogle.Web/Components/Game/UndoButton.razor +++ /dev/null @@ -1,103 +0,0 @@ -@using Koogle.Web.Store.GameState -@inherits FluxorComponent - -@inject IState GameState -@inject IDispatcher Dispatcher - -@* Only show when undo is available *@ -@if (CanUndo) -{ - - @ButtonText - -} - -@code { - /// - /// Whether to show the button even when no undo is available. - /// - [Parameter] - public bool AlwaysShow { get; set; } - - /// - /// Button variant (default: Outlined). - /// - [Parameter] - public Variant Variant { get; set; } = Variant.Outlined; - - /// - /// Whether button should be full width. - /// - [Parameter] - public bool FullWidth { get; set; } = true; - - /// - /// Button size. - /// - [Parameter] - public Size Size { get; set; } = Size.Medium; - - /// - /// Additional CSS classes. - /// - [Parameter] - public string? Class { get; set; } - - /// - /// Optional custom button text. If not set, shows count. - /// - [Parameter] - public string? CustomText { get; set; } - - /// - /// Whether to show the undo count in the button text. - /// - [Parameter] - public bool ShowCount { get; set; } = true; - - /// - /// Callback when undo is triggered. - /// - [Parameter] - public EventCallback OnUndoTriggered { get; set; } - - private int UndoCount => GameState.Value.UndoStack.Count; - private bool CanUndo => UndoCount > 0 || AlwaysShow; - private bool IsDisabled => UndoCount == 0 || GameState.Value.IsSaving; - - private string ButtonText - { - get - { - if (!string.IsNullOrEmpty(CustomText)) - return CustomText; - - var baseText = "Letzten Wurf rückgängig"; - return ShowCount && UndoCount > 0 - ? $"{baseText} ({UndoCount})" - : baseText; - } - } - - private async Task HandleUndo() - { - if (UndoCount == 0) - return; - - var lastSnapshot = GameState.Value.UndoStack[^1]; - - Dispatcher.Dispatch(new UndoThrowSuccessAction( - lastSnapshot.ThrowPanel, - lastSnapshot.Participants, - lastSnapshot.GameModel)); - - await OnUndoTriggered.InvokeAsync(); - } -}