Polish UI: consistent icon buttons, tooltips, modal backdrop close, and top bar layout
All checks were successful
CI / check (push) Successful in 45s
CI / build-image (push) Successful in 17s

- Standardize icon button sizing (size="icon") and color (text-muted-foreground) across top and bottom bars
- Group bottom bar icon buttons with gap-0 to match top bar style
- Add missing tooltips/aria-labels for stat block viewer, bulk import buttons
- Replace Settings icon with Library for source manager
- Make step forward/back buttons use primary (solid) variant
- Move round badge next to combatant name in center of top bar
- Close player create/edit and management modals on backdrop click

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-12 18:47:47 +01:00
parent 91703ddebc
commit 458c277e9f
5 changed files with 121 additions and 103 deletions

View File

@@ -54,11 +54,11 @@ describe("TurnNavigation", () => {
expect(container.textContent).not.toContain("—");
});
it("round badge and combatant name are in separate DOM elements", () => {
it("round badge and combatant name are siblings in the center area", () => {
renderNav();
const badge = screen.getByText("R1");
const name = screen.getByText("Goblin");
expect(badge.parentElement).not.toBe(name.parentElement);
expect(badge.parentElement).toBe(name.parentElement);
});
it("updates the round badge when round changes", () => {

View File

@@ -437,26 +437,32 @@ export function ActionBar({
<Button type="submit" size="sm">
Add
</Button>
<div className="flex items-center gap-0">
{onManagePlayers && (
<Button
type="button"
size="sm"
size="icon"
variant="ghost"
className="text-muted-foreground hover:text-hover-neutral"
onClick={onManagePlayers}
title="Player characters"
aria-label="Player characters"
>
<Users className="h-4 w-4" />
<Users className="h-5 w-5" />
</Button>
)}
{bestiaryLoaded && onViewStatBlock && (
<div ref={viewerRef} className="relative">
<Button
type="button"
size="sm"
size="icon"
variant="ghost"
className="text-muted-foreground hover:text-hover-neutral"
onClick={() => (viewerOpen ? closeViewer() : openViewer())}
title="Browse stat blocks"
aria-label="Browse stat blocks"
>
<Eye className="h-4 w-4" />
<Eye className="h-5 w-5" />
</Button>
{viewerOpen && (
<div className="absolute bottom-full right-0 z-50 mb-1 w-64 rounded-md border border-border bg-card shadow-lg">
@@ -506,14 +512,18 @@ export function ActionBar({
{bestiaryLoaded && onBulkImport && (
<Button
type="button"
size="sm"
size="icon"
variant="ghost"
className="text-muted-foreground hover:text-hover-neutral"
onClick={onBulkImport}
disabled={bulkImportDisabled}
title="Bulk import"
aria-label="Bulk import"
>
<Import className="h-4 w-4" />
<Import className="h-5 w-5" />
</Button>
)}
</div>
</form>
</div>
);

View File

@@ -77,8 +77,16 @@ export function CreatePlayerModal({
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
<div className="w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-xl">
// biome-ignore lint/a11y/noStaticElementInteractions: backdrop click to close
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
onMouseDown={onClose}
>
{/* biome-ignore lint/a11y/noStaticElementInteractions: prevent close when clicking modal content */}
<div
className="w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-xl"
onMouseDown={(e) => e.stopPropagation()}
>
<div className="mb-4 flex items-center justify-between">
<h2 className="text-lg font-semibold text-foreground">
{isEdit ? "Edit Player" : "Create Player"}

View File

@@ -28,8 +28,16 @@ export function PlayerManagement({
if (!open) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
<div className="w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-xl">
// biome-ignore lint/a11y/noStaticElementInteractions: backdrop click to close
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
onMouseDown={onClose}
>
{/* biome-ignore lint/a11y/noStaticElementInteractions: prevent close when clicking modal content */}
<div
className="w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-xl"
onMouseDown={(e) => e.stopPropagation()}
>
<div className="mb-4 flex items-center justify-between">
<h2 className="text-lg font-semibold text-foreground">
Player Characters

View File

@@ -1,5 +1,5 @@
import type { Encounter } from "@initiative/domain";
import { Settings, StepBack, StepForward, Trash2 } from "lucide-react";
import { Library, StepBack, StepForward, Trash2 } from "lucide-react";
import { D20Icon } from "./d20-icon";
import { Button } from "./ui/button";
import { ConfirmButton } from "./ui/confirm-button";
@@ -27,11 +27,8 @@ export function TurnNavigation({
return (
<div className="flex items-center gap-3 rounded-md border border-border bg-card px-4 py-3">
<div className="flex flex-shrink-0 items-center gap-3">
<Button
variant="outline"
size="icon"
className="h-8 w-8 text-foreground border-foreground hover:text-hover-action hover:border-hover-action hover:bg-transparent"
onClick={onRetreatTurn}
disabled={!hasCombatants || isAtStart}
title="Previous turn"
@@ -39,16 +36,13 @@ export function TurnNavigation({
>
<StepBack className="h-5 w-5" />
</Button>
<span className="rounded-full bg-muted text-foreground text-sm px-2 py-0.5 font-semibold">
<div className="min-w-0 flex-1 flex items-center justify-center gap-2 text-sm">
<span className="rounded-full bg-muted text-foreground text-sm px-2 py-0.5 font-semibold shrink-0">
R{encounter.roundNumber}
</span>
</div>
<div className="min-w-0 flex-1 text-center text-sm">
{activeCombatant ? (
<span className="truncate block font-medium">
{activeCombatant.name}
</span>
<span className="truncate font-medium">{activeCombatant.name}</span>
) : (
<span className="text-muted-foreground">No combatants</span>
)}
@@ -59,7 +53,7 @@ export function TurnNavigation({
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-hover-action"
className="text-muted-foreground hover:text-hover-action"
onClick={onRollAllInitiative}
title="Roll all initiative"
aria-label="Roll all initiative"
@@ -69,25 +63,23 @@ export function TurnNavigation({
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-hover-neutral"
className="text-muted-foreground hover:text-hover-neutral"
onClick={onOpenSourceManager}
title="Manage cached sources"
aria-label="Manage cached sources"
>
<Settings className="h-5 w-5" />
<Library className="h-5 w-5" />
</Button>
<ConfirmButton
icon={<Trash2 className="h-5 w-5" />}
label="Clear encounter"
onConfirm={onClearEncounter}
disabled={!hasCombatants}
className="h-8 w-8 text-muted-foreground"
className="text-muted-foreground"
/>
</div>
<Button
variant="outline"
size="icon"
className="h-8 w-8 text-foreground border-foreground hover:text-hover-action hover:border-hover-action hover:bg-transparent"
onClick={onAdvanceTurn}
disabled={!hasCombatants}
title="Next turn"