24 Commits

Author SHA1 Message Date
Frank Schwenk
68434f885d feat(game-14.1): Implement undo, forfeit, log, and stats
- Implements a robust undo feature using a state stack.
- Adds a 'Forfeit' button to allow a player to concede the game.
- Introduces a 'Game Log' to track all turns, fouls, and re-racks.
- Calculates and displays post-game statistics (highest run, avg. pots/turn).
- All changes are related to issue #21.
2025-06-22 11:05:51 +02:00
Frank Schwenk
aa5ef1c5b2 feat(14.1): Implement foul system
Implements a comprehensive foul system for the 14.1 game mode as per issue #20.

- **`src/components/GameDetail141.jsx`**

    - Adds `handleFoul` function to manage standard (-1pt) and break (-2pt) fouls.

    - Implements logic for the 3-consecutive-foul rule, applying a -15pt penalty.

    - Adds foul counters and a visual warning for players with 2 consecutive fouls.

    - Resets the consecutive foul counter on a legal (non-foul) turn.

- **`src/components/GameDetail.module.css`**

    - Adds styles for foul buttons (`.foul-btn`).

    - Adds styles for the foul counter indicator (`.foul-indicator`) and warning (`.foul-warning`).

This commit fulfills the requirements for issue #20. The `.gitea` file is left unstaged as it points to the next issue to be worked on.
2025-06-22 10:43:21 +02:00
Frank Schwenk
6a25c18153 feat(game-14-1): Implement re-rack logic and scoring hooks
Implements the re-rack functionality and prepares the scoring system for foul integration, as detailed in issue #19.

- Adds '+14' and '+15' re-rack buttons to the game view.
- Creates a  function to update the number of balls on the table.
- Modifies the  function to accept an optional  argument, preparing it for the next phase of development.

Closes #19
2025-06-20 16:07:38 +02:00
Frank Schwenk
a71c65852d feat(game-14-1): Implement phase 1 foundation
Implements the foundational UI and logic for the 14.1 Endless game mode, as detailed in issue #18.

- Adds a new  component to handle the specific game view.
- Introduces a modal within the game view to select the starting player.
- Replaces text input with a button grid for selecting remaining balls.
- Updates  to correctly initialize the 14.1 game state.

Closes #18
2025-06-20 15:35:38 +02:00
Frank Schwenk
875e9c8795 feat: Implement rematch functionality
Refs #17

Adds a 'Rematch' button to the game completion modal.

Introduces a 'handleRematch' function in 'App.jsx' to create a new game with the same players and settings as the previous game.

The 'onRematch' handler is passed down to the 'GameCompletionModal' component.

Adds '.gitea' to '.gitignore' to prevent tracking local issue context.
2025-06-20 13:35:42 +02:00
Frank Schwenk
429d479f69 feat: Implement score increment on click and cleanup CSS
- Implemented score increment functionality directly on the score display in GameDetail.jsx.

- Deleted obsolete ValidationModal.module.css to finalize style consolidation.

- This resolves all outstanding tasks for the refactor and adds a minor feature enhancement.

- Closes #1
2025-06-20 13:01:30 +02:00
Frank Schwenk
dbc173f57b 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
2025-06-20 11:03:37 +02:00
Frank Schwenk
b466dd2a0a feat: complete wizard navigation for all steps
- Adds forward navigation arrows to the 'Game Type' and 'Race To' steps in the new game wizard.
- Unifies navigation logic across all five steps.
- Users can now review their selections before proceeding.

Closes #11
2025-06-20 10:44:27 +02:00
Frank Schwenk
14fd711858 refactor: Update Race To step UI and logic
- Renames 'Offen' to 'Endlos' and moves it to a separate line.
- Extends quick-pick buttons to include 1-9.
- Removes 'Custom' button and makes numeric input always visible.
- Updates placeholder text for the custom input.
- Closes #10
2025-06-20 10:23:14 +02:00
Frank Schwenk
1c77661dbc feat: Implement Game Type selection step
- Adds the 'GameTypeStep' to the new game wizard.
- Features large, touch-friendly buttons for selecting game types.
- Selection automatically proceeds to the next step.
- Includes progress indicator and back navigation.
- Closes #9
2025-06-20 10:16:13 +02:00
Frank Schwenk
47554cdd27 feat: Implement Player 3 input step
- Implemented the third step of the new game creation wizard for Player 3's name input.
- The step is optional and includes a 'Skip' button.
- Includes autosuggestions from player history and quick-pick buttons.
- Aligned styling and layout with previous steps, including fixes for button alignment.
- Closes #8
2025-06-20 10:10:32 +02:00
Frank Schwenk
a2b618ce16 feat(wizard): Player 2 step and multi-step navigation
- Add Player2Step component for player 2 name input
- Implement multi-step wizard logic in App.jsx
- Player 1/2 steps now allow forward/back navigation
- Left arrow on Player 2 returns to Player 1, not abort
- Prepare placeholders for further steps

Closes #7
2025-06-18 20:59:05 +02:00
Frank Schwenk
76ef005cda feat(wizard): Player 1 step UI overhaul
- Quick-pick now advances to next step
- Added clear (×) icon to input field
- Replaced navigation buttons with large left/right arrows
- All controls are touch-friendly and visually prominent

Closes #6
2025-06-18 20:48:28 +02:00
Frank Schwenk
d1379985f3 refactor: deduplicate modal/button styles and enforce global utility usage
- Consolidated all modal-related styles into Modal.module.css; ValidationModal.module.css is now deprecated
- All main action/navigation buttons in NewGame and GameDetail use global .btn/.nav-buttons utility classes
- Removed duplicate utility classes from component CSS files
- Fixed .fullscreenToggle class naming for consistency
- Cleaned up component CSS to only contain component-specific styles
- Updated GameCompletionModal to use shared modal styles

This ensures DRY, maintainable, and consistent styling across the app.
2025-06-06 16:42:11 +02:00
Frank Schwenk
209df5d9f2 refactor: apply Astro, Preact, and general best practices to src
- Refactored all components in src/components to:
  - Use arrow function components and prop destructuring
  - Add JSDoc for all exported components
  - Improve accessibility (aria-labels, roles, etc.)
  - Use correct key usage in lists
  - Add comments for non-obvious logic
  - Use modern event handler patterns and memoization where appropriate
- Refactored src/pages/index.astro:
  - Removed <html>, <head>, and <body> (should be in layout)
  - Used semantic <main> for main content
  - Kept only necessary imports and markup
- Refactored src/styles/index.css:
  - Removed duplicate rules
  - Ensured only global resets/utilities are present
  - Added comments for clarity
  - Ensured no component-specific styles are present
  - Used consistent formatting

Brings the codebase in line with modern Astro and Preact best practices, improves maintainability, accessibility, and code clarity.
2025-06-06 16:28:57 +02:00
Frank Schwenk
7cb79f5ee3 fix: modal overlay and game screen styling
- Move modal overlay CSS to global stylesheet for reliable overlay behavior
- Render GameCompletionModal outside main container for true overlay effect
- Refactor GameCompletionModal to use global overlay and local content styles
- Fix player score layout, color, and button styling on game detail screen
- Add global .modal and .modal.show classes to index.css
- Clean up CSS modules for modal content and responsive design

Fixes #<issue_number>
2025-06-06 15:56:04 +02:00
Frank Schwenk
d81c375f1e feat(new-game): prefill with last game, add clear-all button
- New Game form is now prefilled with the last created game's values
- Added 'Felder leeren' (Clear All) button at the top to reset all fields
- Improves speed and UX for repeated game entry

Refs #1
2025-06-06 13:11:03 +02:00
Frank Schwenk
c845b0cb51 refactor(new-game): modernize UI, remove player selects
- Refactored New Game screen to use a modern, card-like, dark-themed layout
- Removed select dropdowns for previous players, now only datalist+input for player names
- Updated paddings, backgrounds, borders, and font sizes for a visually consistent, modern look
- No logic changes, only markup and style

Refs #1
2025-06-06 12:54:13 +02:00
Frank Schwenk
b44b013f58 refactor: move filter bar to GameList and fix button styling
- Moved filter button bar from App.jsx to GameList.jsx for better separation of concerns.
- Updated GameList to accept filter/setFilter props and render the filter bar internally.
- Moved .new-game-button styles to global CSS for consistent styling.
- Ensured filter button styles remain in GameList.module.css.
- Improves modularity and UI consistency.
2025-06-06 12:22:55 +02:00
Frank Schwenk
8384d08393 refactor: migrate UI to Preact components and remove legacy Astro/JS
- Replaced all .astro components with .jsx Preact components and added corresponding CSS modules.
- Updated index.astro to use the new App Preact component; removed legacy script and Astro imports.
- Deleted obsolete .astro component files and main JS logic (src/scripts/index.js, public/scripts/index.js).
- Updated astro.config.mjs for Preact integration.
- Updated package.json and package-lock.json to include @astrojs/preact and preact.
- Updated tsconfig.json for Preact JSX support.
- Refactored index.css to keep only global resets and utility styles.
- All changes relate to Gitea issue #1 (refactor to astro app).

Migrates the UI from Astro/vanilla JS to a modular Preact component architecture, removing all legacy code and aligning the project with modern best practices.
Refs #1
2025-06-06 11:58:29 +02:00
Frank Schwenk
de07d6e7a2 refactor: modularize screens, styles, and logic
- Split monolithic index.astro into Astro components for each screen and modal
- Moved all styles to src/styles/index.css
- Moved all JS logic to src/scripts/index.js and public/scripts/index.js
- Updated event wiring and removed inline handlers for best practice
- Ensured all components and scripts are integrated and functional

Refs #1
2025-06-05 19:51:01 +02:00
Frank Schwenk
38916b026d Commit staged changes 2025-06-05 18:27:02 +02:00
Frank Schwenk
f2e11e74e1 Document and automate Cursor rules adaptation for Astro web app 2025-06-05 18:12:59 +02:00
Frank Schwenk
03cb869a0a Commit staged changes 2025-06-05 18:08:47 +02:00
42 changed files with 3980 additions and 1819 deletions

Submodule .cursor deleted from 24996c0e13

25
.cursor/README.md Normal file
View File

