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
This commit is contained in:
Frank Schwenk
2025-06-06 11:58:29 +02:00
parent de07d6e7a2
commit 8384d08393
31 changed files with 1901 additions and 1891 deletions

View File

@@ -0,0 +1,38 @@
import { h } from 'preact';
import styles from './GameCompletionModal.module.css';
export default function GameCompletionModal({ open, game, onConfirm, onClose }) {
if (!open || !game) return null;
const playerNames = [game.player1, game.player2, game.player3].filter(Boolean);
const scores = [game.score1, game.score2, game.score3].filter((_, i) => playerNames[i]);
const maxScore = Math.max(...scores);
const winners = playerNames.filter((name, idx) => scores[idx] === maxScore);
const winnerText = winners.length > 1
? `Unentschieden zwischen ${winners.join(' und ')}`
: `${winners[0]} hat gewonnen!`;
return (
<div className={styles['modal'] + ' ' + styles['show']} id="game-completion-modal">
<div className={styles['modal-content']}>
<div className={styles['modal-header']}>
<span className={styles['modal-title']}>Spiel beendet</span>
<button className={styles['close-button']} onClick={onClose}>×</button>
</div>
<div className={styles['modal-body']}>
<div className={styles['final-scores']}>
{playerNames.map((name, idx) => (
<div className={styles['final-score']} key={name}>
<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>
</div>
<div className={styles['modal-footer']}>
<button className={styles['btn'] + ' ' + styles['btn--warning']} onClick={onConfirm}>Bestätigen</button>
<button className={styles['btn']} onClick={onClose}>Abbrechen</button>
</div>
</div>
</div>
);
}