feat: abstract buttons

This commit is contained in:
Lala, Shahd
2026-05-04 09:56:09 +02:00
parent 361ce1e817
commit d471eef7af
15 changed files with 103 additions and 144 deletions
+40
View File
@@ -0,0 +1,40 @@
/* Shared Button Template */
.app-btn {
background: var(--btn-bg);
color: var(--btn-fg);
border: none;
border-radius: 2px;
padding: 0.6rem 1rem;
font-family: 'Space Mono', monospace;
font-size: 11px;
font-weight: 700;
letter-spacing: 1px;
cursor: pointer;
box-shadow: var(--btn-glow);
transition: transform 0.2s ease, filter 0.2s ease, background 1.6s ease, box-shadow 1.6s ease;
display: inline-flex;
align-items: center;
justify-content: center;
outline: none;
text-transform: uppercase;
}
.app-btn:hover:enabled {
transform: scale(1.05);
filter: brightness(1.15);
}
.app-btn:active:enabled {
transform: scale(0.98);
}
.app-btn:disabled {
opacity: 0.65;
cursor: not-allowed;
box-shadow: none;
}
.app-btn.w-100 {
width: 100%;
}
@@ -40,21 +40,7 @@
} }
.input-card .btn { @import '../../button-template.css';
border: var(--button-border);
border-radius: var(--border-radius-sm);
background: var(--color-bg-button);
color: var(--color-text-primary);
padding: var(--button-padding);
cursor: pointer;
font-weight: 600;
transition: background-color 0.2s, color 0.2s;
}
.input-card .btn:hover {
background: var(--color-bg-button-hover);
color: var(--color-text-button-hover);
}
.hint-text { .hint-text {
margin: 0; margin: 0;
@@ -21,7 +21,7 @@
/> />
} }
<button type="button" class="btn w-100" (click)="onButtonClick()"> <button type="button" class="app-btn w-100" (click)="onButtonClick()">
{{ buttonLabel }} {{ buttonLabel }}
</button> </button>
@@ -27,35 +27,17 @@
text-align: center; text-align: center;
} }
@import '../../button-template.css';
.dialog-actions { .dialog-actions {
display: flex; display: flex;
gap: 0.6rem; gap: 0.6rem;
flex-wrap: wrap; flex-wrap: wrap;
} }
.dialog-btn { .dialog-actions .app-btn {
flex: 1; flex: 1;
min-width: 120px; min-width: 120px;
background: var(--btn-bg);
color: var(--btn-fg);
border: none;
border-radius: 2px;
padding: 0.55rem 0.75rem;
font-family: 'Space Mono', monospace;
font-size: 11px;
font-weight: 700;
letter-spacing: 1px;
cursor: pointer;
box-shadow: var(--btn-glow);
}
.dialog-btn:hover:enabled {
filter: brightness(1.12);
}
.dialog-btn:disabled {
opacity: 0.65;
cursor: not-allowed;
} }
.dialog-input { .dialog-input {
@@ -22,9 +22,9 @@
} }
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="openRegister()">Create account</button> <button type="button" class="app-btn" (click)="openRegister()">Create account</button>
<button type="button" class="dialog-btn" (click)="closeDialog()">Cancel</button> <button type="button" class="app-btn" (click)="closeDialog()">Cancel</button>
<button type="button" class="dialog-btn" (click)="onSubmit()" [disabled]="isLoading || loginForm.invalid"> <button type="submit" class="app-btn" [disabled]="isLoading || loginForm.invalid">
@if (isLoading) { @if (isLoading) {
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> <span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
} }
@@ -20,9 +20,10 @@
} }
.promotion-dialog { .promotion-dialog {
background: white; background: var(--dlg-bg, white);
border-radius: 8px; border: 1.5px solid var(--dlg-border, #ddd);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); border-radius: 4px;
box-shadow: var(--bb-glow, 0 4px 16px rgba(0, 0, 0, 0.2));
max-width: 400px; max-width: 400px;
width: 90%; width: 90%;
animation: slideUp 0.3s ease; animation: slideUp 0.3s ease;
@@ -44,32 +45,14 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 20px; padding: 20px;
border-bottom: 1px solid #e0e0e0; border-bottom: 1px solid var(--bb-border, #e0e0e0);
h3 { h3 {
margin: 0; margin: 0;
font-family: 'Bebas Neue', sans-serif;
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: #333; color: var(--bb-title, #333);
}
.close-btn {
background: none;
border: none;
font-size: 24px;
cursor: pointer;
color: #999;
padding: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
transition: color 0.2s;
&:hover {
color: #333;
}
} }
} }
@@ -80,7 +63,8 @@
.promotion-prompt { .promotion-prompt {
margin: 0 0 20px 0; margin: 0 0 20px 0;
text-align: center; text-align: center;
color: #666; color: var(--bb-title);
opacity: 0.8;
font-size: 14px; font-size: 14px;
} }
@@ -90,42 +74,20 @@
gap: 12px; gap: 12px;
} }
.promotion-button { @import '../../button-template.css';
display: flex;
.promotion-choice {
flex-direction: column; flex-direction: column;
align-items: center; height: auto;
justify-content: center;
gap: 8px;
padding: 16px; padding: 16px;
background: #f5f5f5; gap: 8px;
border: 2px solid #ddd; }
border-radius: 6px;
cursor: pointer; .promotion-choice .piece-symbol {
transition: all 0.2s; font-size: 32px;
font-family: inherit; line-height: 1;
}
&:hover {
background: #e8e8e8; .promotion-choice .piece-label {
border-color: #999; font-size: 11px;
transform: translateY(-2px);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
&:active {
transform: translateY(0);
box-shadow: none;
}
.piece-symbol {
font-size: 32px;
line-height: 1;
}
.piece-label {
font-size: 12px;
font-weight: 500;
color: #666;
text-transform: uppercase;
letter-spacing: 0.5px;
}
} }
@@ -2,7 +2,7 @@
<div class="promotion-dialog"> <div class="promotion-dialog">
<div class="promotion-header"> <div class="promotion-header">
<h3>Pawn Promotion</h3> <h3>Pawn Promotion</h3>
<button class="close-btn" (click)="close()" aria-label="Close">&times;</button> <button class="app-btn" (click)="close()" aria-label="Close" style="padding:0.2rem 0.5rem;min-width:unset;">&times;</button>
</div> </div>
<div class="promotion-body"> <div class="promotion-body">
@@ -11,7 +11,8 @@
<div class="promotion-options"> <div class="promotion-options">
@for (piece of promotionPieces; track piece.type) { @for (piece of promotionPieces; track piece.type) {
<button <button
class="promotion-button" type="button"
class="app-btn promotion-choice"
[attr.data-piece]="piece.type" [attr.data-piece]="piece.type"
(click)="selectPromotion(piece.type)" (click)="selectPromotion(piece.type)"
[title]="piece.label" [title]="piece.label"
@@ -27,35 +27,17 @@
text-align: center; text-align: center;
} }
@import '../../button-template.css';
.dialog-actions { .dialog-actions {
display: flex; display: flex;
gap: 0.6rem; gap: 0.6rem;
flex-wrap: wrap; flex-wrap: wrap;
} }
.dialog-btn { .dialog-actions .app-btn {
flex: 1; flex: 1;
min-width: 120px; min-width: 120px;
background: var(--btn-bg);
color: var(--btn-fg);
border: none;
border-radius: 2px;
padding: 0.55rem 0.75rem;
font-family: 'Space Mono', monospace;
font-size: 11px;
font-weight: 700;
letter-spacing: 1px;
cursor: pointer;
box-shadow: var(--btn-glow);
}
.dialog-btn:hover:enabled {
filter: brightness(1.12);
}
.dialog-btn:disabled {
opacity: 0.65;
cursor: not-allowed;
} }
.dialog-input { .dialog-input {
@@ -29,9 +29,9 @@
} }
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="openLogin()">Already have an account?</button> <button type="button" class="app-btn" (click)="openLogin()">Already have an account?</button>
<button type="button" class="dialog-btn" (click)="closeDialog()">Cancel</button> <button type="button" class="app-btn" (click)="closeDialog()">Cancel</button>
<button type="button" class="dialog-btn" (click)="onSubmit()" [disabled]="isLoading || registerForm.invalid"> <button type="submit" class="app-btn" [disabled]="isLoading || registerForm.invalid">
@if (isLoading) { @if (isLoading) {
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> <span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
} }
@@ -17,3 +17,5 @@
.gap-2 { .gap-2 {
gap: 0.5rem; gap: 0.5rem;
} }
@import '../../button-template.css';
@@ -3,19 +3,19 @@
<span class="navbar-brand">NowChess</span> <span class="navbar-brand">NowChess</span>
<div class="ms-auto"> <div class="ms-auto">
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-2">
<button type="button" class="dialog-btn" (click)="toggleTheme()"> <button type="button" class="app-btn" (click)="toggleTheme()">
{{ isDarkMode ? 'Light mode' : 'Dark mode' }} {{ isDarkMode ? 'Light mode' : 'Dark mode' }}
</button> </button>
@if (currentUser; as user) { @if (currentUser; as user) {
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-2">
<span style="color:var(--bb-title);font-weight:700">{{ user.username }}</span> <span style="color:var(--bb-title);font-weight:700">{{ user.username }}</span>
<button class="dialog-btn" (click)="logout()">Logout</button> <button type="button" class="app-btn" (click)="logout()">Logout</button>
</div> </div>
} @else { } @else {
<button class="dialog-btn" (click)="openLoginDialog()"> <button type="button" class="app-btn" (click)="openLoginDialog()">
Login Login
</button> </button>
<button class="dialog-btn" (click)="openRegisterDialog()"> <button type="button" class="app-btn" (click)="openRegisterDialog()">
Register Register
</button> </button>
} }
+2
View File
@@ -1,3 +1,5 @@
@import '../../button-template.css';
.game-shell { .game-shell {
min-height: 100dvh; min-height: 100dvh;
padding: clamp(var(--size-md), 2vw, var(--size-xl)); padding: clamp(var(--size-md), 2vw, var(--size-xl));
+1 -1
View File
@@ -144,7 +144,7 @@
readonly readonly
></textarea> ></textarea>
<button type="button" class="export-button" (click)="completeExport()">Done</button> <button type="button" class="app-btn w-100" (click)="completeExport()">Done</button>
@if (exportNotice) { @if (exportNotice) {
<p class="export-note">{{ exportNotice }}</p> <p class="export-note">{{ exportNotice }}</p>
@@ -1,3 +1,5 @@
@import '../../button-template.css';
:host { :host {
display: block; display: block;
} }
+12 -12
View File
@@ -37,7 +37,7 @@
<div class="bb"> <div class="bb">
<div class="bb-tag">JOIN</div> <div class="bb-tag">JOIN</div>
<div class="bb-title">JOIN<br />GAME</div> <div class="bb-title">JOIN<br />GAME</div>
<button type="button" class="bb-btn" (click)="openJoinDialog()" [disabled]="joiningGame"> <button type="button" class="app-btn" (click)="openJoinDialog()" [disabled]="joiningGame">
{{ joiningGame ? 'JOINING...' : 'JOIN GAME →' }} {{ joiningGame ? 'JOINING...' : 'JOIN GAME →' }}
</button> </button>
</div> </div>
@@ -62,7 +62,7 @@
<div class="bb"> <div class="bb">
<div class="bb-tag">BOT</div> <div class="bb-tag">BOT</div>
<div class="bb-title">PLAY WITH<br />A BOT</div> <div class="bb-title">PLAY WITH<br />A BOT</div>
<button type="button" class="bb-btn" (click)="openDifficultyDialog()" [disabled]="creating"> <button type="button" class="app-btn" (click)="openDifficultyDialog()" [disabled]="creating">
{{ creating ? 'CREATING...' : 'GET STARTED →' }} {{ creating ? 'CREATING...' : 'GET STARTED →' }}
</button> </button>
</div> </div>
@@ -94,7 +94,7 @@
<div class="bb-tag">WELCOME</div> <div class="bb-tag">WELCOME</div>
<div class="bb-title" style="font-size:clamp(16px,1.8vw,26px);">WELCOME TO<br />NOWCHESS</div> <div class="bb-title" style="font-size:clamp(16px,1.8vw,26px);">WELCOME TO<br />NOWCHESS</div>
<div class="bb-subtitle">Play your next move from the skyline.</div> <div class="bb-subtitle">Play your next move from the skyline.</div>
<button type="button" class="bb-btn" style="padding:7px 20px;font-size:11px;" (click)="startOneVsOne()" <button type="button" class="app-btn" style="padding:7px 20px;font-size:11px;" (click)="startOneVsOne()"
[disabled]="creating"> [disabled]="creating">
{{ creating ? 'CREATING...' : 'START NOW →' }} {{ creating ? 'CREATING...' : 'START NOW →' }}
</button> </button>
@@ -121,7 +121,7 @@
<div class="bb"> <div class="bb">
<div class="bb-tag">OPTIONS</div> <div class="bb-tag">OPTIONS</div>
<div class="bb-title">MORE<br />OPTIONS</div> <div class="bb-title">MORE<br />OPTIONS</div>
<button type="button" class="bb-btn" (click)="openOptionsDialog()">OPEN MENU →</button> <button type="button" class="app-btn" (click)="openOptionsDialog()">OPEN MENU →</button>
</div> </div>
</div> </div>
<div class="wins" style="grid-template-columns:repeat(6,1fr);"> <div class="wins" style="grid-template-columns:repeat(6,1fr);">
@@ -192,9 +192,9 @@
<div class="dialog-card" (click)="$event.stopPropagation()"> <div class="dialog-card" (click)="$event.stopPropagation()">
<div class="dialog-title">SELECT DIFFICULTY</div> <div class="dialog-title">SELECT DIFFICULTY</div>
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="startVsBot('easy')" [disabled]="creating">EASY</button> <button type="button" class="app-btn" (click)="startVsBot('easy')" [disabled]="creating">EASY</button>
<button type="button" class="dialog-btn" (click)="startVsBot('medium')" [disabled]="creating">MEDIUM</button> <button type="button" class="app-btn" (click)="startVsBot('medium')" [disabled]="creating">MEDIUM</button>
<button type="button" class="dialog-btn" (click)="startVsBot('hard')" [disabled]="creating">HARD</button> <button type="button" class="app-btn" (click)="startVsBot('hard')" [disabled]="creating">HARD</button>
</div> </div>
</div> </div>
</div> </div>
@@ -205,7 +205,7 @@
<div class="dialog-card" (click)="$event.stopPropagation()"> <div class="dialog-card" (click)="$event.stopPropagation()">
<div class="dialog-title">MORE OPTIONS</div> <div class="dialog-title">MORE OPTIONS</div>
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="openImportDialog()">IMPORT GAME</button> <button type="button" class="app-btn" (click)="openImportDialog()">IMPORT GAME</button>
</div> </div>
</div> </div>
</div> </div>
@@ -218,11 +218,11 @@
<input type="text" class="dialog-input" [(ngModel)]="gameIdInput" placeholder="Paste game ID here" <input type="text" class="dialog-input" [(ngModel)]="gameIdInput" placeholder="Paste game ID here"
[disabled]="joiningGame" (keyup.enter)="submitJoinGame()" /> [disabled]="joiningGame" (keyup.enter)="submitJoinGame()" />
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="submitJoinGame()" <button type="button" class="app-btn" (click)="submitJoinGame()"
[disabled]="joiningGame || !gameIdInput.trim()"> [disabled]="joiningGame || !gameIdInput.trim()">
{{ joiningGame ? 'JOINING...' : 'JOIN' }} {{ joiningGame ? 'JOINING...' : 'JOIN' }}
</button> </button>
<button type="button" class="dialog-btn" (click)="closeJoinDialog()" [disabled]="joiningGame">CANCEL</button> <button type="button" class="app-btn" (click)="closeJoinDialog()" [disabled]="joiningGame">CANCEL</button>
</div> </div>
</div> </div>
</div> </div>
@@ -248,11 +248,11 @@
[placeholder]="importMode === 'fen' ? 'Paste FEN here' : 'Paste PGN here'" [disabled]="importing" [placeholder]="importMode === 'fen' ? 'Paste FEN here' : 'Paste PGN here'" [disabled]="importing"
rows="5"></textarea> rows="5"></textarea>
<div class="dialog-actions"> <div class="dialog-actions">
<button type="button" class="dialog-btn" (click)="submitImportGame()" <button type="button" class="app-btn" (click)="submitImportGame()"
[disabled]="importing || !importText.trim()"> [disabled]="importing || !importText.trim()">
{{ importing ? 'IMPORTING...' : 'IMPORT' }} {{ importing ? 'IMPORTING...' : 'IMPORT' }}
</button> </button>
<button type="button" class="dialog-btn" (click)="closeImportDialog()" [disabled]="importing">CANCEL</button> <button type="button" class="app-btn" (click)="closeImportDialog()" [disabled]="importing">CANCEL</button>
</div> </div>
</div> </div>
</div> </div>