@@ -0,0 +1,25 @@
# Cursor Rules for BSC Score (Astro Web App)
## Summary of Rule Adaptations
This project uses the Cursor rules system to enforce best practices and workflow discipline. The following summarizes the rule adaptations, removals, and additions for this project:
### Enforced Rules
- All general development, git workflow, Gitea usage, discipline, and best practices rules are enforced.
- **best-practices-astro.mdc** is enforced, as the project is built with Astro.
- Type safety and code quality rules are relevant due to the use of TypeScript (via Astro's strict config).
### Not Relevant / Not Present
- No CLI, API, or data science rules are present or required, as this is a web application only.
- No rules were removed, as all present rules are applicable to the project domain.
### Project-Specific Adaptations
- See `.cursor/rules/project-adaptations.mdc` for a detailed rationale and documentation of all rule adaptations and exceptions.
### Maintenance
- When central rules are updated, all `.mdc` files in `.cursor/rules` should be re-reviewed and project-specific adaptations re-applied.
- If any conflicts or ambiguities arise, manual review will be requested.
---
This README documents the current state of rule enforcement and adaptation for the BSC Score project. For further details, consult the individual rule files in `.cursor/rules/` and the project adaptation summary.

View File

@@ -0,0 +1,15 @@
---
description:
globs:
alwaysApply: true
---
- Write clean, readable, and maintainable code
- Follow SOLID principles and DRY (Don't Repeat Yourself)
- Use meaningful variable and function names that explain their purpose
- Add comments for complex logic, but prefer self-documenting code
- Handle errors gracefully with proper error handling
- Implement proper logging and debugging practices
- Use consistent indentation and formatting
- Avoid deep nesting - prefer early returns and guard clauses
- Keep functions small and focused on single responsibilities
- Use type safety when available (TypeScript, JSDoc, etc.)

View File

@@ -0,0 +1,40 @@
---
description:
globs:
alwaysApply: true
---
# /dev Folder Rules
## Resource Management Protocol
- Resources in `/dev` are staging materials that require processing before production use
- NEVER automatically copy resources from `/dev` to production locations
- ONLY move or process `/dev` resources when explicitly instructed by user
- Maintain original files in `/dev` unless specifically told to remove them
## Quick and Dirty (QnD) Scripts Protocol
- `/dev` is the designated location for quick prototyping scripts
- QnD scripts in `/dev` don't need to follow full production code standards
- Focus on functionality over code quality for QnD scripts
- Document script purpose with minimal comments
- Use descriptive filenames that indicate script function
- QnD scripts should be marked clearly (e.g., `qnd_` prefix or `.qnd.` in filename)
## Proof of Concept (POC) Protocol
- All POC development happens exclusively in `/dev`
- POC code should be isolated from production codebase
- POC code can be experimental and doesn't require full error handling
- When POC is approved for production, create separate implementation outside `/dev`
## Temporary Files Management
- Use `/dev` for all temporary files created during development process
- User-created temporary files can be placed directly in `/dev`
## Safety and Cleanup Rules
- NEVER delete files from `/dev` without explicit user permission
- Ask before moving files out of `/dev` to production locations
- Maintain clear separation between `/dev` content and production code
## Exclusions and Restrictions
- Production builds should NEVER reference files directly from `/dev`
- `/dev` paths should not be hardcoded in production configuration
- `/dev` is not for production dependencies or critical system files

View File

@@ -0,0 +1,46 @@
---
description:
globs:
alwaysApply: true
---
# Development Discipline Rules
## Precision Over Presumption
- NEVER add functionality that wasn't explicitly requested
- NEVER speculate beyond the current scope of work
- NEVER assume requirements or extend beyond stated needs
- If uncertain about any aspect, state "I don't know" rather than guessing
- Stick to the exact scope defined in the request
## File Modification Protocol
- NEVER modify files if the user's prompt ends with a question mark (?)
- NEVER assume permission to refactor existing code
- Only modify files when explicitly instructed to do so
- Always ask for permission before making structural changes
## Code Quality Enforcement (Zero Tolerance)
- Every line of code must be bug-free, secure, and maintainable
- Violations of DRY (Don't Repeat Yourself) are unacceptable
- Violations of KISS (Keep It Simple, Stupid) are unacceptable
- Code must be self-documenting with meaningful names
- Comments should explain "why" not "what"
- Names must reveal intent clearly
## Technical Standards (Non-Negotiable)
- Correctness takes priority over performance
- Readability is paramount in all code decisions
- Every solution must include:
- Comprehensive error handling
- Input validation
- Consideration of failure modes
- Edge case handling
- Design pattern choices must be justified (e.g., "Using Factory pattern here because...")
## Violation Response Protocol
- If a rule conflicts with a user request:
1. Clearly state the specific conflict
2. Refuse the action until the conflict is resolved
3. Provide alternative approaches if possible
- Example responses:
- "This would violate DRY principle because... Alternative approach: ..."
- "Cannot modify files - prompt ends with '?'. Did you mean to ask a question instead?"

View File

@@ -0,0 +1,40 @@
---
description:
globs:
alwaysApply: true
---
# Git Workflow Rules
## Zero Autonomy on Git Operations
- NEVER stage, commit, or push code without explicit user instruction
- NEVER assume permission to perform git operations
- If asked about git status, only provide information - do not take action
## Commit Protocol (When Explicitly Asked)
When user requests a commit, follow this exact sequence:
1. **Review Phase**:
- List ALL modified files with their status (M/A/D)
- List ALL added files that will be staged
- List ALL deleted files
- Check for any files that should be included but aren't staged
2. **Summary Phase**:
- Generate commit title (≤50 characters, imperative mood)
- Create detailed bulleted summary including:
- Which files were changed and how
- What logic was modified/added/removed
- Impact of changes on functionality
- Purpose statement (e.g., "Fix race condition" → "Patches race condition in user authentication flow")
3. **Confirmation Phase**:
- Present the complete commit message for approval
- Show exactly what will be committed
- Wait for explicit confirmation before executing
- If user rejects, ask for specific changes to the commit message
## Git Safety Rules
- If no changes detected when asked to commit: "No changes detected. Aborting as per Git rules."
- If conflicts exist, report them but do not resolve without instruction
- Never force push or use destructive git operations
- Always use conventional commit format when generating messages

View File

@@ -0,0 +1,43 @@
---
description:
globs:
alwaysApply: true
---
# Gitea Usage Rules
## Purpose
Establish disciplined, transparent, and user-aligned protocols for using Gitea, especially regarding issue management and traceability between code and issues.
## Rules
1. **Stick to the Current Selected Issue**
- Always work with a clearly selected, active Gitea issue.
- All code changes must be associated with the currently selected issue.
- If you need to switch issues, document the switch and update the new issue context before proceeding.
2. **Update Issues After Commits**
- After every commit, update the relevant Gitea issue(s) with a summary of the changes made.
- Include references to commit hashes and affected files or features.
- If the commit resolves or partially addresses the issue, state this explicitly in the issue update.
3. **Link Commits in Issues**
- Every commit message must reference the relevant Gitea issue by its number (e.g., `Fixes #42` or `Refs #42`).
- When updating an issue, include direct links to the commit(s) in Gitea for traceability.
- Use Gitea's markdown syntax to create clickable links to commits and related issues.
4. **Issue-Driven Workflow**
- Do not make code changes without an associated issue.
- If a new task arises, create a Gitea issue before starting work.
- Use issues to track discussions, decisions, and progress.
5. **Responsibility for Issue Hygiene**
- Keep issue status, labels, and assignees up to date.
- Close issues only when fully resolved and after confirming with all stakeholders if needed.
- Document any ambiguity or blockers in the issue before pausing or switching context.
6. **Current Issue Tracking via .gitea File**
- A file named `.gitea` can exist in the project root, containing the URL of the currently selected Gitea issue (e.g., `https://gitea.schwenk.online/froxxxy/vfbred/issues/3`).
- The AI assistant will read this file to determine the current project name and issue number for all Gitea-related operations.
## Rationale
These rules ensure that all work is traceable, communication is clear, and project history is auditable. They foster accountability and make onboarding, reviews, and audits more efficient.

View File

@@ -0,0 +1,39 @@
---
description:
globs:
alwaysApply: false
---
# Cursor Rules Automated Installation & Configuration Guide
You are to follow these instructions after this `rules` folder has been copied into the project's `.cursor` directory. Your goal is to configure and adapt the rules for this specific project with minimal manual intervention.
## 1. Review Rule Files
- Read all `.mdc` files in `.cursor/rules`.
- Identify any rules that are not relevant to this project's framework, language, or domain.
- List which files should be removed, renamed, or adapted, and propose new rules if needed.
## 2. Adaptation
- For each rule that requires adaptation (e.g., framework-specific best practices), generate a new `.mdc` file (e.g., `best-practices-react.mdc`, `best-practices-python.mdc`) with appropriate content.
- Remove or archive irrelevant rules (e.g., Astro-specific rules in a non-Astro project).
- If the project is not web-based, create domain-specific rules (e.g., `cli-ux.mdc`, `api-design.mdc`, `data-best-practices.mdc`).
## 3. Project-Specific Customization
- Analyze the project structure and requirements.
- Create a `project-adaptations.mdc` file summarizing any overrides, extensions, or exceptions to the default rules.
- Document all changes and the reasoning behind them.
## 4. Documentation
- Update `.cursor/README.md` to summarize all rule adaptations, removals, and additions.
- Clearly state which rules are overridden, ignored, or extended for this project.
## 5. Maintenance
- When the central rules are updated, re-read all `.mdc` files in `.cursor/rules`.
- Re-apply project-specific adaptations and update documentation as needed.
- Alert the user if any manual review is required due to conflicts or ambiguities.
---
**General Principle:**
- Automate as much of the review, adaptation, and documentation process as possible.
- Only request user input if clarification or conflict resolution is required.

View File

@@ -0,0 +1,12 @@
---
description:
globs:
alwaysApply: true
---
- Use Model Context Protocol (MCP) servers when available and appropriate
- Leverage MCP for enhanced functionality like file system operations, API integrations, or specialized tools
- Prefer MCP-based solutions over manual implementations when MCP servers are available
- Utilize MCP for better context awareness and cross-system integration
- Check for available MCP servers before implementing custom solutions
- Use MCP for database operations, external API calls, and system integrations when possible
- Ensure MCP usage aligns with security best practices and project requirements

View File

@@ -0,0 +1,12 @@
---
description:
globs:
alwaysApply: true
---
- Always reference and stay aligned with the requirements in [prd.md](mdc:docs/prd.md)
- Before making any significant changes, verify they align with the PRD specifications
- If a proposed change conflicts with the PRD, flag it and ask for clarification
- Ensure all new features and modifications serve the goals outlined in the PRD
- Maintain consistency with the project scope and user stories defined in the PRD
- Consider the technical requirements and constraints mentioned in the PRD
- Validate that implementations match the expected user experience described in the PRD

View File

@@ -0,0 +1,26 @@
---
description:
globs:
alwaysApply: false
---
# Project-Specific Rule Adaptations for BSC Score (Astro Web App)
## Overview
This project is a modern, responsive web application for tracking billiards scores, built with Astro and vanilla JavaScript. The following adaptations and exceptions apply to the default Cursor rules:
## Rule Adaptations & Removals
- **best-practices-astro.mdc**: Kept and enforced, as the project is built with Astro.
- **CLI/API/Non-Web Rules**: No CLI, API, or data science rules are needed. No such rules exist in the current ruleset, so no removals are required.
- **All Other Rules**: All other rules are relevant and retained, as they apply to general development, git workflow, Gitea usage, discipline, and best practices for web projects.
## Reasoning
- The project is a web application using Astro, so Astro-specific best practices are required.
- There is no CLI, API, or non-web domain logic, so no domain-specific rules for those are needed.
- TypeScript is supported via Astro's strict config, so type safety rules are relevant.
## Overrides/Extensions
- No overrides or extensions are currently required. If the project scope changes (e.g., adds an API or CLI), new rules will be proposed.
## Documentation
- This file documents the rationale for rule selection and adaptation. All changes are summarized in .cursor/README.md as required.

View File

@@ -0,0 +1,11 @@
---
description:
globs:
alwaysApply: true
---
- When questions are asked, provide clear and comprehensive answers
- Do NOT make any code changes, file modifications, or implementations when answering questions
- Focus solely on explaining concepts, providing guidance, or clarifying requirements
- If examples are needed, present them as explanatory code blocks, not as file changes
- Ask for explicit confirmation before making any modifications to the codebase
- Separate informational responses from actionable requests clearly

View File

@@ -0,0 +1,54 @@
---
description:
globs:
alwaysApply: true
---
# Senior Developer Protocol Rules
## Expert-Level Assumption
- Assume user has expert-level technical competence
- NEVER explain basic programming concepts unless explicitly asked
- Phrases like "As you know..." are forbidden
- No patronizing simplifications - provide raw technical depth
- Prioritize implementation over theory unless explicitly requested
- Code examples > lengthy explanations
## Absolute Truthfulness Protocol
- NEVER lie by omission, approximation, or fabrication
- If uncertain about anything:
- Use "I don't know" as a hard stop - no guessing allowed
- Flag unverified information with "UNVERIFIED:" prefix
- If solution is suboptimal or controversial:
- "The standard approach is X, but it fails for Y. Here's why Z might be better, but risks A."
## No False Certainty
- Reject binary answers for ambiguous problems
- Use phrases like: "There's no consensus on this—here are the tradeoffs..."
- Always expose unknowns: "This answer depends on [unconfirmed variable]. Without testing, we can't be sure."
- Acknowledge when multiple valid approaches exist
## Correctness Over Politeness
- If user request has flaws (anti-patterns, security risks):
- "WARNING: This approach would cause X due to Y. Alternatives: A, B."
- If better tools/libraries exist:
- "You asked for X, but Y is industry-standard because... Shall I proceed with X anyway?"
- Challenge problematic requests directly and professionally
## Proof of Work Requirements
For complex answers, provide:
- Citations from official documentation or RFCs
- Benchmarks if performance is critical
- Explicit testing recommendations: "This is untested—would you like a prototype to validate?"
- References to industry standards and best practices
## Response Prefixes (Mandatory)
- Use "UNVERIFIED:" for uncertain information
- Use "OPINION:" for subjective recommendations
- Use "WARNING:" for potentially problematic approaches
- Use "UNTESTED:" for theoretical solutions
## Conflict Resolution
- If request is impossible or contradictory:
- "INVALID: This violates [principle X] because [Y]. Aborting."
- Provide clear reasoning for refusal
- Offer alternative approaches when possible

View File

@@ -0,0 +1,44 @@
---
description:
globs:
alwaysApply: true
---
# Thinking Process Rules
## Exploration First Protocol
- Always show uncertainty and reasoning process
- Use phrases like: "I'm debating between X and Y because..."
- Document failed approaches: "Approach A failed due to B; pivoting to C."
- Make the decision-making process transparent and auditable
## Atomic Step Reasoning
- Break down complex reasoning into numbered, simple sentences
- Show progression of thought clearly
- Revise thinking publicly: "Earlier I thought X, but now Y makes more sense because..."
- Each step should be independently understandable
## Proactive Problem Anticipation
- Propose unrequested but relevant solutions when critical
- Use format: "You didn't ask for error handling, but Z is critical because..."
- Identify potential issues before they become problems
- Suggest complementary improvements that align with the main request
## Auditable Decision Trail
- Document why specific approaches were chosen over alternatives
- Show trade-off analysis: "Chose X over Y because of performance, but sacrifices readability"
- Include decision context: "Given constraints A and B, solution C is optimal"
- Make it easy to understand the reasoning behind technical choices
## Iterative Refinement Process
- Start with initial assessment
- Show how understanding evolves
- Document assumption changes
- Acknowledge when new information changes conclusions
- Example: "Initial analysis suggested X, but considering constraint Y, Z is actually better"
## Question Protocol Integration
- When user prompt starts with "QUESTION":
- Provide thorough answer using above thinking process
- Do NOT modify any files
- Focus entirely on explanation and reasoning
- Make thinking process visible in the response

2
.gitea
View File

@@ -1 +1 @@
@https://gitea.schwenk.online/froxxxy/bscscore/issues/1 @https://gitea.schwenk.online/froxxxy/bscscore/issues/10

2
.gitignore vendored
View File

@@ -24,4 +24,4 @@ pnpm-debug.log*
.idea/ .idea/
.gitea .gitea
dev/ dev/.gitea

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule ".cursor"]
path = .cursor
url = ssh://git@gitea.schwenk.online:2222/froxxxy/cursorrules.git

View File

@@ -1,5 +1,9 @@
// @ts-check // @ts-check
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import preact from '@astrojs/preact';
// https://astro.build/config // https://astro.build/config
export default defineConfig({}); export default defineConfig({
integrations: [preact()]
});

870
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,14 @@
"type": "module", "type": "module",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev --host",
"build": "astro build", "build": "astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"astro": "^5.8.2" "@astrojs/preact": "^4.1.0",
"astro": "^5.9.0",
"preact": "^10.26.8"
} }
} }

