From dbc173f57bc597bb383171722a8f8575a761f252 Mon Sep 17 00:00:00 2001 From: Frank Schwenk Date: Fri, 20 Jun 2025 11:03:37 +0200 Subject: [PATCH] feat: optimize player selection for touch input - Increases the number of quick-pick buttons from 4 to 10. - Adds a '...' button that appears when more than 10 players exist in history. - Clicking '...' opens a scrollable modal listing all past players for easy selection. - This provides a much faster player selection flow on touch devices. Closes #4 --- src/components/NewGame.jsx | 49 ++++++++++++++- src/components/PlayerSelectModal.module.css | 70 +++++++++++++++++++++ 2 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 src/components/PlayerSelectModal.module.css diff --git a/src/components/NewGame.jsx b/src/components/NewGame.jsx index 738568f..10c0b25 100644 --- a/src/components/NewGame.jsx +++ b/src/components/NewGame.jsx @@ -1,6 +1,25 @@ import { h } from 'preact'; import { useState, useEffect, useRef } from 'preact/hooks'; import styles from './NewGame.module.css'; +import modalStyles from './PlayerSelectModal.module.css'; + +const PlayerSelectModal = ({ players, onSelect, onClose }) => ( +
+
e.stopPropagation()}> +
+

Alle Spieler

+ +
+
+ {players.map(player => ( + + ))} +
+
+
+); /** * Player 1 input step for multi-step game creation wizard. @@ -15,6 +34,7 @@ const Player1Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) const [player1, setPlayer1] = useState(initialValue); const [error, setError] = useState(null); const [filteredNames, setFilteredNames] = useState(playerNameHistory); + const [isModalOpen, setIsModalOpen] = useState(false); const inputRef = useRef(null); useEffect(() => { @@ -44,6 +64,11 @@ const Player1Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) onNext(name); }; + const handleModalSelect = (name) => { + setIsModalOpen(false); + handleQuickPick(name); + }; + const handleClear = () => { setPlayer1(''); setError(null); @@ -103,7 +128,7 @@ const Player1Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) {filteredNames.length > 0 && (
- {filteredNames.slice(0, 4).map((name, idx) => ( + {filteredNames.slice(0, 10).map((name, idx) => ( + )}
)} {error &&
{error}
} + {isModalOpen && ( + setIsModalOpen(false)} + /> + )}