fix: Prettier
All checks were successful
CI / Get Changed Files (pull_request) Successful in 28s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / Docker frontend validation (pull_request) Successful in 1m19s
CI / eslint (pull_request) Successful in 25s
CI / oxlint (pull_request) Successful in 23s
CI / prettier (pull_request) Successful in 21s
CI / test-build (pull_request) Successful in 32s

This commit is contained in:
Jan K9f 2025-05-21 11:06:35 +02:00
commit bb5f26ab60
3 changed files with 30 additions and 21 deletions

View file

@ -98,9 +98,18 @@ button:not([disabled]):active {
/* Animation for results */
@keyframes popIn {
0% { transform: scale(0.8); opacity: 0; }
70% { transform: scale(1.1); opacity: 1; }
100% { transform: scale(1); opacity: 1; }
0% {
transform: scale(0.8);
opacity: 0;
}
70% {
transform: scale(1.1);
opacity: 1;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.result-text {

View file

@ -20,14 +20,7 @@ import { CoinflipGame, CoinflipRequest } from './models/coinflip.model';
@Component({
selector: 'app-coinflip',
standalone: true,
imports: [
AnimatedNumberComponent,
CurrencyPipe,
FormsModule,
CommonModule,
NgIf,
NgClass
],
imports: [AnimatedNumberComponent, CurrencyPipe, FormsModule, CommonModule, NgIf, NgClass],
templateUrl: './coinflip.component.html',
styleUrl: './coinflip.component.css',
changeDetection: ChangeDetectionStrategy.OnPush,
@ -71,15 +64,15 @@ export default class CoinflipComponent implements OnInit {
updateBet(event: Event) {
const inputElement = event.target as HTMLInputElement;
let value = Number(inputElement.value);
// Reset invalid bet state
this.isInvalidBet.set(false);
// Enforce minimum bet of 1
if (value <= 0) {
value = 1;
}
// Cap bet at available balance and show feedback
if (value > this.balance()) {
value = this.balance();
@ -90,7 +83,7 @@ export default class CoinflipComponent implements OnInit {
// Update the input field directly to show the user the max value
inputElement.value = String(value);
}
// Update signals
this.betInputValue.set(value);
this.currentBet.set(value);
@ -220,29 +213,32 @@ export default class CoinflipComponent implements OnInit {
if (navigationKeys.includes(event.key)) {
return;
}
// Only allow numbers
if (!/^\d$/.test(event.key)) {
event.preventDefault();
return;
}
// Get the value that would result after the keypress
const input = event.target as HTMLInputElement;
const currentValue = input.value;
const cursorPosition = input.selectionStart || 0;
const newValue = currentValue.substring(0, cursorPosition) + event.key + currentValue.substring(input.selectionEnd || cursorPosition);
const newValue =
currentValue.substring(0, cursorPosition) +
event.key +
currentValue.substring(input.selectionEnd || cursorPosition);
const numValue = Number(newValue);
// Prevent values greater than balance
if (numValue > this.balance()) {
event.preventDefault();
}
}
// We removed the paste handler for simplicity since the updateBet method
// will handle any value that gets into the input field
getResultClass() {
if (!this.gameResult()) return '';
const result = this.gameResult();