View File

@@ -1,22 +0,0 @@
{
"name": "BSC Score",
"short_name": "BSC Score",
"description": "Pool Scoring App für den Billard Sport Club",
"lang": "de",
"start_url": ".",
"display": "fullscreen",
"background_color": "#1a1a1a",
"theme_color": "#000000",
"icons": [
{
"src": "icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

View File

@@ -1,31 +0,0 @@
const CACHE_NAME = 'bscscore-v1';
const URLS_TO_CACHE = [
'/',
'/index.html',
'/manifest.json',
'/favicon.ico',
'/icon-192.png',
'/icon-512.png'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(URLS_TO_CACHE))
);
});
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key)))
)
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response =>
response || fetch(event.request).catch(() => caches.match('/index.html'))
)
);
});

359
src/components/App.jsx Normal file
View File

@@ -0,0 +1,359 @@
import { h } from 'preact';
import { useState, useEffect, useCallback } from 'preact/hooks';
import GameList from './GameList.jsx';
import GameDetail from './GameDetail.jsx';
import { Player1Step, Player2Step, Player3Step, GameTypeStep, RaceToStep } from './NewGame.jsx';
import Modal from './Modal.jsx';
import ValidationModal from './ValidationModal.jsx';
import GameCompletionModal from './GameCompletionModal.jsx';
import FullscreenToggle from './FullscreenToggle.jsx';
const LOCAL_STORAGE_KEY = 'bscscore_games';
/**
* Main App component for BSC Score
* @returns {import('preact').VNode}
*/
const App = () => {
const [games, setGames] = useState([]);
const [currentGameId, setCurrentGameId] = useState(null);
const [playerNameHistory, setPlayerNameHistory] = useState([]);
const [screen, setScreen] = useState('game-list');
const [modal, setModal] = useState({ open: false, gameId: null });
const [validation, setValidation] = useState({ open: false, message: '' });
const [completionModal, setCompletionModal] = useState({ open: false, game: null });
const [filter, setFilter] = useState('all');
const [newGameStep, setNewGameStep] = useState(null);
const [newGameData, setNewGameData] = useState({ player1: '', player2: '', player3: '', gameType: '', raceTo: '' });
// Load games from localStorage on mount
useEffect(() => {
const savedGames = localStorage.getItem(LOCAL_STORAGE_KEY);
if (savedGames) {
setGames(JSON.parse(savedGames));
}
}, []);
// Save games to localStorage whenever games change
useEffect(() => {
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(games));
// Update player name history
const nameLastUsed = {};
games.forEach(game => {
if (game.player1) nameLastUsed[game.player1] = Math.max(nameLastUsed[game.player1] || 0, new Date(game.updatedAt).getTime());
if (game.player2) nameLastUsed[game.player2] = Math.max(nameLastUsed[game.player2] || 0, new Date(game.updatedAt).getTime());
if (game.player3) nameLastUsed[game.player3] = Math.max(nameLastUsed[game.player3] || 0, new Date(game.updatedAt).getTime());
});
setPlayerNameHistory(
[...new Set(Object.keys(nameLastUsed))].sort((a, b) => nameLastUsed[b] - nameLastUsed[a])
);
}, [games]);
// Navigation handlers
const showGameList = useCallback(() => {
setScreen('game-list');
setCurrentGameId(null);
}, []);
const showNewGame = useCallback(() => {
setScreen('new-game');
setCurrentGameId(null);
setNewGameStep('player1');
setNewGameData({ player1: '', player2: '', player3: '', gameType: '', raceTo: '' });
}, []);
const showGameDetail = useCallback((id) => {
setCurrentGameId(id);
setScreen('game-detail');
}, []);
// Game creation
const handleCreateGame = useCallback(({ player1, player2, player3, gameType, raceTo }) => {
const newGame = {
id: Date.now(),
gameType,
raceTo: parseInt(raceTo, 10),
status: 'active',
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
log: [],
undoStack: [],
};
if (gameType === '14/1 endlos') {
const players = [{ name: player1, score: 0, consecutiveFouls: 0 }, { name: player2, score: 0, consecutiveFouls: 0 }];
if (player3) {
players.push({ name: player3, score: 0, consecutiveFouls: 0 });
}
newGame.players = players;
newGame.currentPlayer = null; // Set to null, will be chosen in GameDetail141
newGame.ballsOnTable = 15;
} else {
newGame.player1 = player1;
newGame.player2 = player2;
newGame.score1 = 0;
newGame.score2 = 0;
if (player3) {
newGame.player3 = player3;
newGame.score3 = 0;
}
}
setGames(g => [newGame, ...g]);
return newGame.id;
}, []);
// Game update for 14.1
const handleGameAction = useCallback((updatedGame) => {
const originalGame = games.find(game => game.id === currentGameId);
if (!originalGame) return;
// Add the original state to the undo stack before updating
const newUndoStack = [...(originalGame.undoStack || []), originalGame];
const gameWithHistory = {
...updatedGame,
undoStack: newUndoStack,
updatedAt: new Date().toISOString(),
};
setGames(games => games.map(game => (game.id === currentGameId ? gameWithHistory : game)));
// Check for raceTo completion
if (gameWithHistory.raceTo) {
const winner = gameWithHistory.players.find(p => p.score >= gameWithHistory.raceTo);
if (winner) {
setCompletionModal({ open: true, game: gameWithHistory });
}
}
}, [games, currentGameId]);
const handleUndo = useCallback(() => {
const game = games.find(g => g.id === currentGameId);
if (!game || !game.undoStack || game.undoStack.length === 0) return;
const lastState = game.undoStack[game.undoStack.length - 1];
const newUndoStack = game.undoStack.slice(0, -1);
setGames(g => g.map(gme => (gme.id === currentGameId ? { ...lastState, undoStack: newUndoStack } : gme)));
}, [games, currentGameId]);
const handleForfeit = useCallback(() => {
const game = games.find(g => g.id === currentGameId);
if (!game) return;
const winner = game.players.find((p, idx) => idx !== game.currentPlayer);
// In a 2 player game, this is simple. For >2, we need a winner selection.
// For now, assume the *other* player wins. This is fine for 2 players.
// We'll mark the game as complete with a note about the forfeit.
const forfeitedGame = {
...game,
status: 'completed',
winner: winner.name,
forfeitedBy: game.players[game.currentPlayer].name,
updatedAt: new Date().toISOString(),
};
setGames(g => g.map(gme => (gme.id === currentGameId ? forfeitedGame : gme)));
setCompletionModal({ open: true, game: forfeitedGame });
}, [games, currentGameId]);
// Score update
const handleUpdateScore = useCallback((player, change) => {
setGames(games => games.map(game => {
if (game.id !== currentGameId || game.status === 'completed') return game;
const updated = { ...game };
if (player === 1) updated.score1 = Math.max(0, updated.score1 + change);
if (player === 2) updated.score2 = Math.max(0, updated.score2 + change);
if (player === 3) updated.score3 = Math.max(0, updated.score3 + change);
updated.updatedAt = new Date().toISOString();
// Check for raceTo completion
if (updated.raceTo && (updated.score1 >= updated.raceTo || updated.score2 >= updated.raceTo || (updated.player3 && updated.score3 >= updated.raceTo))) {
setCompletionModal({ open: true, game: updated });
}
return updated;
}));
setCompletionModal({ open: false, game: null });
setScreen('game-detail');
}, [currentGameId]);
// Finish game
const handleFinishGame = useCallback(() => {
const game = games.find(g => g.id === currentGameId);
if (!game) return;
setCompletionModal({ open: true, game });
}, [games, currentGameId]);
const handleConfirmCompletion = useCallback(() => {
setGames(games => games.map(game => {
if (game.id !== currentGameId) return game;
return { ...game, status: 'completed', updatedAt: new Date().toISOString() };
}));
setCompletionModal({ open: false, game: null });
setScreen('game-detail');
}, [currentGameId]);
const handleRematch = useCallback(() => {
const completedGame = games.find(g => g.id === currentGameId);
if (!completedGame) return;
const newId = handleCreateGame({
player1: completedGame.player1,
player2: completedGame.player2,
player3: completedGame.player3,
gameType: completedGame.gameType,
raceTo: completedGame.raceTo,
});
setCompletionModal({ open: false, game: null });
showGameDetail(newId);
}, [games, currentGameId, handleCreateGame, showGameDetail]);
// Delete game
const handleDeleteGame = useCallback((id) => {
setModal({ open: true, gameId: id });
}, []);
const handleConfirmDelete = useCallback(() => {
setGames(games => games.filter(g => g.id !== modal.gameId));
setModal({ open: false, gameId: null });
setScreen('game-list');
}, [modal.gameId]);
const handleCancelDelete = useCallback(() => {
setModal({ open: false, gameId: null });
}, []);
// Validation modal
const showValidation = useCallback((message) => {
setValidation({ open: true, message });
}, []);
const closeValidation = useCallback(() => {
setValidation({ open: false, message: '' });
}, []);
// Step handlers
const handlePlayer1Next = (name) => {
setNewGameData(data => ({ ...data, player1: name }));
setNewGameStep('player2');
};
const handlePlayer2Next = (name) => {
setNewGameData(data => ({ ...data, player2: name }));
setNewGameStep('player3');
};
const handlePlayer3Next = (name) => {
setNewGameData(data => ({ ...data, player3: name }));
setNewGameStep('gameType');
};
const handleGameTypeNext = (type) => {
setNewGameData(data => ({ ...data, gameType: type, raceTo: type === '14/1 endlos' ? '150' : '50' }));
setNewGameStep('raceTo');
};
const handleRaceToNext = (raceTo) => {
const finalData = { ...newGameData, raceTo };
const newId = handleCreateGame(finalData);
showGameDetail(newId);
setNewGameStep(null);
setNewGameData({ player1: '', player2: '', player3: '', gameType: '', raceTo: '' });
};
const handleCancelNewGame = useCallback(() => {
setScreen('game-list');
setNewGameStep(null);
setNewGameData({ player1: '', player2: '', player3: '', gameType: '', raceTo: '' });
}, []);
return (
<div className="screen-container">
{screen === 'game-list' && (
<div className="screen active">
<div className="screen-content">
<button className="nav-button new-game-button" onClick={showNewGame} aria-label="Neues Spiel starten">Neues Spiel</button>
<GameList
games={games}
filter={filter}
onShowGameDetail={showGameDetail}
onDeleteGame={handleDeleteGame}
setFilter={setFilter}
/>
</div>
</div>
)}
{screen === 'new-game' && (
<div className="screen active">
<div className="screen-content">
{newGameStep === 'player1' && (
<Player1Step
playerNameHistory={playerNameHistory}
onNext={handlePlayer1Next}
onCancel={handleCancelNewGame}
initialValue={newGameData.player1}
/>
)}
{newGameStep === 'player2' && (
<Player2Step
playerNameHistory={playerNameHistory}
onNext={handlePlayer2Next}
onCancel={() => setNewGameStep('player1')}
initialValue={newGameData.player2}
/>
)}
{newGameStep === 'player3' && (
<Player3Step
playerNameHistory={playerNameHistory}
onNext={handlePlayer3Next}
onCancel={() => setNewGameStep('player2')}
initialValue={newGameData.player3}
/>
)}
{newGameStep === 'gameType' && (
<GameTypeStep
onNext={handleGameTypeNext}
onCancel={() => setNewGameStep('player3')}
initialValue={newGameData.gameType}
/>
)}
{newGameStep === 'raceTo' && (
<RaceToStep
onNext={handleRaceToNext}
onCancel={() => setNewGameStep('gameType')}
initialValue={newGameData.raceTo}
/>
)}
</div>
</div>
)}
{screen === 'game-detail' && (
<div className="screen active">
<div className="screen-content">
<GameDetail
game={games.find(g => g.id === currentGameId)}
onUpdateScore={handleUpdateScore}
onFinishGame={handleFinishGame}
onUpdateGame={handleGameAction}
onUndo={handleUndo}
onForfeit={handleForfeit}
onBack={showGameList}
/>
</div>
</div>
)}
<Modal
open={modal.open}
title="Spiel löschen"
message="Möchten Sie das Spiel wirklich löschen?"
onCancel={handleCancelDelete}
onConfirm={handleConfirmDelete}
/>
<ValidationModal
open={validation.open}
message={validation.message}
onClose={closeValidation}
/>
<GameCompletionModal
open={completionModal.open}
game={completionModal.game}
onConfirm={handleConfirmCompletion}
onClose={() => setCompletionModal({ open: false, game: null })}
onRematch={handleRematch}
/>
<FullscreenToggle />
</div>
);
};
export default App;

