refactor: migrate UI to Preact components and remove legacy Astro/JS

- Replaced all .astro components with .jsx Preact components and added corresponding CSS modules.
- Updated index.astro to use the new App Preact component; removed legacy script and Astro imports.
- Deleted obsolete .astro component files and main JS logic (src/scripts/index.js, public/scripts/index.js).
- Updated astro.config.mjs for Preact integration.
- Updated package.json and package-lock.json to include @astrojs/preact and preact.
- Updated tsconfig.json for Preact JSX support.
- Refactored index.css to keep only global resets and utility styles.
- All changes relate to Gitea issue #1 (refactor to astro app).

Migrates the UI from Astro/vanilla JS to a modular Preact component architecture, removing all legacy code and aligning the project with modern best practices.
Refs #1
This commit is contained in:
Frank Schwenk
2025-06-06 11:58:29 +02:00
parent de07d6e7a2
commit 8384d08393
31 changed files with 1901 additions and 1891 deletions

View File

@@ -1,4 +1,4 @@
/* Extracted from original index.astro <style> block */
/* Global resets and utility styles */
* {
margin: 0;
padding: 0;
@@ -18,745 +18,37 @@ body {
min-height: 100vh;
overscroll-behavior: none;
}
.screen-container {
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 {
input, select {
min-height: 44px;
padding: 12px;
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;
padding: 12px;
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) {
.fullscreen-toggle {
bottom: 15px;
@@ -764,119 +56,4 @@ select {
width: 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;
}