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:
@@ -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()]
|
||||||
|
});
|
||||||
862
package-lock.json
generated
862
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,8 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "^5.9.0"
|
"@astrojs/preact": "^4.1.0",
|
||||||
|
"astro": "^5.9.0",
|
||||||
|
"preact": "^10.26.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,423 +0,0 @@
|
|||||||
// src/scripts/index.js
|
|
||||||
// Modularized logic from original index.astro
|
|
||||||
|
|
||||||
// --- State ---
|
|
||||||
let games = [];
|
|
||||||
let currentGameId = null;
|
|
||||||
let playerNameHistory = [];
|
|
||||||
|
|
||||||
// --- DOM Selectors ---
|
|
||||||
const screens = {
|
|
||||||
'new-game-screen': document.getElementById('new-game-screen'),
|
|
||||||
'game-list-screen': document.getElementById('game-list-screen'),
|
|
||||||
'game-detail-screen': document.getElementById('game-detail-screen'),
|
|
||||||
'game-history-screen': document.getElementById('game-history-screen')
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Screen Management ---
|
|
||||||
function showScreen(screenId) {
|
|
||||||
const currentScreen = document.querySelector('.screen.active');
|
|
||||||
const newScreen = document.getElementById(screenId);
|
|
||||||
if (currentScreen) {
|
|
||||||
currentScreen.classList.remove('active');
|
|
||||||
currentScreen.classList.add('slide-out');
|
|
||||||
setTimeout(() => {
|
|
||||||
currentScreen.classList.remove('slide-out');
|
|
||||||
newScreen.classList.add('active');
|
|
||||||
newScreen.classList.add('slide-in');
|
|
||||||
setTimeout(() => {
|
|
||||||
newScreen.classList.remove('slide-in');
|
|
||||||
}, 300);
|
|
||||||
}, 300);
|
|
||||||
} else {
|
|
||||||
newScreen.classList.add('active');
|
|
||||||
}
|
|
||||||
if (screenId === 'new-game-screen') {
|
|
||||||
updateNameHistory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Loading Overlay ---
|
|
||||||
function showLoading() {
|
|
||||||
document.querySelector('.loading-overlay').style.display = 'block';
|
|
||||||
document.querySelector('.loading-indicator').style.display = 'block';
|
|
||||||
}
|
|
||||||
function hideLoading() {
|
|
||||||
document.querySelector('.loading-overlay').style.display = 'none';
|
|
||||||
document.querySelector('.loading-indicator').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Data Management ---
|
|
||||||
function loadGames() {
|
|
||||||
const savedGames = localStorage.getItem('bscscore_games');
|
|
||||||
if (savedGames) {
|
|
||||||
games = JSON.parse(savedGames);
|
|
||||||
renderGames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function saveGames() {
|
|
||||||
localStorage.setItem('bscscore_games', JSON.stringify(games));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Player Name History ---
|
|
||||||
function updateNameHistory() {
|
|
||||||
const allNames = games.flatMap(game => [game.player1, game.player2, game.player3].filter(Boolean));
|
|
||||||
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());
|
|
||||||
});
|
|
||||||
playerNameHistory = [...new Set(Object.keys(nameLastUsed))].sort((a, b) => nameLastUsed[b] - nameLastUsed[a]);
|
|
||||||
updateNameSelects();
|
|
||||||
}
|
|
||||||
function updateNameSelects() {
|
|
||||||
const player1Select = document.getElementById('player1-select');
|
|
||||||
const player2Select = document.getElementById('player2-select');
|
|
||||||
const player3Select = document.getElementById('player3-select');
|
|
||||||
while (player1Select.options.length > 1) player1Select.remove(1);
|
|
||||||
while (player2Select.options.length > 1) player2Select.remove(1);
|
|
||||||
while (player3Select.options.length > 1) player3Select.remove(1);
|
|
||||||
playerNameHistory.forEach(name => {
|
|
||||||
const option1 = new Option(name, name);
|
|
||||||
const option2 = new Option(name, name);
|
|
||||||
const option3 = new Option(name, name);
|
|
||||||
player1Select.add(option1);
|
|
||||||
player2Select.add(option2);
|
|
||||||
player3Select.add(option3);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function updatePlayerInput(playerId) {
|
|
||||||
const select = document.getElementById(`${playerId}-select`);
|
|
||||||
const input = document.getElementById(playerId);
|
|
||||||
if (select.value) {
|
|
||||||
input.value = select.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Validation Modal ---
|
|
||||||
function showValidationModal(message) {
|
|
||||||
const modal = document.getElementById('validation-modal');
|
|
||||||
const modalMessage = document.getElementById('validation-modal-message');
|
|
||||||
modalMessage.textContent = message;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeValidationModal() {
|
|
||||||
const modal = document.getElementById('validation-modal');
|
|
||||||
modal.classList.remove('show');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- New Game Creation ---
|
|
||||||
function createNewGame() {
|
|
||||||
const player1Name = document.getElementById('player1').value.trim();
|
|
||||||
const player2Name = document.getElementById('player2').value.trim();
|
|
||||||
const player3Name = document.getElementById('player3').value.trim();
|
|
||||||
const gameType = document.getElementById('game-type').value;
|
|
||||||
const raceTo = document.getElementById('race-to').value;
|
|
||||||
if (!player1Name || !player2Name) {
|
|
||||||
showValidationModal('Bitte Namen für beide Spieler eingeben');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const newGame = {
|
|
||||||
id: Date.now(),
|
|
||||||
player1: player1Name,
|
|
||||||
player2: player2Name,
|
|
||||||
player3: player3Name || null,
|
|
||||||
score1: 0,
|
|
||||||
score2: 0,
|
|
||||||
score3: 0,
|
|
||||||
gameType: gameType,
|
|
||||||
raceTo: raceTo ? parseInt(raceTo) : null,
|
|
||||||
status: 'active',
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
updatedAt: new Date().toISOString()
|
|
||||||
};
|
|
||||||
games.push(newGame);
|
|
||||||
saveGames();
|
|
||||||
updateNameHistory();
|
|
||||||
renderGames();
|
|
||||||
showGameDetail(newGame.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Score Update ---
|
|
||||||
function updateScore(gameId, player, change) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game || game.status === 'completed') return;
|
|
||||||
if (player === 1) {
|
|
||||||
game.score1 = Math.max(0, game.score1 + change);
|
|
||||||
} else if (player === 2) {
|
|
||||||
game.score2 = Math.max(0, game.score2 + change);
|
|
||||||
} else if (player === 3) {
|
|
||||||
game.score3 = Math.max(0, game.score3 + change);
|
|
||||||
}
|
|
||||||
game.updatedAt = new Date().toISOString();
|
|
||||||
if (game.raceTo && (game.score1 >= game.raceTo || game.score2 >= game.raceTo || (game.player3 && game.score3 >= game.raceTo))) {
|
|
||||||
showGameCompletionModal();
|
|
||||||
}
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
if (document.getElementById('game-detail-screen').classList.contains('active')) {
|
|
||||||
document.getElementById('score1').textContent = game.score1;
|
|
||||||
document.getElementById('score2').textContent = game.score2;
|
|
||||||
document.getElementById('score3').textContent = game.score3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Deletion ---
|
|
||||||
function deleteGame(gameId) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game) return;
|
|
||||||
currentGameId = gameId;
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
const modalTitle = document.getElementById('modal-title');
|
|
||||||
const modalMessage = document.getElementById('modal-message');
|
|
||||||
modalTitle.textContent = 'Spiel löschen';
|
|
||||||
modalMessage.textContent = `Möchten Sie das Spiel zwischen ${game.player1} und ${game.player2} wirklich löschen?`;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeModal() {
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
modal.classList.remove('show');
|
|
||||||
currentGameId = null;
|
|
||||||
}
|
|
||||||
function confirmDeleteGame(gameId) {
|
|
||||||
if (!gameId) return;
|
|
||||||
showLoading();
|
|
||||||
setTimeout(() => {
|
|
||||||
const gameIndex = games.findIndex(g => g.id === gameId);
|
|
||||||
if (gameIndex !== -1) {
|
|
||||||
games.splice(gameIndex, 1);
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
if (currentGameId === gameId) {
|
|
||||||
showScreen('game-list-screen');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hideLoading();
|
|
||||||
closeModal();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Rendering ---
|
|
||||||
function renderGames(filter = 'all') {
|
|
||||||
const gamesContainer = document.getElementById('games-container');
|
|
||||||
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));
|
|
||||||
if (filteredGames.length === 0) {
|
|
||||||
gamesContainer.innerHTML = '<div class="empty-state">Keine Spiele vorhanden</div>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gamesContainer.innerHTML = 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 class="game-item ${game.status === 'completed' ? 'completed' : 'active'}">
|
|
||||||
<div class="game-info" onclick="showGameDetail(${game.id})">
|
|
||||||
<div class="game-type">${game.gameType}${game.raceTo ? ` | ${game.raceTo}` : ''}</div>
|
|
||||||
<div class="player-names">${playerNames}</div>
|
|
||||||
<div class="game-scores">${scores}</div>
|
|
||||||
</div>
|
|
||||||
<button class="delete-button" onclick="deleteGame(${game.id})"></button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Detail ---
|
|
||||||
function showGameDetail(gameId) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game) return;
|
|
||||||
currentGameId = gameId;
|
|
||||||
document.getElementById('game-title').textContent = `${game.gameType}${game.raceTo ? ` | Race to ${game.raceTo}` : ''}`;
|
|
||||||
document.getElementById('player1-name').textContent = game.player1;
|
|
||||||
document.getElementById('player2-name').textContent = game.player2;
|
|
||||||
const player3Score = document.getElementById('player3-score');
|
|
||||||
if (game.player3) {
|
|
||||||
document.getElementById('player3-name').textContent = game.player3;
|
|
||||||
document.getElementById('score3').textContent = game.score3;
|
|
||||||
player3Score.style.display = 'flex';
|
|
||||||
} else {
|
|
||||||
player3Score.style.display = 'none';
|
|
||||||
}
|
|
||||||
document.getElementById('score1').textContent = game.score1;
|
|
||||||
document.getElementById('score2').textContent = game.score2;
|
|
||||||
const player1Container = document.querySelector('.player-score:first-child');
|
|
||||||
const player2Container = document.querySelector('.player-score:nth-child(2)');
|
|
||||||
const player3Container = document.getElementById('player3-score');
|
|
||||||
player1Container.classList.toggle('franky', game.player1 === 'Fränky');
|
|
||||||
player2Container.classList.toggle('franky', game.player2 === 'Fränky');
|
|
||||||
player3Container.classList.toggle('franky', game.player3 === 'Fränky');
|
|
||||||
const controlButton = document.getElementById('game-control');
|
|
||||||
if (game.status === 'completed') {
|
|
||||||
controlButton.textContent = 'Zurück zur Liste';
|
|
||||||
controlButton.onclick = () => showScreen('game-list-screen');
|
|
||||||
controlButton.classList.add('disabled');
|
|
||||||
} else {
|
|
||||||
controlButton.textContent = 'Spiel beenden';
|
|
||||||
controlButton.onclick = () => finishGame();
|
|
||||||
controlButton.classList.remove('disabled');
|
|
||||||
}
|
|
||||||
const scoreButtons = document.querySelectorAll('.score-button');
|
|
||||||
scoreButtons.forEach(button => {
|
|
||||||
button.disabled = game.status === 'completed';
|
|
||||||
});
|
|
||||||
showScreen('game-detail-screen');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Completion Modal ---
|
|
||||||
function showGameCompletionModal() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
const modal = document.getElementById('game-completion-modal');
|
|
||||||
const finalScores = modal.querySelector('.final-scores');
|
|
||||||
const winnerAnnouncement = modal.querySelector('.winner-announcement');
|
|
||||||
let scoreHtml = '';
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player1}</span>
|
|
||||||
<span class="score">${game.score1}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player2}</span>
|
|
||||||
<span class="score">${game.score2}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
if (game.player3) {
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player3}</span>
|
|
||||||
<span class="score">${game.score3}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
finalScores.innerHTML = scoreHtml;
|
|
||||||
const scores = [game.score1, game.score2];
|
|
||||||
if (game.player3) scores.push(game.score3);
|
|
||||||
const maxScore = Math.max(...scores);
|
|
||||||
const winners = [];
|
|
||||||
if (game.score1 === maxScore) winners.push(game.player1);
|
|
||||||
if (game.score2 === maxScore) winners.push(game.player2);
|
|
||||||
if (game.player3 && game.score3 === maxScore) winners.push(game.player3);
|
|
||||||
const winnerText = winners.length > 1
|
|
||||||
? `Unentschieden zwischen ${winners.join(' und ')}`
|
|
||||||
: `${winners[0]} hat gewonnen!`;
|
|
||||||
winnerAnnouncement.innerHTML = `<h3>${winnerText}</h3>`;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeGameCompletionModal() {
|
|
||||||
document.getElementById('game-completion-modal').classList.remove('show');
|
|
||||||
}
|
|
||||||
function confirmGameCompletion() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
game.status = 'completed';
|
|
||||||
game.updatedAt = new Date().toISOString();
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
showGameDetail(currentGameId);
|
|
||||||
closeGameCompletionModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Finish ---
|
|
||||||
function finishGame() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
showGameCompletionModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Filter Games ---
|
|
||||||
function filterGames(filter) {
|
|
||||||
document.querySelectorAll('.filter-button').forEach(button => {
|
|
||||||
button.classList.remove('active');
|
|
||||||
});
|
|
||||||
document.querySelector(`.filter-button[onclick=\"filterGames('${filter}')\"]`).classList.add('active');
|
|
||||||
renderGames(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Fullscreen ---
|
|
||||||
function toggleFullscreen() {
|
|
||||||
if (!document.fullscreenElement) {
|
|
||||||
document.documentElement.requestFullscreen().catch(err => {
|
|
||||||
console.log(`Error attempting to enable fullscreen: ${err.message}`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
document.exitFullscreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.addEventListener('fullscreenchange', () => {
|
|
||||||
const button = document.getElementById('fullscreen-toggle');
|
|
||||||
if (document.fullscreenElement) {
|
|
||||||
button.innerHTML = `<svg viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>`;
|
|
||||||
} else {
|
|
||||||
button.innerHTML = `<svg viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Event Listeners ---
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
loadGames();
|
|
||||||
// Attach event listeners for navigation, game creation, modals, etc.
|
|
||||||
document.querySelectorAll('.nav-button').forEach(btn => {
|
|
||||||
if (btn.textContent.includes('Neues Spiel')) btn.onclick = () => showScreen('new-game-screen');
|
|
||||||
if (btn.textContent.includes('Abbrechen')) btn.onclick = () => showScreen('game-list-screen');
|
|
||||||
if (btn.textContent.includes('Zurück zur Liste')) btn.onclick = () => showScreen('game-list-screen');
|
|
||||||
});
|
|
||||||
document.querySelectorAll('.filter-button').forEach((btn, idx) => {
|
|
||||||
if (btn.textContent === 'Alle') btn.onclick = () => filterGames('all');
|
|
||||||
if (btn.textContent === 'Aktiv') btn.onclick = () => filterGames('active');
|
|
||||||
if (btn.textContent === 'Abgeschlossen') btn.onclick = () => filterGames('completed');
|
|
||||||
});
|
|
||||||
// Attach fullscreen toggle event
|
|
||||||
const fullscreenBtn = document.getElementById('fullscreen-toggle');
|
|
||||||
if (fullscreenBtn) fullscreenBtn.addEventListener('click', toggleFullscreen);
|
|
||||||
// Modal buttons
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
if (modal) {
|
|
||||||
modal.querySelector('.close-button').onclick = closeModal;
|
|
||||||
modal.querySelector('.modal-button.cancel').onclick = closeModal;
|
|
||||||
modal.querySelector('.modal-button.confirm').onclick = () => confirmDeleteGame(currentGameId);
|
|
||||||
}
|
|
||||||
const validationModal = document.getElementById('validation-modal');
|
|
||||||
if (validationModal) {
|
|
||||||
validationModal.querySelector('.close-button').onclick = closeValidationModal;
|
|
||||||
validationModal.querySelector('.modal-button.cancel').onclick = closeValidationModal;
|
|
||||||
}
|
|
||||||
const gameCompletionModal = document.getElementById('game-completion-modal');
|
|
||||||
if (gameCompletionModal) {
|
|
||||||
gameCompletionModal.querySelector('.btn.btn--warning').onclick = confirmGameCompletion;
|
|
||||||
gameCompletionModal.querySelector('.btn:not(.btn--warning)').onclick = closeGameCompletionModal;
|
|
||||||
}
|
|
||||||
// New game creation
|
|
||||||
const startGameBtn = document.querySelector('.nav-button');
|
|
||||||
if (startGameBtn && startGameBtn.textContent.includes('Spiel starten')) {
|
|
||||||
startGameBtn.onclick = createNewGame;
|
|
||||||
}
|
|
||||||
// Player name selects
|
|
||||||
['player1', 'player2', 'player3'].forEach(pid => {
|
|
||||||
const select = document.getElementById(`${pid}-select`);
|
|
||||||
if (select) select.onchange = () => updatePlayerInput(pid);
|
|
||||||
});
|
|
||||||
// Score buttons
|
|
||||||
document.querySelectorAll('.score-button').forEach((btn, idx) => {
|
|
||||||
btn.onclick = () => {
|
|
||||||
const player = Math.floor(idx / 2) + 1;
|
|
||||||
const change = idx % 2 === 0 ? -1 : 1;
|
|
||||||
updateScore(currentGameId, player, change);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Initial screen
|
|
||||||
showScreen('game-list-screen');
|
|
||||||
|
|
||||||
window.toggleFullscreen = toggleFullscreen;
|
|
||||||
194
src/components/App.jsx
Normal file
194
src/components/App.jsx
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import { useState, useEffect } from 'preact/hooks';
|
||||||
|
import GameList from './GameList.jsx';
|
||||||
|
import GameDetail from './GameDetail.jsx';
|
||||||
|
import NewGame 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';
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const [games, setGames] = useState([]);
|
||||||
|
const [currentGameId, setCurrentGameId] = useState(null);
|
||||||
|
const [playerNameHistory, setPlayerNameHistory] = useState([]);
|
||||||
|
const [screen, setScreen] = useState('game-list');
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [modal, setModal] = useState({ open: false, gameId: null });
|
||||||
|
const [validation, setValidation] = useState({ open: false, message: '' });
|
||||||
|
const [completionModal, setCompletionModal] = useState({ open: false, game: null });
|
||||||
|
|
||||||
|
// 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
|
||||||
|
function showGameList() {
|
||||||
|
setScreen('game-list');
|
||||||
|
setCurrentGameId(null);
|
||||||
|
}
|
||||||
|
function showNewGame() {
|
||||||
|
setScreen('new-game');
|
||||||
|
setCurrentGameId(null);
|
||||||
|
}
|
||||||
|
function showGameDetail(id) {
|
||||||
|
setCurrentGameId(id);
|
||||||
|
setScreen('game-detail');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game creation
|
||||||
|
function handleCreateGame({ player1, player2, player3, gameType, raceTo }) {
|
||||||
|
const newGame = {
|
||||||
|
id: Date.now(),
|
||||||
|
player1,
|
||||||
|
player2,
|
||||||
|
player3,
|
||||||
|
score1: 0,
|
||||||
|
score2: 0,
|
||||||
|
score3: 0,
|
||||||
|
gameType,
|
||||||
|
raceTo,
|
||||||
|
status: 'active',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: new Date().toISOString()
|
||||||
|
};
|
||||||
|
setGames(g => [newGame, ...g]);
|
||||||
|
setScreen('game-list');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Score update
|
||||||
|
function handleUpdateScore(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;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish game
|
||||||
|
function handleFinishGame() {
|
||||||
|
const game = games.find(g => g.id === currentGameId);
|
||||||
|
if (!game) return;
|
||||||
|
setCompletionModal({ open: true, game });
|
||||||
|
}
|
||||||
|
function handleConfirmCompletion() {
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete game
|
||||||
|
function handleDeleteGame(id) {
|
||||||
|
setModal({ open: true, gameId: id });
|
||||||
|
}
|
||||||
|
function handleConfirmDelete() {
|
||||||
|
setGames(games => games.filter(g => g.id !== modal.gameId));
|
||||||
|
setModal({ open: false, gameId: null });
|
||||||
|
setScreen('game-list');
|
||||||
|
}
|
||||||
|
function handleCancelDelete() {
|
||||||
|
setModal({ open: false, gameId: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation modal
|
||||||
|
function showValidation(message) {
|
||||||
|
setValidation({ open: true, message });
|
||||||
|
}
|
||||||
|
function closeValidation() {
|
||||||
|
setValidation({ open: false, message: '' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="screen-container">
|
||||||
|
{screen === 'game-list' && (
|
||||||
|
<div className="screen active">
|
||||||
|
<div className="screen-content">
|
||||||
|
<button className="nav-button" onClick={showNewGame}>Neues Spiel</button>
|
||||||
|
<GameList
|
||||||
|
games={games}
|
||||||
|
onShowGameDetail={showGameDetail}
|
||||||
|
onDeleteGame={handleDeleteGame}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{screen === 'new-game' && (
|
||||||
|
<div className="screen active">
|
||||||
|
<div className="screen-content">
|
||||||
|
<NewGame
|
||||||
|
onCreateGame={handleCreateGame}
|
||||||
|
playerNameHistory={playerNameHistory}
|
||||||
|
onCancel={showGameList}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{screen === 'game-detail' && (
|
||||||
|
<div className="screen active">
|
||||||
|
<div className="screen-content">
|
||||||
|
<GameDetail
|
||||||
|
game={games.find(g => g.id === currentGameId)}
|
||||||
|
onFinishGame={handleFinishGame}
|
||||||
|
onUpdateScore={handleUpdateScore}
|
||||||
|
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 })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<FullscreenToggle />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
26
src/components/FullscreenToggle.jsx
Normal file
26
src/components/FullscreenToggle.jsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import { useCallback } from 'preact/hooks';
|
||||||
|
import styles from './FullscreenToggle.module.css';
|
||||||
|
|
||||||
|
export default function FullscreenToggle() {
|
||||||
|
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"
|
||||||
|
>
|
||||||
|
<svg viewBox="0 0 24 24" width="24" height="24">
|
||||||
|
<path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
37
src/components/FullscreenToggle.module.css
Normal file
37
src/components/FullscreenToggle.module.css
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div id="game-completion-modal" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<h2>Spiel beenden</h2>
|
|
||||||
<div id="game-summary">
|
|
||||||
<div class="final-scores"></div>
|
|
||||||
<div class="winner-announcement"></div>
|
|
||||||
</div>
|
|
||||||
<div class="modal-buttons">
|
|
||||||
<button class="btn btn--warning">Bestätigen</button>
|
|
||||||
<button class="btn">Abbrechen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
38
src/components/GameCompletionModal.jsx
Normal file
38
src/components/GameCompletionModal.jsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
85
src/components/GameCompletionModal.module.css
Normal file
85
src/components/GameCompletionModal.module.css
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#game-completion-modal {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
|
z-index: 1000;
|
||||||
|
display: none;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
#game-completion-modal.show {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
#game-completion-modal .modal-content {
|
||||||
|
background-color: #2a2a2a;
|
||||||
|
padding: 30px;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
position: relative;
|
||||||
|
margin: auto;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
.final-scores {
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
.final-score {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
background: #333;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
.final-score .player-name {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.final-score .score {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.winner-announcement {
|
||||||
|
text-align: center;
|
||||||
|
margin: 20px 0;
|
||||||
|
padding: 20px;
|
||||||
|
background: #4CAF50;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.winner-announcement h3 {
|
||||||
|
font-size: 24px;
|
||||||
|
margin: 0;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.modal-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.modal-buttons .btn {
|
||||||
|
flex: 1;
|
||||||
|
padding: 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.modal-buttons .btn--warning {
|
||||||
|
background: #f44336;
|
||||||
|
}
|
||||||
|
.modal-buttons .btn:not(.btn--warning) {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
#game-completion-modal h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div class="screen" id="game-detail-screen">
|
|
||||||
<div class="screen-content">
|
|
||||||
<div class="game-title" id="game-title">8-Ball | Race to 5</div>
|
|
||||||
<div class="game-header">
|
|
||||||
<button class="btn nav-button">Zurück zur Liste</button>
|
|
||||||
</div>
|
|
||||||
<div class="scores-container">
|
|
||||||
<div class="player-score">
|
|
||||||
<div class="player-name" id="player1-name">Spieler 1</div>
|
|
||||||
<div class="score" id="score1">0</div>
|
|
||||||
<div class="score-buttons">
|
|
||||||
<button class="score-button">-</button>
|
|
||||||
<button class="score-button">+</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="player-score">
|
|
||||||
<div class="player-name" id="player2-name">Spieler 2</div>
|
|
||||||
<div class="score" id="score2">0</div>
|
|
||||||
<div class="score-buttons">
|
|
||||||
<button class="score-button">-</button>
|
|
||||||
<button class="score-button">+</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="player-score" id="player3-score" style="display: none;">
|
|
||||||
<div class="player-name" id="player3-name">Spieler 3</div>
|
|
||||||
<div class="score" id="score3">0</div>
|
|
||||||
<div class="score-buttons">
|
|
||||||
<button class="score-button">-</button>
|
|
||||||
<button class="score-button">+</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="game-controls">
|
|
||||||
<button id="game-control" class="control-button">Spiel beenden</button>
|
|
||||||
<button id="delete-game" class="control-button delete">Spiel löschen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
31
src/components/GameDetail.jsx
Normal file
31
src/components/GameDetail.jsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import styles from './GameDetail.module.css';
|
||||||
|
|
||||||
|
export default function GameDetail({ game, onFinishGame, onUpdateScore, onBack }) {
|
||||||
|
if (!game) return null;
|
||||||
|
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['player-scores']}>
|
||||||
|
{playerNames.map((name, idx) => (
|
||||||
|
<div className={
|
||||||
|
styles['player-score'] + (name === 'Fränky' ? ' ' + styles['franky'] : '')
|
||||||
|
} key={name}>
|
||||||
|
<span className={styles['player-name']}>{name}</span>
|
||||||
|
<span className={styles['score']} id={`score${idx+1}`}>{scores[idx]}</span>
|
||||||
|
<button className={styles['score-button']} disabled={isCompleted} onClick={() => onUpdateScore(idx+1, -1)}>-</button>
|
||||||
|
<button className={styles['score-button']} disabled={isCompleted} onClick={() => onUpdateScore(idx+1, 1)}>+</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className={styles['game-detail-controls']}>
|
||||||
|
<button className={styles['nav-button']} onClick={onBack}>Zurück zur Liste</button>
|
||||||
|
<button className={styles['nav-button']} disabled={isCompleted} onClick={onFinishGame}>{isCompleted ? 'Abgeschlossen' : 'Spiel beenden'}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
103
src/components/GameDetail.module.css
Normal file
103
src/components/GameDetail.module.css
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
.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: 20px;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
.player-score {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #333;
|
||||||
|
border-radius: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
.player-name {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #fff;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.score {
|
||||||
|
font-size: 50vh;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 10px 0;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
.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;
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div class="screen" id="game-history-screen">
|
|
||||||
<div class="screen-content">
|
|
||||||
<h1 class="screen-title">Spielhistorie</h1>
|
|
||||||
<div class="nav-buttons">
|
|
||||||
<button class="btn nav-button">Zurück zur Liste</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
40
src/components/GameHistory.module.css
Normal file
40
src/components/GameHistory.module.css
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
.nav-buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 20px 0 40px 0;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 20px;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div class="screen active" id="game-list-screen">
|
|
||||||
<div class="screen-content">
|
|
||||||
<h1 class="screen-title">Spiele</h1>
|
|
||||||
<div class="game-list">
|
|
||||||
<div class="nav-buttons">
|
|
||||||
<button class="btn nav-button">Neues Spiel</button>
|
|
||||||
</div>
|
|
||||||
<div class="game-filters">
|
|
||||||
<button class="btn filter-button active">Alle</button>
|
|
||||||
<button class="btn filter-button">Aktiv</button>
|
|
||||||
<button class="btn filter-button">Abgeschlossen</button>
|
|
||||||
</div>
|
|
||||||
<div id="games-container">
|
|
||||||
<!-- Games will be added dynamically -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
41
src/components/GameList.jsx
Normal file
41
src/components/GameList.jsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import styles from './GameList.module.css';
|
||||||
|
|
||||||
|
export default function GameList({ games, filter = 'all', onShowGameDetail, onDeleteGame }) {
|
||||||
|
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));
|
||||||
|
|
||||||
|
if (filteredGames.length === 0) {
|
||||||
|
return <div className={styles['empty-state']}>Keine Spiele vorhanden</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles['game-list'] + ' ' + styles['games-container']}>
|
||||||
|
{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)}>
|
||||||
|
<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)}></button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
46
src/components/GameList.module.css
Normal file
46
src/components/GameList.module.css
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
.nav-buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 20px 0 40px 0;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 20px;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
.filter-button {
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
.filter-button.active {
|
||||||
|
background: #4CAF50;
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div id="modal" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<span class="close-button">×</span>
|
|
||||||
<h2 id="modal-title">Spiel löschen</h2>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p id="modal-message">Möchten Sie das Spiel zwischen Spieler 1 und Spieler 2 wirklich löschen?</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button class="modal-button cancel">Abbrechen</button>
|
|
||||||
<button class="modal-button confirm">Löschen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
23
src/components/Modal.jsx
Normal file
23
src/components/Modal.jsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import styles from './Modal.module.css';
|
||||||
|
|
||||||
|
export default function Modal({ open, title, message, onCancel, onConfirm }) {
|
||||||
|
if (!open) return null;
|
||||||
|
return (
|
||||||
|
<div className={styles['modal'] + ' ' + styles['show']}>
|
||||||
|
<div className={styles['modal-content']}>
|
||||||
|
<div className={styles['modal-header']}>
|
||||||
|
<span className={styles['modal-title']}>{title}</span>
|
||||||
|
<button className={styles['close-button']} onClick={onCancel}>×</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}>Abbrechen</button>
|
||||||
|
<button className={styles['modal-button'] + ' ' + styles['confirm']} onClick={onConfirm}>Löschen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
63
src/components/Modal.module.css
Normal file
63
src/components/Modal.module.css
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
.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;
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div class="screen" id="new-game-screen">
|
|
||||||
<div class="screen-content">
|
|
||||||
<h1 class="screen-title">Neues Spiel</h1>
|
|
||||||
<div class="player-inputs">
|
|
||||||
<div class="player-input">
|
|
||||||
<label for="player1">Spieler 1</label>
|
|
||||||
<div class="name-input-container">
|
|
||||||
<select id="player1-select" class="name-select"><option value="">Vorherige Spieler...</option></select>
|
|
||||||
<input type="text" id="player1" placeholder="Name Spieler 1" class="name-input" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="player-input">
|
|
||||||
<label for="player2">Spieler 2</label>
|
|
||||||
<div class="name-input-container">
|
|
||||||
<select id="player2-select" class="name-select"><option value="">Vorherige Spieler...</option></select>
|
|
||||||
<input type="text" id="player2" placeholder="Name Spieler 2" class="name-input" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="player-input">
|
|
||||||
<label for="player3">Spieler 3 (optional)</label>
|
|
||||||
<div class="name-input-container">
|
|
||||||
<select id="player3-select" class="name-select"><option value="">Vorherige Spieler...</option></select>
|
|
||||||
<input type="text" id="player3" placeholder="Name Spieler 3" class="name-input" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="game-settings">
|
|
||||||
<div class="setting-group">
|
|
||||||
<label for="game-type">Spieltyp</label>
|
|
||||||
<select id="game-type">
|
|
||||||
<option value="8-Ball">8-Ball</option>
|
|
||||||
<option value="9-Ball">9-Ball</option>
|
|
||||||
<option value="10-Ball">10-Ball</option>
|
|
||||||
<option value="14/1">14/1 endlos</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="setting-group">
|
|
||||||
<label for="race-to">Race to X (optional)</label>
|
|
||||||
<input type="number" id="race-to" placeholder="0" min="0" max="99" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="nav-buttons">
|
|
||||||
<button class="btn nav-button">Spiel starten</button>
|
|
||||||
<button class="btn nav-button">Abbrechen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
71
src/components/NewGame.jsx
Normal file
71
src/components/NewGame.jsx
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import { useState } from 'preact/hooks';
|
||||||
|
import styles from './NewGame.module.css';
|
||||||
|
|
||||||
|
export default function NewGame({ onCreateGame, playerNameHistory, onCancel }) {
|
||||||
|
const [player1, setPlayer1] = useState('');
|
||||||
|
const [player2, setPlayer2] = useState('');
|
||||||
|
const [player3, setPlayer3] = useState('');
|
||||||
|
const [gameType, setGameType] = useState('8-Ball');
|
||||||
|
const [raceTo, setRaceTo] = useState('');
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
function handleSubmit(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!player1.trim() || !player2.trim()) {
|
||||||
|
setError('Bitte Namen für beide Spieler eingeben');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onCreateGame({
|
||||||
|
player1: player1.trim(),
|
||||||
|
player2: player2.trim(),
|
||||||
|
player3: player3.trim() || null,
|
||||||
|
gameType,
|
||||||
|
raceTo: raceTo ? parseInt(raceTo) : null
|
||||||
|
});
|
||||||
|
setPlayer1(''); setPlayer2(''); setPlayer3(''); setGameType('8-Ball'); setRaceTo(''); setError(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className={styles['new-game-form']} onSubmit={handleSubmit}>
|
||||||
|
<div>
|
||||||
|
<label>Spieler 1:</label>
|
||||||
|
<input value={player1} onInput={e => setPlayer1(e.target.value)} list="player1-history" />
|
||||||
|
<datalist id="player1-history">
|
||||||
|
{playerNameHistory.map(name => <option value={name} key={name} />)}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Spieler 2:</label>
|
||||||
|
<input value={player2} onInput={e => setPlayer2(e.target.value)} list="player2-history" />
|
||||||
|
<datalist id="player2-history">
|
||||||
|
{playerNameHistory.map(name => <option value={name} key={name} />)}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Spieler 3 (optional):</label>
|
||||||
|
<input value={player3} onInput={e => setPlayer3(e.target.value)} list="player3-history" />
|
||||||
|
<datalist id="player3-history">
|
||||||
|
{playerNameHistory.map(name => <option value={name} key={name} />)}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Spieltyp:</label>
|
||||||
|
<select value={gameType} onChange={e => setGameType(e.target.value)}>
|
||||||
|
<option value="8-Ball">8-Ball</option>
|
||||||
|
<option value="9-Ball">9-Ball</option>
|
||||||
|
<option value="10-Ball">10-Ball</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>Race to:</label>
|
||||||
|
<input type="number" value={raceTo} onInput={e => setRaceTo(e.target.value)} min="1" />
|
||||||
|
</div>
|
||||||
|
{error && <div className={styles['validation-error']}>{error}</div>}
|
||||||
|
<div className={styles['form-actions']}>
|
||||||
|
<button type="button" className={styles['nav-button']} onClick={onCancel}>Abbrechen</button>
|
||||||
|
<button type="submit" className={styles['nav-button']}>Spiel starten</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
111
src/components/NewGame.module.css
Normal file
111
src/components/NewGame.module.css
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
.player-inputs {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
width: 100%;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.player-input {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.player-input label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #ccc;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
.name-input-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.name-select {
|
||||||
|
flex: 1;
|
||||||
|
padding: 30px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: white;
|
||||||
|
font-size: 24px;
|
||||||
|
min-height: 44px;
|
||||||
|
}
|
||||||
|
.name-input {
|
||||||
|
flex: 2;
|
||||||
|
padding: 30px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: white;
|
||||||
|
font-size: 24px;
|
||||||
|
min-height: 44px;
|
||||||
|
}
|
||||||
|
.name-select:focus, .name-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #666;
|
||||||
|
}
|
||||||
|
.game-settings {
|
||||||
|
margin-top: 20px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.setting-group {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.setting-group select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 30px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: white;
|
||||||
|
font-size: 24px;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
.setting-group input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 30px;
|
||||||
|
border: 2px solid #333;
|
||||||
|
background: #2a2a2a;
|
||||||
|
color: white;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
.setting-group input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #666;
|
||||||
|
}
|
||||||
|
.nav-buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 20px 0 40px 0;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 20px;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
---
|
|
||||||
<div id="validation-modal" class="modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<span class="close-button">×</span>
|
|
||||||
<h2 id="validation-modal-title">Fehler</h2>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p id="validation-modal-message"></p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button class="modal-button cancel">OK</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- TODO: Wire up events and props for integration -->
|
|
||||||
22
src/components/ValidationModal.jsx
Normal file
22
src/components/ValidationModal.jsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import styles from './ValidationModal.module.css';
|
||||||
|
|
||||||
|
export default function ValidationModal({ open, message, onClose }) {
|
||||||
|
if (!open) return null;
|
||||||
|
return (
|
||||||
|
<div className={styles['modal'] + ' ' + styles['show']} id="validation-modal">
|
||||||
|
<div className={styles['modal-content']}>
|
||||||
|
<div className={styles['modal-header']}>
|
||||||
|
<span className={styles['modal-title']}>Fehler</span>
|
||||||
|
<button className={styles['close-button']} onClick={onClose}>×</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}>OK</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
63
src/components/ValidationModal.module.css
Normal file
63
src/components/ValidationModal.module.css
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
.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;
|
||||||
|
}
|
||||||
|
.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;
|
||||||
|
}
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
---
|
---
|
||||||
import NewGame from "../components/NewGame.astro";
|
|
||||||
import GameList from "../components/GameList.astro";
|
|
||||||
import GameDetail from "../components/GameDetail.astro";
|
|
||||||
import GameHistory from "../components/GameHistory.astro";
|
|
||||||
import Modal from "../components/Modal.astro";
|
|
||||||
import ValidationModal from "../components/ValidationModal.astro";
|
|
||||||
import GameCompletionModal from "../components/GameCompletionModal.astro";
|
|
||||||
import "../styles/index.css";
|
import "../styles/index.css";
|
||||||
|
import App from "../components/App.jsx";
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
@@ -25,19 +19,7 @@ import "../styles/index.css";
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="screen-container">
|
<div class="screen-container">
|
||||||
<NewGame />
|
<App client:only="preact" />
|
||||||
<GameList />
|
|
||||||
<GameDetail />
|
|
||||||
<GameHistory />
|
|
||||||
</div>
|
</div>
|
||||||
<button id="fullscreen-toggle" class="fullscreen-toggle">
|
|
||||||
<svg viewBox="0 0 24 24" width="24" height="24">
|
|
||||||
<path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<Modal />
|
|
||||||
<ValidationModal />
|
|
||||||
<GameCompletionModal />
|
|
||||||
<script type="module" src="/scripts/index.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,421 +0,0 @@
|
|||||||
// src/scripts/index.js
|
|
||||||
// Modularized logic from original index.astro
|
|
||||||
|
|
||||||
// --- State ---
|
|
||||||
let games = [];
|
|
||||||
let currentGameId = null;
|
|
||||||
let playerNameHistory = [];
|
|
||||||
|
|
||||||
// --- DOM Selectors ---
|
|
||||||
const screens = {
|
|
||||||
'new-game-screen': document.getElementById('new-game-screen'),
|
|
||||||
'game-list-screen': document.getElementById('game-list-screen'),
|
|
||||||
'game-detail-screen': document.getElementById('game-detail-screen'),
|
|
||||||
'game-history-screen': document.getElementById('game-history-screen')
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Screen Management ---
|
|
||||||
function showScreen(screenId) {
|
|
||||||
const currentScreen = document.querySelector('.screen.active');
|
|
||||||
const newScreen = document.getElementById(screenId);
|
|
||||||
if (currentScreen) {
|
|
||||||
currentScreen.classList.remove('active');
|
|
||||||
currentScreen.classList.add('slide-out');
|
|
||||||
setTimeout(() => {
|
|
||||||
currentScreen.classList.remove('slide-out');
|
|
||||||
newScreen.classList.add('active');
|
|
||||||
newScreen.classList.add('slide-in');
|
|
||||||
setTimeout(() => {
|
|
||||||
newScreen.classList.remove('slide-in');
|
|
||||||
}, 300);
|
|
||||||
}, 300);
|
|
||||||
} else {
|
|
||||||
newScreen.classList.add('active');
|
|
||||||
}
|
|
||||||
if (screenId === 'new-game-screen') {
|
|
||||||
updateNameHistory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Loading Overlay ---
|
|
||||||
function showLoading() {
|
|
||||||
document.querySelector('.loading-overlay').style.display = 'block';
|
|
||||||
document.querySelector('.loading-indicator').style.display = 'block';
|
|
||||||
}
|
|
||||||
function hideLoading() {
|
|
||||||
document.querySelector('.loading-overlay').style.display = 'none';
|
|
||||||
document.querySelector('.loading-indicator').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Data Management ---
|
|
||||||
function loadGames() {
|
|
||||||
const savedGames = localStorage.getItem('bscscore_games');
|
|
||||||
if (savedGames) {
|
|
||||||
games = JSON.parse(savedGames);
|
|
||||||
renderGames();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function saveGames() {
|
|
||||||
localStorage.setItem('bscscore_games', JSON.stringify(games));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Player Name History ---
|
|
||||||
function updateNameHistory() {
|
|
||||||
const allNames = games.flatMap(game => [game.player1, game.player2, game.player3].filter(Boolean));
|
|
||||||
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());
|
|
||||||
});
|
|
||||||
playerNameHistory = [...new Set(Object.keys(nameLastUsed))].sort((a, b) => nameLastUsed[b] - nameLastUsed[a]);
|
|
||||||
updateNameSelects();
|
|
||||||
}
|
|
||||||
function updateNameSelects() {
|
|
||||||
const player1Select = document.getElementById('player1-select');
|
|
||||||
const player2Select = document.getElementById('player2-select');
|
|
||||||
const player3Select = document.getElementById('player3-select');
|
|
||||||
while (player1Select.options.length > 1) player1Select.remove(1);
|
|
||||||
while (player2Select.options.length > 1) player2Select.remove(1);
|
|
||||||
while (player3Select.options.length > 1) player3Select.remove(1);
|
|
||||||
playerNameHistory.forEach(name => {
|
|
||||||
const option1 = new Option(name, name);
|
|
||||||
const option2 = new Option(name, name);
|
|
||||||
const option3 = new Option(name, name);
|
|
||||||
player1Select.add(option1);
|
|
||||||
player2Select.add(option2);
|
|
||||||
player3Select.add(option3);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function updatePlayerInput(playerId) {
|
|
||||||
const select = document.getElementById(`${playerId}-select`);
|
|
||||||
const input = document.getElementById(playerId);
|
|
||||||
if (select.value) {
|
|
||||||
input.value = select.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Validation Modal ---
|
|
||||||
function showValidationModal(message) {
|
|
||||||
const modal = document.getElementById('validation-modal');
|
|
||||||
const modalMessage = document.getElementById('validation-modal-message');
|
|
||||||
modalMessage.textContent = message;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeValidationModal() {
|
|
||||||
const modal = document.getElementById('validation-modal');
|
|
||||||
modal.classList.remove('show');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- New Game Creation ---
|
|
||||||
function createNewGame() {
|
|
||||||
const player1Name = document.getElementById('player1').value.trim();
|
|
||||||
const player2Name = document.getElementById('player2').value.trim();
|
|
||||||
const player3Name = document.getElementById('player3').value.trim();
|
|
||||||
const gameType = document.getElementById('game-type').value;
|
|
||||||
const raceTo = document.getElementById('race-to').value;
|
|
||||||
if (!player1Name || !player2Name) {
|
|
||||||
showValidationModal('Bitte Namen für beide Spieler eingeben');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const newGame = {
|
|
||||||
id: Date.now(),
|
|
||||||
player1: player1Name,
|
|
||||||
player2: player2Name,
|
|
||||||
player3: player3Name || null,
|
|
||||||
score1: 0,
|
|
||||||
score2: 0,
|
|
||||||
score3: 0,
|
|
||||||
gameType: gameType,
|
|
||||||
raceTo: raceTo ? parseInt(raceTo) : null,
|
|
||||||
status: 'active',
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
updatedAt: new Date().toISOString()
|
|
||||||
};
|
|
||||||
games.push(newGame);
|
|
||||||
saveGames();
|
|
||||||
updateNameHistory();
|
|
||||||
renderGames();
|
|
||||||
showGameDetail(newGame.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Score Update ---
|
|
||||||
function updateScore(gameId, player, change) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game || game.status === 'completed') return;
|
|
||||||
if (player === 1) {
|
|
||||||
game.score1 = Math.max(0, game.score1 + change);
|
|
||||||
} else if (player === 2) {
|
|
||||||
game.score2 = Math.max(0, game.score2 + change);
|
|
||||||
} else if (player === 3) {
|
|
||||||
game.score3 = Math.max(0, game.score3 + change);
|
|
||||||
}
|
|
||||||
game.updatedAt = new Date().toISOString();
|
|
||||||
if (game.raceTo && (game.score1 >= game.raceTo || game.score2 >= game.raceTo || (game.player3 && game.score3 >= game.raceTo))) {
|
|
||||||
showGameCompletionModal();
|
|
||||||
}
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
if (document.getElementById('game-detail-screen').classList.contains('active')) {
|
|
||||||
document.getElementById('score1').textContent = game.score1;
|
|
||||||
document.getElementById('score2').textContent = game.score2;
|
|
||||||
document.getElementById('score3').textContent = game.score3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Deletion ---
|
|
||||||
function deleteGame(gameId) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game) return;
|
|
||||||
currentGameId = gameId;
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
const modalTitle = document.getElementById('modal-title');
|
|
||||||
const modalMessage = document.getElementById('modal-message');
|
|
||||||
modalTitle.textContent = 'Spiel löschen';
|
|
||||||
modalMessage.textContent = `Möchten Sie das Spiel zwischen ${game.player1} und ${game.player2} wirklich löschen?`;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeModal() {
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
modal.classList.remove('show');
|
|
||||||
currentGameId = null;
|
|
||||||
}
|
|
||||||
function confirmDeleteGame(gameId) {
|
|
||||||
if (!gameId) return;
|
|
||||||
showLoading();
|
|
||||||
setTimeout(() => {
|
|
||||||
const gameIndex = games.findIndex(g => g.id === gameId);
|
|
||||||
if (gameIndex !== -1) {
|
|
||||||
games.splice(gameIndex, 1);
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
if (currentGameId === gameId) {
|
|
||||||
showScreen('game-list-screen');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hideLoading();
|
|
||||||
closeModal();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Rendering ---
|
|
||||||
function renderGames(filter = 'all') {
|
|
||||||
const gamesContainer = document.getElementById('games-container');
|
|
||||||
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));
|
|
||||||
if (filteredGames.length === 0) {
|
|
||||||
gamesContainer.innerHTML = '<div class="empty-state">Keine Spiele vorhanden</div>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gamesContainer.innerHTML = 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 class="game-item ${game.status === 'completed' ? 'completed' : 'active'}">
|
|
||||||
<div class="game-info" onclick="showGameDetail(${game.id})">
|
|
||||||
<div class="game-type">${game.gameType}${game.raceTo ? ` | ${game.raceTo}` : ''}</div>
|
|
||||||
<div class="player-names">${playerNames}</div>
|
|
||||||
<div class="game-scores">${scores}</div>
|
|
||||||
</div>
|
|
||||||
<button class="delete-button" onclick="deleteGame(${game.id})"></button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}).join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Detail ---
|
|
||||||
function showGameDetail(gameId) {
|
|
||||||
const game = games.find(g => g.id === gameId);
|
|
||||||
if (!game) return;
|
|
||||||
currentGameId = gameId;
|
|
||||||
document.getElementById('game-title').textContent = `${game.gameType}${game.raceTo ? ` | Race to ${game.raceTo}` : ''}`;
|
|
||||||
document.getElementById('player1-name').textContent = game.player1;
|
|
||||||
document.getElementById('player2-name').textContent = game.player2;
|
|
||||||
const player3Score = document.getElementById('player3-score');
|
|
||||||
if (game.player3) {
|
|
||||||
document.getElementById('player3-name').textContent = game.player3;
|
|
||||||
document.getElementById('score3').textContent = game.score3;
|
|
||||||
player3Score.style.display = 'flex';
|
|
||||||
} else {
|
|
||||||
player3Score.style.display = 'none';
|
|
||||||
}
|
|
||||||
document.getElementById('score1').textContent = game.score1;
|
|
||||||
document.getElementById('score2').textContent = game.score2;
|
|
||||||
const player1Container = document.querySelector('.player-score:first-child');
|
|
||||||
const player2Container = document.querySelector('.player-score:nth-child(2)');
|
|
||||||
const player3Container = document.getElementById('player3-score');
|
|
||||||
player1Container.classList.toggle('franky', game.player1 === 'Fränky');
|
|
||||||
player2Container.classList.toggle('franky', game.player2 === 'Fränky');
|
|
||||||
player3Container.classList.toggle('franky', game.player3 === 'Fränky');
|
|
||||||
const controlButton = document.getElementById('game-control');
|
|
||||||
if (game.status === 'completed') {
|
|
||||||
controlButton.textContent = 'Zurück zur Liste';
|
|
||||||
controlButton.onclick = () => showScreen('game-list-screen');
|
|
||||||
controlButton.classList.add('disabled');
|
|
||||||
} else {
|
|
||||||
controlButton.textContent = 'Spiel beenden';
|
|
||||||
controlButton.onclick = () => finishGame();
|
|
||||||
controlButton.classList.remove('disabled');
|
|
||||||
}
|
|
||||||
const scoreButtons = document.querySelectorAll('.score-button');
|
|
||||||
scoreButtons.forEach(button => {
|
|
||||||
button.disabled = game.status === 'completed';
|
|
||||||
});
|
|
||||||
showScreen('game-detail-screen');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Completion Modal ---
|
|
||||||
function showGameCompletionModal() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
const modal = document.getElementById('game-completion-modal');
|
|
||||||
const finalScores = modal.querySelector('.final-scores');
|
|
||||||
const winnerAnnouncement = modal.querySelector('.winner-announcement');
|
|
||||||
let scoreHtml = '';
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player1}</span>
|
|
||||||
<span class="score">${game.score1}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player2}</span>
|
|
||||||
<span class="score">${game.score2}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
if (game.player3) {
|
|
||||||
scoreHtml += `
|
|
||||||
<div class="final-score">
|
|
||||||
<span class="player-name">${game.player3}</span>
|
|
||||||
<span class="score">${game.score3}</span>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
finalScores.innerHTML = scoreHtml;
|
|
||||||
const scores = [game.score1, game.score2];
|
|
||||||
if (game.player3) scores.push(game.score3);
|
|
||||||
const maxScore = Math.max(...scores);
|
|
||||||
const winners = [];
|
|
||||||
if (game.score1 === maxScore) winners.push(game.player1);
|
|
||||||
if (game.score2 === maxScore) winners.push(game.player2);
|
|
||||||
if (game.player3 && game.score3 === maxScore) winners.push(game.player3);
|
|
||||||
const winnerText = winners.length > 1
|
|
||||||
? `Unentschieden zwischen ${winners.join(' und ')}`
|
|
||||||
: `${winners[0]} hat gewonnen!`;
|
|
||||||
winnerAnnouncement.innerHTML = `<h3>${winnerText}</h3>`;
|
|
||||||
modal.classList.add('show');
|
|
||||||
}
|
|
||||||
function closeGameCompletionModal() {
|
|
||||||
document.getElementById('game-completion-modal').classList.remove('show');
|
|
||||||
}
|
|
||||||
function confirmGameCompletion() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
game.status = 'completed';
|
|
||||||
game.updatedAt = new Date().toISOString();
|
|
||||||
saveGames();
|
|
||||||
renderGames();
|
|
||||||
showGameDetail(currentGameId);
|
|
||||||
closeGameCompletionModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Game Finish ---
|
|
||||||
function finishGame() {
|
|
||||||
const game = games.find(g => g.id === currentGameId);
|
|
||||||
if (!game) return;
|
|
||||||
showGameCompletionModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Filter Games ---
|
|
||||||
function filterGames(filter) {
|
|
||||||
document.querySelectorAll('.filter-button').forEach(button => {
|
|
||||||
button.classList.remove('active');
|
|
||||||
});
|
|
||||||
document.querySelector(`.filter-button[onclick="filterGames('${filter}')"]`).classList.add('active');
|
|
||||||
renderGames(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Fullscreen ---
|
|
||||||
function toggleFullscreen() {
|
|
||||||
if (!document.fullscreenElement) {
|
|
||||||
document.documentElement.requestFullscreen().catch(err => {
|
|
||||||
console.log(`Error attempting to enable fullscreen: ${err.message}`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
document.exitFullscreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.addEventListener('fullscreenchange', () => {
|
|
||||||
const button = document.getElementById('fullscreen-toggle');
|
|
||||||
if (document.fullscreenElement) {
|
|
||||||
button.innerHTML = `<svg viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>`;
|
|
||||||
} else {
|
|
||||||
button.innerHTML = `<svg viewBox="0 0 24 24" width="24" height="24"><path fill="currentColor" d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Event Listeners ---
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
loadGames();
|
|
||||||
// Attach event listeners for navigation, game creation, modals, etc.
|
|
||||||
document.querySelectorAll('.nav-button').forEach(btn => {
|
|
||||||
if (btn.textContent.includes('Neues Spiel')) btn.onclick = () => showScreen('new-game-screen');
|
|
||||||
if (btn.textContent.includes('Abbrechen')) btn.onclick = () => showScreen('game-list-screen');
|
|
||||||
if (btn.textContent.includes('Zurück zur Liste')) btn.onclick = () => showScreen('game-list-screen');
|
|
||||||
});
|
|
||||||
document.querySelectorAll('.filter-button').forEach((btn, idx) => {
|
|
||||||
if (btn.textContent === 'Alle') btn.onclick = () => filterGames('all');
|
|
||||||
if (btn.textContent === 'Aktiv') btn.onclick = () => filterGames('active');
|
|
||||||
if (btn.textContent === 'Abgeschlossen') btn.onclick = () => filterGames('completed');
|
|
||||||
});
|
|
||||||
document.getElementById('fullscreen-toggle').onclick = toggleFullscreen;
|
|
||||||
// Modal buttons
|
|
||||||
const modal = document.getElementById('modal');
|
|
||||||
if (modal) {
|
|
||||||
modal.querySelector('.close-button').onclick = closeModal;
|
|
||||||
modal.querySelector('.modal-button.cancel').onclick = closeModal;
|
|
||||||
modal.querySelector('.modal-button.confirm').onclick = () => confirmDeleteGame(currentGameId);
|
|
||||||
}
|
|
||||||
const validationModal = document.getElementById('validation-modal');
|
|
||||||
if (validationModal) {
|
|
||||||
validationModal.querySelector('.close-button').onclick = closeValidationModal;
|
|
||||||
validationModal.querySelector('.modal-button.cancel').onclick = closeValidationModal;
|
|
||||||
}
|
|
||||||
const gameCompletionModal = document.getElementById('game-completion-modal');
|
|
||||||
if (gameCompletionModal) {
|
|
||||||
gameCompletionModal.querySelector('.btn.btn--warning').onclick = confirmGameCompletion;
|
|
||||||
gameCompletionModal.querySelector('.btn:not(.btn--warning)').onclick = closeGameCompletionModal;
|
|
||||||
}
|
|
||||||
// New game creation
|
|
||||||
const startGameBtn = document.querySelector('.nav-button');
|
|
||||||
if (startGameBtn && startGameBtn.textContent.includes('Spiel starten')) {
|
|
||||||
startGameBtn.onclick = createNewGame;
|
|
||||||
}
|
|
||||||
// Player name selects
|
|
||||||
['player1', 'player2', 'player3'].forEach(pid => {
|
|
||||||
const select = document.getElementById(`${pid}-select`);
|
|
||||||
if (select) select.onchange = () => updatePlayerInput(pid);
|
|
||||||
});
|
|
||||||
// Score buttons
|
|
||||||
document.querySelectorAll('.score-button').forEach((btn, idx) => {
|
|
||||||
btn.onclick = () => {
|
|
||||||
const player = Math.floor(idx / 2) + 1;
|
|
||||||
const change = idx % 2 === 0 ? -1 : 1;
|
|
||||||
updateScore(currentGameId, player, change);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Initial screen
|
|
||||||
showScreen('game-list-screen');
|
|
||||||
|
|
||||||
window.toggleFullscreen = toggleFullscreen;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Extracted from original index.astro <style> block */
|
/* Global resets and utility styles */
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -18,745 +18,37 @@ body {
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
overscroll-behavior: none;
|
overscroll-behavior: none;
|
||||||
}
|
}
|
||||||
.screen-container {
|
input, select {
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
.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.slide-out {
|
|
||||||
transform: translateX(-100%);
|
|
||||||
}
|
|
||||||
.screen.slide-in {
|
|
||||||
transform: translateX(0);
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.game-filters {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.data-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 100px;
|
|
||||||
padding: 20px;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
font-size: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
.filter-button {
|
|
||||||
background: #333;
|
|
||||||
}
|
|
||||||
.filter-button.active {
|
|
||||||
background: #4CAF50;
|
|
||||||
}
|
|
||||||
.filter-button[onclick="filterGames('active')"] {
|
|
||||||
background: #1e4620;
|
|
||||||
}
|
|
||||||
.filter-button[onclick="filterGames('active')"].active {
|
|
||||||
background: #4CAF50;
|
|
||||||
}
|
|
||||||
.filter-button[onclick="filterGames('completed')"] {
|
|
||||||
background: #3a3a3a;
|
|
||||||
}
|
|
||||||
.filter-button[onclick="filterGames('completed')"].active {
|
|
||||||
background: #4CAF50;
|
|
||||||
}
|
|
||||||
.data-button {
|
|
||||||
background: #333;
|
|
||||||
}
|
|
||||||
.data-button.export {
|
|
||||||
background: #1e4620;
|
|
||||||
}
|
|
||||||
.data-button.import {
|
|
||||||
background: #3a3a3a;
|
|
||||||
}
|
|
||||||
.file-input {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.game-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 1.5rem;
|
|
||||||
margin-bottom: 0.75rem;
|
|
||||||
background: #fff;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
.game-item.active {
|
|
||||||
background: #1e4620;
|
|
||||||
}
|
|
||||||
.game-item.completed {
|
|
||||||
background: #3a3a3a;
|
|
||||||
}
|
|
||||||
.game-item:active {
|
|
||||||
transform: scale(0.98);
|
|
||||||
}
|
|
||||||
.game-info {
|
|
||||||
flex: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 2rem;
|
|
||||||
}
|
|
||||||
.game-type {
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
min-width: 8rem;
|
|
||||||
}
|
|
||||||
.player-names {
|
|
||||||
color: #fff;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
min-width: 20rem;
|
|
||||||
}
|
|
||||||
.game-scores {
|
|
||||||
font-size: 2rem;
|
|
||||||
font-weight: bold;
|
|
||||||
min-width: 6rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.delete-button {
|
|
||||||
width: 3rem;
|
|
||||||
height: 3rem;
|
|
||||||
border: none;
|
|
||||||
background: #ff4444;
|
|
||||||
color: white;
|
|
||||||
border-radius: 50%;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin-left: 1rem;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.delete-button::before {
|
|
||||||
content: '🗑️';
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
.delete-button:hover {
|
|
||||||
background: #cc0000;
|
|
||||||
}
|
|
||||||
.delete-button:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
.game-item.completed {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
.empty-state {
|
|
||||||
text-align: center;
|
|
||||||
padding: 2rem;
|
|
||||||
color: #666;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
.game-players {
|
|
||||||
font-size: 24px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.game-details {
|
|
||||||
color: #ccc;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
.game-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.action-button {
|
|
||||||
padding: 20px;
|
|
||||||
background: #333;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
font-size: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
.game-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.game-title {
|
|
||||||
font-size: 24px;
|
|
||||||
color: #ccc;
|
|
||||||
}
|
|
||||||
.score-display {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
flex: 1;
|
|
||||||
text-align: center;
|
|
||||||
padding: 20px;
|
|
||||||
margin: 0 5px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.player-score:first-child {
|
|
||||||
background: #4CAF50;
|
|
||||||
}
|
|
||||||
.player-score:nth-child(2) {
|
|
||||||
background: #1f21f2;
|
|
||||||
}
|
|
||||||
.player-score:last-child {
|
|
||||||
background: #f44336;
|
|
||||||
}
|
|
||||||
.player-score.franky {
|
|
||||||
background: #ffffff !important;
|
|
||||||
}
|
|
||||||
.player-score.franky .player-name,
|
|
||||||
.player-score.franky .score {
|
|
||||||
color: #f12f12 !important;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 15rem;
|
|
||||||
font-weight: bold;
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.score-buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
.score-button {
|
|
||||||
flex: 1;
|
|
||||||
padding: 30px;
|
|
||||||
background: #333;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
font-size: 36px;
|
|
||||||
cursor: pointer;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
.score-button:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
.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.warning {
|
|
||||||
background: #f44336;
|
|
||||||
}
|
|
||||||
.nav-buttons {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
margin: 20px 0 40px 0;
|
|
||||||
}
|
|
||||||
.nav-button {
|
|
||||||
padding: 30px;
|
|
||||||
background: #333;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
font-size: 24px;
|
|
||||||
cursor: pointer;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
.player-inputs {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20px;
|
|
||||||
width: 100%;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
.player-input {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.player-input label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
color: #ccc;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
.name-input-container {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.name-select {
|
|
||||||
flex: 1;
|
|
||||||
padding: 30px;
|
|
||||||
border: 2px solid #333;
|
|
||||||
background: #2a2a2a;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
min-height: 44px;
|
|
||||||
}
|
|
||||||
.name-input {
|
|
||||||
flex: 2;
|
|
||||||
padding: 30px;
|
|
||||||
border: 2px solid #333;
|
|
||||||
background: #2a2a2a;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
min-height: 44px;
|
|
||||||
}
|
|
||||||
.name-select:focus, .name-input:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: #666;
|
|
||||||
}
|
|
||||||
.game-settings {
|
|
||||||
margin-top: 20px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.setting-group {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.setting-group select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 30px;
|
|
||||||
border: 2px solid #333;
|
|
||||||
background: #2a2a2a;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
min-height: 44px;
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
.setting-group input {
|
|
||||||
width: 100%;
|
|
||||||
padding: 30px;
|
|
||||||
border: 2px solid #333;
|
|
||||||
background: #2a2a2a;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
.setting-group input:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: #666;
|
|
||||||
}
|
|
||||||
.start-game-button {
|
|
||||||
margin-top: 20px;
|
|
||||||
padding: 30px;
|
|
||||||
background: #4CAF50;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
font-size: 24px;
|
|
||||||
cursor: pointer;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
.player-score.completed {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
.score-button:disabled,
|
|
||||||
.control-button:disabled,
|
|
||||||
.action-button:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
.loading-overlay {
|
|
||||||
display: none;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
|
||||||
z-index: 1000;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.loading-indicator {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
border: 5px solid #f3f3f3;
|
|
||||||
border-top: 5px solid #3498db;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
@keyframes spin {
|
|
||||||
0% { transform: rotate(0deg); }
|
|
||||||
100% { transform: rotate(360deg); }
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.button, .control-button, .score-button, .delete-button, .filter-button, .nav-button {
|
|
||||||
transition: transform 0.1s ease, background-color 0.2s ease;
|
|
||||||
}
|
|
||||||
.button:active, .control-button:active, .score-button:active, .delete-button:active, .filter-button:active, .nav-button:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
.button, .control-button, .score-button, .delete-button, .filter-button, .nav-button {
|
|
||||||
min-height: 44px;
|
|
||||||
min-width: 44px;
|
|
||||||
padding: 12px 24px;
|
|
||||||
}
|
|
||||||
.game-item {
|
|
||||||
transition: transform 0.1s ease, background-color 0.2s ease;
|
|
||||||
}
|
|
||||||
.game-item:active {
|
|
||||||
transform: scale(0.98);
|
|
||||||
}
|
|
||||||
input {
|
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
select {
|
|
||||||
|
/* 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;
|
min-height: 44px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
@media screen and (max-width: 480px) {
|
|
||||||
.game-detail {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 36px;
|
|
||||||
}
|
|
||||||
.score-buttons {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.score-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.game-actions {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.action-button {
|
|
||||||
padding: 8px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.new-game-form {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
|
||||||
.form-group input,
|
|
||||||
.form-group select {
|
|
||||||
padding: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.form-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.filter-buttons {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
.filter-button {
|
|
||||||
padding: 6px 12px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and (min-width: 481px) and (max-width: 768px) {
|
|
||||||
.game-detail {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 42px;
|
|
||||||
}
|
|
||||||
.score-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.new-game-form {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.form-group input,
|
|
||||||
.form-group select {
|
|
||||||
padding: 8px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.form-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.filter-button {
|
|
||||||
padding: 6px 12px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.game-detail {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
background-color: #2a2a2a;
|
|
||||||
border-radius: 10px;
|
|
||||||
margin-top: 20px;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 20px;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
flex: 1;
|
|
||||||
text-align: center;
|
|
||||||
padding: 20px;
|
|
||||||
background-color: #333;
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 24px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
color: #fff;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 50vh;
|
|
||||||
font-weight: bold;
|
|
||||||
margin: 10px 0;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 480px) {
|
|
||||||
.game-detail {
|
|
||||||
padding: 15px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
padding: 15px;
|
|
||||||
min-height: 200px;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 25vh;
|
|
||||||
}
|
|
||||||
.score-buttons {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.score-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
min-width: 70px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and (min-width: 481px) and (max-width: 768px) {
|
|
||||||
.game-detail {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
gap: 15px;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
padding: 15px;
|
|
||||||
min-height: 180px;
|
|
||||||
}
|
|
||||||
.player-name {
|
|
||||||
font-size: 22px;
|
|
||||||
}
|
|
||||||
.score {
|
|
||||||
font-size: 25vh;
|
|
||||||
}
|
|
||||||
.score-button {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
min-width: 70px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.fullscreen-toggle {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
.fullscreen-toggle:hover {
|
|
||||||
background-color: rgba(52, 152, 219, 1);
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
.fullscreen-toggle:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
.fullscreen-toggle svg {
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 480px) {
|
@media screen and (max-width: 480px) {
|
||||||
.fullscreen-toggle {
|
.fullscreen-toggle {
|
||||||
bottom: 15px;
|
bottom: 15px;
|
||||||
@@ -764,119 +56,4 @@ select {
|
|||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.optional-player {
|
|
||||||
margin-top: 1rem;
|
|
||||||
padding-top: 1rem;
|
|
||||||
border-top: 1px solid #eee;
|
|
||||||
}
|
|
||||||
.optional-player label {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
.optional-player input[type="checkbox"] {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.scores-container {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 1rem;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
.player-score {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.player-score {
|
|
||||||
min-width: 150px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#game-completion-modal {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
|
||||||
z-index: 1000;
|
|
||||||
display: none;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
#game-completion-modal.show {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
#game-completion-modal .modal-content {
|
|
||||||
background-color: #2a2a2a;
|
|
||||||
padding: 30px;
|
|
||||||
border-radius: 10px;
|
|
||||||
width: 90%;
|
|
||||||
max-width: 500px;
|
|
||||||
position: relative;
|
|
||||||
margin: auto;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
.final-scores {
|
|
||||||
margin: 20px 0;
|
|
||||||
}
|
|
||||||
.final-score {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 20px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
background: #333;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
.final-score .player-name {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.final-score .score {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.winner-announcement {
|
|
||||||
text-align: center;
|
|
||||||
margin: 20px 0;
|
|
||||||
padding: 20px;
|
|
||||||
background: #4CAF50;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
.winner-announcement h3 {
|
|
||||||
font-size: 24px;
|
|
||||||
margin: 0;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.modal-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
.modal-buttons .btn {
|
|
||||||
flex: 1;
|
|
||||||
padding: 20px;
|
|
||||||
font-size: 20px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.modal-buttons .btn--warning {
|
|
||||||
background: #f44336;
|
|
||||||
}
|
|
||||||
.modal-buttons .btn:not(.btn--warning) {
|
|
||||||
background: #333;
|
|
||||||
}
|
|
||||||
#game-completion-modal h2 {
|
|
||||||
font-size: 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user