View File

@@ -0,0 +1,35 @@
import { h } from 'preact';
import { useCallback } from 'preact/hooks';
import styles from './FullscreenToggle.module.css';
/**
* Button to toggle fullscreen mode.
* @returns {import('preact').VNode}
*/
const FullscreenToggle = () => {
// Toggle fullscreen mode for the document
const handleToggle = useCallback(() => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
}
}, []);
return (
<button
id="fullscreen-toggle"
className={styles.fullscreenToggle}
onClick={handleToggle}
title="Vollbild umschalten"
aria-label="Vollbild umschalten"
type="button"
>
<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true">
<path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
</svg>
</button>
);
};
export default FullscreenToggle;

View File

@@ -0,0 +1,38 @@
/* FullscreenToggle-specific styles only. */
.fullscreenToggle {
position: fixed;
bottom: 20px;
right: 20px;
width: 48px;
height: 48px;
border-radius: 50%;
background-color: rgba(52, 152, 219, 0.9);
border: none;
color: white;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
z-index: 9999;
transition: background-color 0.2s, transform 0.2s;
}
.fullscreenToggle:hover {
background-color: rgba(52, 152, 219, 1);
transform: scale(1.1);
}
.fullscreenToggle:active {
transform: scale(0.95);
}
.fullscreenToggle svg {
width: 24px;
height: 24px;
}
@media screen and (max-width: 480px) {
.fullscreenToggle {
bottom: 15px;
right: 15px;
width: 40px;
height: 40px;
}
}

View File

@@ -0,0 +1,132 @@
import { h } from 'preact';
import modalStyles from './Modal.module.css';
import styles from './GameCompletionModal.module.css';
const calculateStats = (game) => {
if (game.gameType !== '14/1 endlos' || !game.log) {
return null;
}
const stats = {};
game.players.forEach(p => {
stats[p.name] = {
totalPots: 0,
turnCount: 0,
highestRun: 0,
currentRun: 0,
};
});
for (const entry of game.log) {
if (entry.type === 'turn') {
const playerStats = stats[entry.player];
playerStats.turnCount += 1;
if (entry.ballsPotted > 0) {
playerStats.totalPots += entry.ballsPotted;
playerStats.currentRun += entry.ballsPotted;
} else {
// Run ends on a 0-pot turn
playerStats.highestRun = Math.max(playerStats.highestRun, playerStats.currentRun);
playerStats.currentRun = 0;
}
} else if (entry.type === 'foul') {
const playerStats = stats[entry.player];
playerStats.turnCount += 1;
// Run ends on a foul
playerStats.highestRun = Math.max(playerStats.highestRun, playerStats.currentRun);
playerStats.currentRun = 0;
}
}
// Final check for runs that extend to the end of the game
Object.values(stats).forEach(playerStats => {
playerStats.highestRun = Math.max(playerStats.highestRun, playerStats.currentRun);
});
// Calculate averages
Object.keys(stats).forEach(playerName => {
const ps = stats[playerName];
ps.avgPots = ps.turnCount > 0 ? (ps.totalPots / ps.turnCount).toFixed(2) : 0;
});
return stats;
};
/**
* Modal shown when a game is completed.
* @param {object} props
* @param {boolean} props.open
* @param {object} props.game
* @param {Function} props.onConfirm
* @param {Function} props.onClose
* @param {Function} props.onRematch
* @returns {import('preact').VNode|null}
*/
const GameCompletionModal = ({ open, game, onConfirm, onClose, onRematch }) => {
if (!open || !game) return null;
let playerNames, scores, maxScore, winners, winnerText, gameStats;
if (game.gameType === '14/1 endlos') {
playerNames = game.players.map(p => p.name);
scores = game.players.map(p => p.score);
gameStats = calculateStats(game);
} else {
playerNames = [game.player1, game.player2, game.player3].filter(Boolean);
scores = [game.score1, game.score2, game.score3].filter((_, i) => playerNames[i]);
}
if (game.forfeitedBy) {
winnerText = `${game.winner} hat gewonnen, da ${game.forfeitedBy} aufgegeben hat.`;
} else {
maxScore = Math.max(...scores);
winners = playerNames.filter((name, idx) => scores[idx] === maxScore);
winnerText = winners.length > 1
? `Unentschieden zwischen ${winners.join(' und ')}`
: `${winners[0]} hat gewonnen!`;
}
return (
<div id="game-completion-modal" className={modalStyles['modal'] + ' ' + modalStyles['show']} role="dialog" aria-modal="true" aria-labelledby="completion-modal-title">
<div className={modalStyles['modal-content']}>
<div className={modalStyles['modal-header']}>
<span className={modalStyles['modal-title']} id="completion-modal-title">Spiel beendet</span>
<button className={modalStyles['close-button']} onClick={onClose} aria-label="Schließen">×</button>
</div>
<div className={modalStyles['modal-body']}>
<div className={styles['final-scores']}>
{playerNames.map((name, idx) => (
<div className={styles['final-score']} key={name + idx}>
<span className={styles['player-name']}>{name}</span>
<span className={styles['score']}>{scores[idx]}</span>
</div>
))}
</div>
<div className={styles['winner-announcement']}><h3>{winnerText}</h3></div>
{gameStats && (
<div className={styles['stats-container']}>
<h4 className={styles['stats-title']}>Statistiken</h4>
{playerNames.map(name => (
<div key={name} className={styles['player-stats']}>
<div className={styles['player-name-stats']}>{name}</div>
<div className={styles['stat-item']}>Höchste Serie: <strong>{gameStats[name].highestRun}</strong></div>
<div className={styles['stat-item']}>Punkte / Aufnahme: <strong>{gameStats[name].avgPots}</strong></div>
</div>
))}
</div>
)}
</div>
<div className={modalStyles['modal-footer']}>
<button className={styles['btn'] + ' ' + styles['btn--warning']} onClick={onConfirm} aria-label="Bestätigen">Bestätigen</button>
<button className={styles['btn'] + ' ' + styles['btn--primary']} onClick={onRematch} aria-label="Rematch">Rematch</button>
<button className={styles['btn']} onClick={onClose} aria-label="Abbrechen">Abbrechen</button>
</div>
</div>
</div>
);
};
export default GameCompletionModal;

View File

@@ -0,0 +1,110 @@
/* Only GameCompletionModal-specific styles. Shared modal styles are now in Modal.module.css */
.final-scores {
margin: 20px 0;
}
.final-score {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18px 0;
margin-bottom: 8px;
background: #333;
border-radius: 8px;
font-size: 1.2rem;
color: #fff;
}
.final-score .player-name {
font-size: 1.2rem;
font-weight: bold;
color: #fff;
}
.final-score .score {
font-size: 1.2rem;
font-weight: bold;
color: #fff;
}
.winner-announcement {
text-align: center;
margin: 20px 0 0 0;
padding: 18px 8px;
background: #43a047;
border-radius: 8px;
font-size: 1.2rem;
color: #fff;
font-weight: 700;
}
.winner-announcement h3 {
margin: 0;
font-size: 1.5rem;
color: #2c3e50;
text-align: center;
}
.btn {
flex: 1;
padding: 18px 0;
font-size: 1.1rem;
border: none;
border-radius: 8px;
cursor: pointer;
color: #fff;
background: #333;
font-weight: 600;
transition: background 0.2s;
}
.btn--warning {
background: #f44336;
}
.btn:not(.btn--warning):hover {
background: #444;
}
.btn--warning:hover {
background: #d32f2f;
}
@media (max-width: 600px) {
.btn {
font-size: 1rem;
padding: 14px 0;
}
}
.stats-container {
margin-top: 1.5rem;
padding-top: 1rem;
border-top: 1px solid #dee2e6;
}
.stats-title {
text-align: center;
font-size: 1.3rem;
color: #495057;
margin-bottom: 1rem;
}
.player-stats {
margin-bottom: 1rem;
padding: 0.75rem;
background-color: #f8f9fa;
border-radius: 4px;
}
.player-name-stats {
font-weight: bold;
margin-bottom: 0.5rem;
color: #343a40;
}
.stat-item {
display: flex;
justify-content: space-between;
font-size: 0.95rem;
color: #6c757d;
}
.stat-item strong {
color: #212529;
}
.btn {
padding: 0.75rem 1.5rem;
border-radius: 4px;
}

View File

@@ -0,0 +1,71 @@
import { h } from 'preact';
import styles from './GameDetail.module.css';
import GameDetail141 from './GameDetail141.jsx';
/**
* Game detail view for a single game.
* @param {object} props
* @param {object} props.game
* @param {Function} props.onFinishGame
* @param {Function} props.onUpdateScore
* @param {Function} props.onUpdateGame
* @param {Function} props.onUndo
* @param {Function} props.onForfeit
* @param {Function} props.onBack
* @returns {import('preact').VNode|null}
*/
const GameDetail = ({ game, onFinishGame, onUpdateScore, onUpdateGame, onUndo, onForfeit, onBack }) => {
if (!game) return null;
if (game.gameType === '14/1 endlos') {
return <GameDetail141 game={game} onUpdate={onUpdateGame} onUndo={onUndo} onForfeit={onForfeit} onBack={onBack} />;
}
const isCompleted = game.status === 'completed';
const playerNames = [game.player1, game.player2, game.player3].filter(Boolean);
const scores = [game.score1, game.score2, game.score3].filter((_, i) => playerNames[i]);
return (
<div className={styles['game-detail']}>
<div className={styles['game-title']}>
{game.gameType}{game.raceTo ? ` | Race to ${game.raceTo}` : ''}
</div>
<div className={styles['scores-container']}>
{playerNames.map((name, idx) => (
<div
className={styles['player-score'] + (name === 'Fränky' ? ' ' + styles['franky'] : '')}
key={name + idx}
>
<span className={styles['player-name']}>{name}</span>
<span
className={styles['score']}
id={`score${idx + 1}`}
onClick={() => !isCompleted && onUpdateScore(idx + 1, 1)}
aria-label={`Aktueller Punktestand für ${name}: ${scores[idx]}. Klicken zum Erhöhen.`}
>
{scores[idx]}
</span>
<button
className={styles['score-button']}
disabled={isCompleted}
onClick={() => onUpdateScore(idx+1, -1)}
aria-label={`Punkt abziehen für ${name}`}
>-</button>
<button
className={styles['score-button']}
disabled={isCompleted}
onClick={() => onUpdateScore(idx+1, 1)}
aria-label={`Punkt hinzufügen für ${name}`}
>+</button>
</div>
))}
</div>
<div className={styles['game-detail-controls']}>
<button className="btn" onClick={onBack} aria-label="Zurück zur Liste">Zurück zur Liste</button>
<button className="btn" disabled={isCompleted} onClick={onFinishGame} aria-label={isCompleted ? 'Abgeschlossen' : 'Spiel beenden'}>{isCompleted ? 'Abgeschlossen' : 'Spiel beenden'}</button>
</div>
</div>
);
};
export default GameDetail;

View File

@@ -0,0 +1,276 @@
/* GameDetail-specific styles only. Shared utility classes are now in global CSS. */
.screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: 100vh;
display: none;
opacity: 0;
transform: translateX(100%);
transition: transform 0.3s ease, opacity 0.3s ease;
}
.screen.active {
display: block;
opacity: 1;
transform: translateX(0);
position: relative;
}
.screen-content {
display: flex;
flex-direction: column;
min-height: 100vh;
padding: 20px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.game-title {
font-size: 24px;
color: #ccc;
}
.game-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
width: 100%;
}
.scores-container {
display: flex;
justify-content: space-between;
gap: 32px;
min-height: 0;
}
.player-score {
flex: 1;
text-align: center;
padding: 20px;
border-radius: 16px;
display: flex;
flex-direction: column;
min-height: 0;
margin: 0 8px;
}
.player-score:first-child {
background-color: #43a047;
}
.player-score:nth-child(2) {
background-color: #1565c0;
}
.player-score:nth-child(3) {
background-color: #333;
}
.player-name {
font-size: 24px;
margin-bottom: 10px;
color: #fff;
text-shadow: 0 2px 8px rgba(0,0,0,0.4);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.score {
font-size: 16vh;
font-weight: bold;
margin: 10px 0 20px 0;
line-height: 1;
color: #fff;
text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.score-buttons {
display: flex;
justify-content: center;
gap: 10px;
margin-top: auto;
}
.score-button {
background-color: #333;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
transition: background-color 0.2s;
min-width: 80px;
margin-bottom: 8px;
}
.game-controls {
display: flex;
gap: 10px;
margin-top: 20px;
width: 100%;
}
.control-button {
flex: 1;
padding: 30px;
background: #333;
color: white;
border: none;
border-radius: 0;
font-size: 24px;
cursor: pointer;
touch-action: manipulation;
}
.control-button.delete {
background: #f44336;
}
.game-detail-controls {
display: flex;
flex-direction: row;
gap: 24px;
margin: 40px 0 0 0;
width: 100%;
justify-content: center;
}
.franky .player-name {
font-weight: bold;
color: #ff8c00; /* Example color */
}
.active-player {
border: 2px solid #4caf50;
box-shadow: 0 0 10px #4caf50;
}
.turn-indicator {
margin: 20px 0;
font-size: 1.2rem;
text-align: center;
}
.potted-balls-container {
margin-top: 2rem;
padding: 1rem;
background: #2a2a2a;
border-radius: 8px;
}
.potted-balls-header {
text-align: center;
font-size: 1.1rem;
margin-bottom: 1rem;
font-weight: 600;
}
.potted-balls-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
gap: 10px;
}
.potted-ball-btn {
padding: 1rem;
font-size: 1.2rem;
font-weight: bold;
border-radius: 8px;
border: 1px solid #444;
background-color: #333;
color: #fff;
cursor: pointer;
transition: background-color 0.2s, transform 0.2s;
}
.potted-ball-btn:hover:not(:disabled) {
background-color: #45a049;
transform: translateY(-2px);
}
.potted-ball-btn:disabled {
background-color: #222;
color: #555;
cursor: not-allowed;
}
.rerack-controls {
display: flex;
justify-content: center;
gap: 1rem;
margin-top: 1.5rem;
}
.rerack-btn {
padding: 0.8rem 1.5rem;
font-size: 1rem;
font-weight: bold;
border-radius: 8px;
border: 1px solid #444;
background-color: #3a539b;
color: #fff;
cursor: pointer;
transition: background-color 0.2s;
}
.rerack-btn:hover {
background-color: #4a6fbf;
}
.foul-controls {
display: flex;
justify-content: center;
gap: 1rem;
margin-top: 1.5rem;
}
.foul-btn {
flex-grow: 1;
background-color: #ffc107; /* Amber */
color: #212529;
border: none;
padding: 0.75rem;
border-radius: var(--border-radius);
cursor: pointer;
font-size: 1rem;
transition: background-color 0.2s;
}
.foul-btn:hover {
background-color: #ffca2c;
}
.foul-btn:disabled {
background-color: #e0e0e0;
color: #9e9e9e;
cursor: not-allowed;
}
.foul-indicator {
font-size: 1rem;
font-weight: bold;
color: #fff;
background-color: #c0392b;
padding: 4px 8px;
border-radius: 4px;
margin-top: 8px;
display: inline-block;
}
.foul-warning {
background-color: #f39c12;
color: #000;
}
/* Game Log Styles */
.game-log {
width: 100%;
margin-top: 1.5rem;
padding: 1rem;
background-color: #f8f9fa;
border-radius: var(--border-radius);
border: 1px solid #dee2e6;
}
.log-title {
margin-top: 0;
margin-bottom: 0.5rem;
font-size: 1.2rem;
color: #495057;
}
.log-list {
list-style-type: none;
padding: 0;
margin: 0;
max-height: 200px;
overflow-y: auto;
font-size: 0.9rem;
}
.log-entry {
padding: 0.5rem 0.25rem;
border-bottom: 1px solid #e9ecef;
color: #6c757d;
}
.log-entry:last-child {
border-bottom: none;
}

View File

@@ -0,0 +1,208 @@
import { h } from 'preact';
import { useState } from 'preact/hooks';
import styles from './GameDetail.module.css';
import modalStyles from './PlayerSelectModal.module.css';
const StartingPlayerModal = ({ players, onSelect, onCancel }) => (
<div className={modalStyles.modalOverlay}>
<div className={modalStyles.modalContent} onClick={e => e.stopPropagation()}>
<div className={modalStyles.modalHeader}>
<h3>Welcher Spieler fängt an?</h3>
{/* A cancel button isn't strictly needed if a choice is mandatory */}
</div>
<div className={modalStyles.playerList}>
{players.map((player, index) => (
<button key={player.name} className={modalStyles.playerItem} onClick={() => onSelect(index)}>
{player.name}
</button>
))}
</div>
</div>
</div>
);
const GameLog = ({ log }) => {
if (!log || log.length === 0) {
return null;
}
return (
<div className={styles['game-log']}>
<h4 className={styles['log-title']}>Game Log</h4>
<ul className={styles['log-list']}>
{log.slice().reverse().map((entry, index) => (
<li key={index} className={styles['log-entry']}>
{entry.type === 'rerack' && `Re-Rack (+${entry.ballsAdded} balls).`}
{entry.foul && `Foul by ${entry.player}: ${entry.foul} (${entry.totalDeduction} pts).`}
{entry.ballsPotted !== undefined && `${entry.player}: ${entry.ballsPotted} balls potted. Score: ${entry.newScore}`}
</li>
))}
</ul>
</div>
);
};
const GameDetail141 = ({ game, onUpdate, onUndo, onForfeit, onBack }) => {
const handleSelectStartingPlayer = (playerIndex) => {
onUpdate({
...game,
currentPlayer: playerIndex,
});
};
// If no player is selected yet, show the modal
if (game.currentPlayer === null || game.currentPlayer === undefined) {
return <StartingPlayerModal players={game.players} onSelect={handleSelectStartingPlayer} />;
}
const currentPlayer = game.players[game.currentPlayer];
const handleTurnEnd = (remainingBalls, foulPoints = 0) => {
if (remainingBalls > game.ballsOnTable) {
console.error("Cannot leave more balls than are on the table.");
return;
}
const ballsPotted = game.ballsOnTable - remainingBalls;
const newScore = currentPlayer.score + ballsPotted - foulPoints;
const updatedPlayers = game.players.map((p, index) =>
index === game.currentPlayer ? { ...p, score: newScore, consecutiveFouls: 0 } : p
);
const nextPlayer = (game.currentPlayer + 1) % game.players.length;
onUpdate({
...game,
players: updatedPlayers,
ballsOnTable: remainingBalls,
currentPlayer: nextPlayer,
log: [...(game.log || []), { type: 'turn', player: currentPlayer.name, ballsPotted, foulPoints, newScore, ballsOnTable: remainingBalls }],
});
};
const handleFoul = (foulType) => {
let foulPoints = 0;
let penalty = 0;
const newConsecutiveFouls = (currentPlayer.consecutiveFouls || 0) + 1;
if (foulType === 'standard') {
foulPoints = 1;
} else if (foulType === 'break') {
foulPoints = 2;
}
if (newConsecutiveFouls === 3) {
penalty = 15;
}
const totalDeduction = foulPoints + penalty;
const newScore = currentPlayer.score - totalDeduction;
const updatedPlayers = game.players.map((p, index) => {
if (index === game.currentPlayer) {
return {
...p,
score: newScore,
consecutiveFouls: newConsecutiveFouls === 3 ? 0 : newConsecutiveFouls,
};
}
return p;
});
const nextPlayer = (game.currentPlayer + 1) % game.players.length;
onUpdate({
...game,
players: updatedPlayers,
currentPlayer: nextPlayer,
log: [
...(game.log || []),
{
type: 'foul',
player: currentPlayer.name,
foul: foulType,
foulPoints,
penalty,
totalDeduction,
newScore,
consecutiveFouls: newConsecutiveFouls
},
],
});
};
const handleReRack = (ballsToAdd) => {
const newBallsOnTable = game.ballsOnTable + ballsToAdd;
onUpdate({
...game,
ballsOnTable: newBallsOnTable,
log: [...(game.log || []), { type: 'rerack', player: currentPlayer.name, ballsAdded: ballsToAdd, ballsOnTable: newBallsOnTable }],
});
};
return (
<div className={styles['game-detail']}>
<div className={styles['game-title']}>
14/1 endlos | Race to {game.raceTo}
</div>
<div className={styles['scores-container']}>
{game.players.map((p, idx) => (
<div
className={`${styles['player-score']} ${idx === game.currentPlayer ? styles['active-player'] : ''}`}
key={p.name}
>
<span className={styles['player-name']}>{p.name}</span>
<span className={styles['score']}>{p.score}</span>
{p.consecutiveFouls > 0 && (
<span className={`${styles['foul-indicator']} ${p.consecutiveFouls === 2 ? styles['foul-warning'] : ''}`}>
Fouls: {p.consecutiveFouls}
</span>
)}
</div>
))}
</div>
<div className={styles['turn-indicator']}>
Aktueller Spieler: <strong>{currentPlayer.name}</strong> ({game.ballsOnTable} Bälle auf dem Tisch)
</div>
<div className={styles['potted-balls-container']}>
<p className={styles['potted-balls-header']}>Bälle am Ende der Aufnahme:</p>
<div className={styles['potted-balls-grid']}>
{Array.from({ length: 16 }, (_, i) => i).map(num => (
<button
key={num}
onClick={() => handleTurnEnd(num)}
disabled={num > game.ballsOnTable}
className={styles['potted-ball-btn']}
>
{num}
</button>
))}
</div>
</div>
<div className={styles['rerack-controls']}>
<button onClick={() => handleReRack(14)} className={styles['rerack-btn']}>+14 Re-Rack</button>
<button onClick={() => handleReRack(15)} className={styles['rerack-btn']}>+15 Re-Rack</button>
</div>
<div className={styles['foul-controls']}>
<button onClick={() => handleFoul('standard')} className={styles['foul-btn']}>Standard Foul (-1)</button>
<button onClick={() => handleFoul('break')} className={styles['foul-btn']}>Break Foul (-2)</button>
</div>
<GameLog log={game.log} />
<div className={styles['game-detail-controls']}>
<button className="btn" onClick={onUndo} disabled={!game.undoStack || game.undoStack.length === 0}>Undo</button>
<button className="btn btn-danger" onClick={onForfeit}>Forfeit</button>
<button className="btn" onClick={onBack}>Zurück zur Liste</button>
</div>
</div>
);
};
export default GameDetail141;

View File

@@ -0,0 +1,24 @@
/* GameHistory-specific styles only. Shared utility classes are now in global CSS. */
.screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: 100vh;
display: none;
opacity: 0;
transform: translateX(100%);
transition: transform 0.3s ease, opacity 0.3s ease;
}
.screen-content {
display: flex;
flex-direction: column;
min-height: 100vh;
padding: 20px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.screen-title {
font-size: 24px;
margin-bottom: 20px;
}

View File

@@ -0,0 +1,62 @@
import { h } from 'preact';
import styles from './GameList.module.css';
/**
* List of games with filter and delete options.
* @param {object} props
* @param {object[]} props.games
* @param {string} props.filter
* @param {Function} props.setFilter
* @param {Function} props.onShowGameDetail
* @param {Function} props.onDeleteGame
* @returns {import('preact').VNode}
*/
const GameList = ({ games, filter = 'all', setFilter, onShowGameDetail, onDeleteGame }) => {
// Filter and sort games
const filteredGames = games
.filter(game => {
if (filter === 'active') return game.status === 'active';
if (filter === 'completed') return game.status === 'completed';
return true;
})
.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));
return (
<div className={styles['game-list'] + ' ' + styles['games-container']}>
<div className={styles['filter-buttons']}>
<button className={styles['filter-button'] + (filter === 'all' ? ' ' + styles['active'] : '')} onClick={() => setFilter('all')} aria-label="Alle Spiele anzeigen">Alle</button>
<button className={styles['filter-button'] + (filter === 'active' ? ' ' + styles['active'] : '')} onClick={() => setFilter('active')} aria-label="Nur aktive Spiele anzeigen">Aktiv</button>
<button className={styles['filter-button'] + (filter === 'completed' ? ' ' + styles['active'] : '')} onClick={() => setFilter('completed')} aria-label="Nur abgeschlossene Spiele anzeigen">Abgeschlossen</button>
</div>
{filteredGames.length === 0 ? (
<div className={styles['empty-state']}>Keine Spiele vorhanden</div>
) : (
filteredGames.map(game => {
const playerNames = game.player3
? `${game.player1} vs ${game.player2} vs ${game.player3}`
: `${game.player1} vs ${game.player2}`;
const scores = game.player3
? `${game.score1} - ${game.score2} - ${game.score3}`
: `${game.score1} - ${game.score2}`;
return (
<div
className={
styles['game-item'] + ' ' + (game.status === 'completed' ? styles['completed'] : styles['active'])
}
key={game.id}
>
<div className={styles['game-info']} onClick={() => onShowGameDetail(game.id)} role="button" tabIndex={0} aria-label={`Details für Spiel ${playerNames}`}>
<div className={styles['game-type']}>{game.gameType}{game.raceTo ? ` | ${game.raceTo}` : ''}</div>
<div className={styles['player-names']}>{playerNames}</div>
<div className={styles['game-scores']}>{scores}</div>
</div>
<button className={styles['delete-button']} onClick={() => onDeleteGame(game.id)} aria-label={`Spiel löschen: ${playerNames}`}></button>
</div>
);
})
)}
</div>
);
};
export default GameList;

View File

@@ -0,0 +1,135 @@
/* GameList-specific styles only. Shared utility classes are now in global CSS. */
.screen.active {
display: block;
opacity: 1;
transform: translateX(0);
position: relative;
}
.screen-content {
display: flex;
flex-direction: column;
min-height: 100vh;
padding: 20px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.screen-title {
font-size: 24px;
margin-bottom: 20px;
}
.game-list {
width: 100%;
flex: 1;
overflow-y: auto;
}
.filter-buttons {
display: flex;
gap: 8px;
margin: 24px 0 16px 0;
}
.filter-button {
flex: 1;
background: #333;
color: #fff;
border: none;
border-radius: 0;
font-size: 1.2rem;
padding: 18px 0;
cursor: pointer;
font-weight: 500;
transition: background 0.2s, color 0.2s;
}
.filter-button.active {
background: #4CAF50;
color: #fff;
}
.games-container {
width: 100%;
display: flex;
flex-direction: column;
gap: 16px;
margin-top: 24px;
}
.game-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1.5rem;
border-radius: 0.5rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
transition: transform 0.1s ease, background-color 0.2s ease;
cursor: pointer;
}
.game-item.active {
background: #1e4620;
}
.game-item.completed {
background: #333;
opacity: 0.85;
}
.game-info {
flex: 1;
display: flex;
align-items: center;
gap: 2rem;
}
.game-type {
font-weight: bold;
font-size: 1.5rem;
min-width: 8rem;
color: #fff;
}
.player-names {
color: #fff;
font-size: 1.5rem;
min-width: 16rem;
}
.game-scores {
font-size: 2rem;
font-weight: bold;
min-width: 6rem;
text-align: center;
color: #fff;
}
.delete-button {
width: 3rem;
height: 3rem;
border: none;
background: #ff4444;
color: white;
border-radius: 50%;
font-size: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
margin-left: 1rem;
transition: background-color 0.2s;
position: relative;
}
.delete-button::before {
content: '\1F5D1'; /* 🗑️ */
font-size: 1.5rem;
}
.delete-button:hover {
background: #cc0000;
}
.delete-button:active {
transform: scale(0.95);
}
.empty-state {
text-align: center;
padding: 2rem;
color: #666;
font-size: 1.5rem;
}
.page-header {
font-size: 2rem;
font-weight: 700;
color: #fff;
background: #181818;
padding: 24px 0 16px 0;
margin-bottom: 8px;
text-align: left;
width: 100%;
letter-spacing: 0.5px;
}

35
src/components/Modal.jsx Normal file
View File

@@ -0,0 +1,35 @@
import { h } from 'preact';
import styles from './Modal.module.css';
/**
* Generic modal dialog for confirmation.
* @param {object} props
* @param {boolean} props.open
* @param {string} props.title
* @param {string} props.message
* @param {Function} props.onCancel
* @param {Function} props.onConfirm
* @returns {import('preact').VNode|null}
*/
const Modal = ({ open, title, message, onCancel, onConfirm }) => {
if (!open) return null;
return (
<div className={styles['modal'] + ' ' + styles['show']} role="dialog" aria-modal="true" aria-labelledby="modal-title">
<div className={styles['modal-content']}>
<div className={styles['modal-header']}>
<span className={styles['modal-title']} id="modal-title">{title}</span>
<button className={styles['close-button']} onClick={onCancel} aria-label="Schließen">×</button>
</div>
<div className={styles['modal-body']}>
<div className={styles['modal-message']}>{message}</div>
</div>
<div className={styles['modal-footer']}>
<button className={styles['modal-button'] + ' ' + styles['cancel']} onClick={onCancel} aria-label="Abbrechen">Abbrechen</button>
<button className={styles['modal-button'] + ' ' + styles['confirm']} onClick={onConfirm} aria-label="Löschen">Löschen</button>
</div>
</div>
</div>
);
};
export default Modal;

View File

@@ -0,0 +1,66 @@
/* Consolidated modal styles for all modals */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 1000;
}
.modal.show {
display: flex;
justify-content: center;
align-items: center;
}
.modal-content {
background-color: #2a2a2a;
padding: 20px;
border-radius: 10px;
width: 90%;
max-width: 500px;
position: relative;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.close-button {
font-size: 24px;
cursor: pointer;
color: #888;
background: none;
border: none;
}
.close-button:hover {
color: white;
}
.modal-body {
margin-bottom: 20px;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
}
.modal-button {
padding: 8px 16px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.modal-button.cancel {
background-color: #444;
color: white;
}
.modal-button.confirm {
background-color: #e74c3c;
color: white;
}
.modal-button:hover {
opacity: 0.9;
}

648
src/components/NewGame.jsx Normal file
View File

@@ -0,0 +1,648 @@
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 }) => (
<div className={modalStyles.modalOverlay} onClick={onClose}>
<div className={modalStyles.modalContent} onClick={e => e.stopPropagation()}>
<div className={modalStyles.modalHeader}>
<h3>Alle Spieler</h3>
<button className={modalStyles.closeButton} onClick={onClose}>×</button>
</div>
<div className={modalStyles.playerList}>
{players.map(player => (
<button key={player} className={modalStyles.playerItem} onClick={() => onSelect(player)}>
{player}
</button>
))}
</div>
</div>
</div>
);
/**
* Player 1 input step for multi-step game creation wizard.
* @param {object} props
* @param {string[]} props.playerNameHistory
* @param {Function} props.onNext
* @param {Function} props.onCancel
* @param {string} [props.initialValue]
* @returns {import('preact').VNode}
*/
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(() => {
if (!player1) {
setFilteredNames(playerNameHistory);
} else {
setFilteredNames(
playerNameHistory.filter(name =>
name.toLowerCase().includes(player1.toLowerCase())
)
);
}
}, [player1, playerNameHistory]);
const handleSubmit = (e) => {
e.preventDefault();
if (!player1.trim()) {
setError('Bitte Namen für Spieler 1 eingeben');
return;
}
setError(null);
onNext(player1.trim());
};
const handleQuickPick = (name) => {
setError(null);
onNext(name);
};
const handleModalSelect = (name) => {
setIsModalOpen(false);
handleQuickPick(name);
};
const handleClear = () => {
setPlayer1('');
setError(null);
if (inputRef.current) inputRef.current.focus();
};
return (
<form className={styles['new-game-form']} onSubmit={handleSubmit} aria-label="Spieler 1 Eingabe" autoComplete="off">
<div className={styles['screen-title']}>Neues Spiel Schritt 1/5</div>
<div className={styles['progress-indicator']} style={{ marginBottom: 24 }}>
<span className={styles['progress-dot'] + ' ' + styles['active']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
</div>
<div className={styles['player-input']} style={{ marginBottom: 32, position: 'relative' }}>
<label htmlFor="player1-input" style={{ fontSize: '1.3rem', fontWeight: 600 }}>Spieler 1</label>
<div style={{ position: 'relative', width: '100%' }}>
<input
id="player1-input"
className={styles['name-input']}
placeholder="Name Spieler 1"
value={player1}
onInput={e => setPlayer1(e.target.value)}
autoFocus
autoComplete="off"
aria-label="Name Spieler 1"
style={{ fontSize: '1.2rem', minHeight: 48, marginTop: 12, marginBottom: 12, width: '100%', paddingRight: 44 }}
ref={inputRef}
/>
{player1 && (
<button
type="button"
className={styles['clear-input-btn']}
aria-label="Feld leeren"
onClick={handleClear}
style={{
position: 'absolute',
right: 8,
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
cursor: 'pointer',
fontSize: 24,
color: '#aaa',
padding: 0,
zIndex: 2
}}
tabIndex={0}
>
{/* Unicode heavy multiplication X */}
×
</button>
)}
</div>
{filteredNames.length > 0 && (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, marginTop: 8 }}>
{filteredNames.slice(0, 10).map((name, idx) => (
<button
type="button"
key={name + idx}
className={styles['quick-pick-btn']}
style={{ fontSize: '1.1rem', padding: '12px 20px', borderRadius: 8, background: '#333', color: '#fff', border: 'none', cursor: 'pointer' }}
onClick={() => handleQuickPick(name)}
aria-label={`Schnellauswahl: ${name}`}
>
{name}
</button>
))}
{playerNameHistory.length > 10 && (
<button
type="button"
className={styles['quick-pick-btn']}
style={{ fontSize: '1.1rem', padding: '12px 20px', borderRadius: 8, background: '#333', color: '#fff', border: 'none', cursor: 'pointer' }}
onClick={() => setIsModalOpen(true)}
aria-label="Weitere Spieler anzeigen"
>
...
</button>
)}
</div>
)}
</div>
{error && <div className={styles['validation-error']} style={{ marginBottom: 16 }}>{error}</div>}
{isModalOpen && (
<PlayerSelectModal
players={playerNameHistory}
onSelect={handleModalSelect}
onClose={() => setIsModalOpen(false)}
/>
)}
<div className={styles['arrow-nav']} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 48 }}>
<button
type="button"
className={styles['arrow-btn']}
aria-label="Zurück"
onClick={onCancel}
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
{/* Unicode left arrow */}
&#8592;
</button>
<button
type="submit"
className={styles['arrow-btn']}
aria-label="Weiter"
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
{/* Unicode right arrow */}
&#8594;
</button>
</div>
</form>
);
};
/**
* Player 2 input step for multi-step game creation wizard.
* @param {object} props
* @param {string[]} props.playerNameHistory
* @param {Function} props.onNext
* @param {Function} props.onCancel
* @param {string} [props.initialValue]
* @returns {import('preact').VNode}
*/
const Player2Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) => {
const [player2, setPlayer2] = useState(initialValue);
const [error, setError] = useState(null);
const [filteredNames, setFilteredNames] = useState(playerNameHistory);
const inputRef = useRef(null);
useEffect(() => {
if (!player2) {
setFilteredNames(playerNameHistory);
} else {
setFilteredNames(
playerNameHistory.filter(name =>
name.toLowerCase().includes(player2.toLowerCase())
)
);
}
}, [player2, playerNameHistory]);
const handleSubmit = (e) => {
e.preventDefault();
if (!player2.trim()) {
setError('Bitte Namen für Spieler 2 eingeben');
return;
}
setError(null);
onNext(player2.trim());
};
const handleQuickPick = (name) => {
setError(null);
onNext(name);
};
const handleClear = () => {
setPlayer2('');
setError(null);
if (inputRef.current) inputRef.current.focus();
};
return (
<form className={styles['new-game-form']} onSubmit={handleSubmit} aria-label="Spieler 2 Eingabe" autoComplete="off">
<div className={styles['screen-title']}>Neues Spiel Schritt 2/5</div>
<div className={styles['progress-indicator']} style={{ marginBottom: 24 }}>
<span className={styles['progress-dot']} />
<span className={styles['progress-dot'] + ' ' + styles['active']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
</div>
<div className={styles['player-input']} style={{ marginBottom: 32, position: 'relative' }}>
<label htmlFor="player2-input" style={{ fontSize: '1.3rem', fontWeight: 600 }}>Spieler 2</label>
<div style={{ position: 'relative', width: '100%' }}>
<input
id="player2-input"
className={styles['name-input']}
placeholder="Name Spieler 2"
value={player2}
onInput={e => setPlayer2(e.target.value)}
autoFocus
autoComplete="off"
aria-label="Name Spieler 2"
style={{ fontSize: '1.2rem', minHeight: 48, marginTop: 12, marginBottom: 12, width: '100%', paddingRight: 44 }}
ref={inputRef}
/>
{player2 && (
<button
type="button"
className={styles['clear-input-btn']}
aria-label="Feld leeren"
onClick={handleClear}
style={{
position: 'absolute',
right: 8,
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
cursor: 'pointer',
fontSize: 24,
color: '#aaa',
padding: 0,
zIndex: 2
}}
tabIndex={0}
>
×
</button>
)}
</div>
{filteredNames.length > 0 && (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, marginTop: 8 }}>
{filteredNames.slice(0, 10).map((name, idx) => (
<button
type="button"
key={name + idx}
className={styles['quick-pick-btn']}
style={{ fontSize: '1.1rem', padding: '12px 20px', borderRadius: 8, background: '#333', color: '#fff', border: 'none', cursor: 'pointer' }}
onClick={() => handleQuickPick(name)}
aria-label={`Schnellauswahl: ${name}`}
>
{name}
</button>
))}
</div>
)}
</div>
{error && <div className={styles['validation-error']} style={{ marginBottom: 16 }}>{error}</div>}
<div className={styles['arrow-nav']} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 48 }}>
<button
type="button"
className={styles['arrow-btn']}
aria-label="Zurück"
onClick={onCancel}
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
&#8592;
</button>
<button
type="submit"
className={styles['arrow-btn']}
aria-label="Weiter"
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
&#8594;
</button>
</div>
</form>
);
};
/**
* Player 3 input step for multi-step game creation wizard.
* @param {object} props
* @param {string[]} props.playerNameHistory
* @param {Function} props.onNext
* @param {Function} props.onCancel
* @param {string} [props.initialValue]
* @returns {import('preact').VNode}
*/
const Player3Step = ({ playerNameHistory, onNext, onCancel, initialValue = '' }) => {
const [player3, setPlayer3] = useState(initialValue);
const [filteredNames, setFilteredNames] = useState(playerNameHistory);
const inputRef = useRef(null);
useEffect(() => {
if (!player3) {
setFilteredNames(playerNameHistory);
} else {
setFilteredNames(
playerNameHistory.filter(name =>
name.toLowerCase().includes(player3.toLowerCase())
)
);
}
}, [player3, playerNameHistory]);
const handleSubmit = (e) => {
e.preventDefault();
// Player 3 is optional, so always allow submission
onNext(player3.trim());
};
const handleQuickPick = (name) => {
onNext(name);
};
const handleClear = () => {
setPlayer3('');
if (inputRef.current) inputRef.current.focus();
};
const handleSkip = (e) => {
e.preventDefault();
onNext('');
};
return (
<form className={styles['new-game-form']} onSubmit={handleSubmit} aria-label="Spieler 3 Eingabe" autoComplete="off">
<div className={styles['screen-title']}>Neues Spiel Schritt 3/5</div>
<div className={styles['progress-indicator']} style={{ marginBottom: 24 }}>
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot'] + ' ' + styles['active']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
</div>
<div className={styles['player-input']} style={{ marginBottom: 32, position: 'relative' }}>
<label htmlFor="player3-input" style={{ fontSize: '1.3rem', fontWeight: 600 }}>Spieler 3 (optional)</label>
<div style={{ position: 'relative', width: '100%' }}>
<input
id="player3-input"
className={styles['name-input']}
placeholder="Name Spieler 3 (optional)"
value={player3}
onInput={e => setPlayer3(e.target.value)}
autoFocus
autoComplete="off"
aria-label="Name Spieler 3"
style={{ fontSize: '1.2rem', minHeight: 48, marginTop: 12, marginBottom: 12, width: '100%', paddingRight: 44 }}
ref={inputRef}
/>
{player3 && (
<button
type="button"
className={styles['clear-input-btn']}
aria-label="Feld leeren"
onClick={handleClear}
style={{
position: 'absolute',
right: 8,
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
cursor: 'pointer',
fontSize: 24,
color: '#aaa',
padding: 0,
zIndex: 2
}}
tabIndex={0}
>
×
</button>
)}
</div>
{filteredNames.length > 0 && (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, marginTop: 8 }}>
{filteredNames.slice(0, 10).map((name, idx) => (
<button
type="button"
key={name + idx}
className={styles['quick-pick-btn']}
style={{ fontSize: '1.1rem', padding: '12px 20px', borderRadius: 8, background: '#333', color: '#fff', border: 'none', cursor: 'pointer' }}
onClick={() => handleQuickPick(name)}
aria-label={`Schnellauswahl: ${name}`}
>
{name}
</button>
))}
</div>
)}
</div>
<div className={styles['arrow-nav']} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 48 }}>
<button
type="button"
className={styles['arrow-btn']}
aria-label="Zurück"
onClick={onCancel}
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
&#8592;
</button>
<div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
<button
type="button"
onClick={handleSkip}
className={styles['quick-pick-btn']}
style={{ fontSize: '1.1rem', padding: '12px 20px', borderRadius: 8, background: '#333', color: '#fff', border: 'none', cursor: 'pointer' }}
>
Überspringen
</button>
<button
type="submit"
className={styles['arrow-btn']}
aria-label="Weiter"
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
&#8594;
</button>
</div>
</div>
</form>
);
};
/**
* Game Type selection step for multi-step game creation wizard.
* @param {object} props
* @param {Function} props.onNext
* @param {Function} props.onCancel
* @param {string} [props.initialValue]
* @returns {import('preact').VNode}
*/
const GameTypeStep = ({ onNext, onCancel, initialValue = '' }) => {
const [gameType, setGameType] = useState(initialValue);
const gameTypes = ['8-Ball', '9-Ball', '10-Ball', '14/1 endlos'];
const handleSelect = (selectedType) => {
setGameType(selectedType);
};
const handleSubmit = (e) => {
e.preventDefault();
if (gameType) {
onNext(gameType);
}
};
return (
<form className={styles['new-game-form']} onSubmit={handleSubmit} aria-label="Spielart auswählen">
<div className={styles['screen-title']}>Neues Spiel Schritt 4/5</div>
<div className={styles['progress-indicator']} style={{ marginBottom: 24 }}>
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot'] + ' ' + styles['active']} />
<span className={styles['progress-dot']} />
</div>
<div className={styles['game-type-selection']}>
{gameTypes.map(type => (
<button
key={type}
type="button"
className={`${styles['game-type-btn']} ${gameType === type ? styles.selected : ''}`}
onClick={() => handleSelect(type)}
>
{type}
</button>
))}
</div>
<div className={styles['arrow-nav']} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 48 }}>
<button
type="button"
className={styles['arrow-btn']}
aria-label="Zurück"
onClick={onCancel}
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
{/* Unicode left arrow */}
&#8592;
</button>
<button
type="submit"
className={styles['arrow-btn']}
aria-label="Weiter"
disabled={!gameType}
style={{
fontSize: 48,
width: 80,
height: 80,
borderRadius: '50%',
background: '#222',
color: '#fff',
border: 'none',
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
cursor: 'pointer',
opacity: !gameType ? 0.5 : 1,
}}
>
{/* Unicode right arrow */}
&#8594;
</button>
</div>
</form>
);
};
/**
* Race To selection step for multi-step game creation wizard.
* @param {object} props
* @param {Function} props.onNext
* @param {Function} props.onCancel
* @param {string|number} [props.initialValue]
* @returns {import('preact').VNode}
*/
const RaceToStep = ({ onNext, onCancel, initialValue = '' }) => {
const [raceTo, setRaceTo] = useState(initialValue);
const quickPicks = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const handleQuickPick = (value) => {
setRaceTo(value);
};
const handleInputChange = (e) => {
setRaceTo(e.target.value);
};
const handleSubmit = (e) => {
e.preventDefault();
onNext(parseInt(raceTo, 10) || 0);
};
return (
<form className={styles['new-game-form']} onSubmit={handleSubmit} aria-label="Race To auswählen">
<div className={styles['screen-title']}>Neues Spiel Schritt 5/5</div>
<div className={styles['progress-indicator']} style={{ marginBottom: 24 }}>
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot']} />
<span className={styles['progress-dot'] + ' ' + styles['active']} />
</div>
<div className={styles['endlos-container']}>
<button
type="button"
className={`${styles['race-to-btn']} ${styles['endlos-btn']} ${raceTo === 0 ? styles.selected : ''}`}
onClick={() => handleQuickPick(0)}
>
Endlos
</button>
</div>
<div className={styles['race-to-selection']}>
{quickPicks.map(value => (
<button
key={value}
type="button"
className={`${styles['race-to-btn']} ${parseInt(raceTo, 10) === value ? styles.selected : ''}`}
onClick={() => handleQuickPick(value)}
>
{value}
</button>
))}
</div>
<div className={styles['custom-race-to']}>
<input
type="number"
pattern="[0-9]*"
value={raceTo}
onInput={handleInputChange}
className={styles['name-input']}
placeholder="manuelle Eingabe"
/>
</div>
<div className={styles['arrow-nav']} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 48 }}>
<button
type="button"
className={styles['arrow-btn']}
aria-label="Zurück"
onClick={onCancel}
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
{/* Unicode left arrow */}
&#8592;
</button>
<button
type="submit"
className={styles['arrow-btn']}
aria-label="Fertigstellen"
style={{ fontSize: 48, width: 80, height: 80, borderRadius: '50%', background: '#222', color: '#fff', border: 'none', boxShadow: '0 2px 8px rgba(0,0,0,0.15)', cursor: 'pointer' }}
>
{/* Unicode checkmark */}
&#10003;
</button>
</div>
</form>
);
};
export { Player1Step, Player2Step, Player3Step, GameTypeStep, RaceToStep };

View File

@@ -0,0 +1,277 @@
/* NewGame-specific styles only. Shared utility classes are now in global CSS. */
.screen {
position: absolute;
top: 0;
left: 0;
width: 100%;
min-height: 100vh;
display: none;
opacity: 0;
transform: translateX(100%);
transition: transform 0.3s ease, opacity 0.3s ease;
}
.screen-content {
display: flex;
flex-direction: column;
min-height: 100vh;
padding: 20px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
.screen-title {
font-size: 2rem;
font-weight: 700;
color: #fff;
margin-bottom: 32px;
letter-spacing: 0.5px;
}
.player-inputs {
display: flex;
flex-direction: column;
gap: 24px;
width: 100%;
margin-bottom: 32px;
}
.player-input {
background: #222;
border-radius: 8px;
padding: 20px 16px 16px 16px;
margin-bottom: 0;
box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.player-input label {
display: block;
margin-bottom: 12px;
color: #ccc;
font-size: 1.2rem;
font-weight: 600;
}
.name-input-container {
display: flex;
gap: 12px;
}
.name-input {
flex: 2;
padding: 14px 12px;
border: 2px solid #333;
background: #2a2a2a;
color: white;
font-size: 1.1rem;
min-height: 44px;
border-radius: 0 6px 6px 0;
}
.game-settings {
margin-top: 0;
width: 100%;
margin-bottom: 32px;
}
.setting-group {
margin-bottom: 20px;
}
.setting-group label {
display: block;
margin-bottom: 10px;
color: #ccc;
font-size: 1.1rem;
font-weight: 600;
}
.setting-group select, .setting-group input {
width: 100%;
padding: 14px 12px;
border: 2px solid #333;
background: #2a2a2a;
color: white;
font-size: 1.1rem;
min-height: 44px;
border-radius: 6px;
}
.setting-group input:focus, .setting-group select:focus {
outline: none;
border-color: #666;
}
.validation-error {
color: #f44336;
background: #2a2a2a;
border-radius: 6px;
padding: 12px;
margin-bottom: 16px;
font-size: 1.1rem;
text-align: center;
}
.new-game-form {
width: 100%;
max-width: 700px;
margin: 32px auto 0 auto;
background: #181818;
border-radius: 12px;
box-shadow: 0 2px 16px rgba(0,0,0,0.4);
padding: 32px 24px 24px 24px;
display: flex;
flex-direction: column;
gap: 0;
}
.progress-indicator {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-bottom: 16px;
}
.progress-dot {
width: 14px;
height: 14px;
border-radius: 50%;
background: #444;
opacity: 0.4;
transition: background 0.2s, opacity 0.2s;
}
.progress-dot.active {
background: #fff;
opacity: 1;
}
.quick-pick-btn {
min-width: 80px;
min-height: 44px;
font-size: 1.1rem;
border-radius: 8px;
background: #333;
color: #fff;
border: none;
cursor: pointer;
margin-bottom: 8px;
transition: background 0.2s;
}
.quick-pick-btn:active, .quick-pick-btn:focus {
background: #555;
outline: none;
}
.arrow-nav {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 48px;
width: 100%;
}
.arrow-btn {
font-size: 48px;
width: 80px;
height: 80px;
border-radius: 50%;
background: #222;
color: #fff;
border: none;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.2s, color 0.2s;
}
.arrow-btn:active, .arrow-btn:focus {
background: #444;
color: #fff;
outline: none;
}
.clear-input-btn {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
cursor: pointer;
font-size: 24px;
color: #aaa;
padding: 0;
z-index: 2;
}
.clear-input-btn:active, .clear-input-btn:focus {
color: #fff;
outline: none;
}
.game-type-selection {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
width: 100%;
margin: 16px 0;
}
.game-type-btn {
background: #2a2a2a;
border: 2px solid #333;
color: #fff;
font-size: 1.4rem;
font-weight: 600;
padding: 24px;
border-radius: 8px;
cursor: pointer;
text-align: center;
transition: background 0.2s, border-color 0.2s;
}
.game-type-btn:hover {
background: #333;
border-color: #555;
}
.game-type-btn.selected {
background: #4a4a4a;
border-color: #777;
}
.race-to-selection {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
gap: 12px;
width: 100%;
margin: 16px 0;
}
.race-to-btn {
background: #2a2a2a;
border: 2px solid #333;
color: #fff;
font-size: 1.3rem;
font-weight: 600;
padding: 16px 8px;
border-radius: 8px;
cursor: pointer;
text-align: center;
transition: background 0.2s, border-color 0.2s;
min-height: 70px;
}
.race-to-btn:hover {
background: #333;
border-color: #555;
}
.race-to-btn.selected {
background: #4a4a4a;
border-color: #777;
}
.custom-race-to {
display: flex;
gap: 12px;
margin-top: 24px;
align-items: center;
}
.custom-race-to input {
flex-grow: 1;
}
.custom-race-to .arrow-btn {
width: 60px;
height: 60px;
font-size: 32px;
flex-shrink: 0;
}
.endlos-container {
width: 100%;
margin-bottom: 12px;
}
.endlos-btn {
width: 100%;
}

View File

@@ -0,0 +1,70 @@
.modalOverlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modalContent {
background: #2c2c2c;
padding: 24px;
border-radius: 12px;
width: 90%;
max-width: 400px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: column;
}
.modalHeader {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.modalHeader h3 {
margin: 0;
font-size: 1.5rem;
color: #fff;
}
.closeButton {
background: none;
border: none;
font-size: 2rem;
color: #aaa;
cursor: pointer;
padding: 0;
line-height: 1;
}
.playerList {
max-height: 60vh;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 12px;
}
.playerItem {
background: #444;
color: #fff;
border: none;
padding: 16px;
border-radius: 8px;
text-align: left;
font-size: 1.2rem;
cursor: pointer;
transition: background-color 0.2s;
}
.playerItem:hover {
background: #555;
}

View File

@@ -0,0 +1,32 @@
import { h } from 'preact';
import styles from './Modal.module.css';
/**
* Modal for displaying validation errors.
* @param {object} props
* @param {boolean} props.open
* @param {string} props.message
* @param {Function} props.onClose
* @returns {import('preact').VNode|null}
*/
const ValidationModal = ({ open, message, onClose }) => {
if (!open) return null;
return (
<div className={styles['modal'] + ' ' + styles['show']} id="validation-modal" role="alertdialog" aria-modal="true" aria-labelledby="validation-modal-title">
<div className={styles['modal-content']}>
<div className={styles['modal-header']}>
<span className={styles['modal-title']} id="validation-modal-title">Fehler</span>
<button className={styles['close-button']} onClick={onClose} aria-label="Schließen">×</button>
</div>
<div className={styles['modal-body']}>
<div className={styles['modal-message']}>{message}</div>
</div>
<div className={styles['modal-footer']}>
<button className={styles['modal-button'] + ' ' + styles['cancel']} onClick={onClose} aria-label="OK">OK</button>
</div>
</div>
</div>
);
};
export default ValidationModal;

File diff suppressed because it is too large Load Diff

99
src/styles/index.css Normal file
View File

@@ -0,0 +1,99 @@
/* Global resets and utility styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
body {
font-family: Arial, sans-serif;
background-color: #1a1a1a;
color: white;
min-height: 100vh;
overscroll-behavior: none;
}
input, select {
min-height: 44px;
padding: 12px;
font-size: 1.2rem;
}
/* Responsive adjustments for fullscreen toggle button */
@media screen and (max-width: 480px) {
.fullscreenToggle {
bottom: 15px;
right: 15px;
width: 40px;
height: 40px;
}
}
/* Utility button for new game (global, not component-specific) */
.new-game-button {
width: 100%;
background: #222;
color: #fff;
border: none;
border-radius: 0;
font-size: 1.4rem;
font-weight: 600;
padding: 20px 0;
margin-bottom: 16px;
cursor: pointer;
transition: background 0.2s, color 0.2s;
text-align: center;
display: block;
}
.new-game-button:hover {
background: #333;
}
/* Shared utility classes for buttons and layout */
.btn {
flex: 1;
min-width: 100px;
padding: 18px;
color: white;
background: #333;
border: none;
border-radius: 6px;
font-size: 1.2rem;
font-weight: 600;
cursor: pointer;
touch-action: manipulation;
transition: background 0.2s, color 0.2s;
}
.btn:hover {
background: #444;
}
.nav-buttons {
display: flex;
flex-direction: column;
gap: 12px;
margin: 16px 0 0 0;
}
/* Modal overlay (global, not component-specific) */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
}
.modal.show {
display: flex;
}

View File

@@ -1,5 +1,14 @@
{ {
"extends": "astro/tsconfigs/strict", "extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"], "include": [
"exclude": ["dist"] ".astro/types.d.ts",
"**/*"
],
"exclude": [
"dist"
],
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
} }