From bb5f26ab60b7eae7001f2336197ad975f0eef101 Mon Sep 17 00:00:00 2001 From: Jan K9f Date: Wed, 21 May 2025 11:06:35 +0200 Subject: [PATCH] fix: Prettier --- .../game/coinflip/coinflip.component.css | 15 +++++++-- .../game/coinflip/coinflip.component.ts | 32 ++++++++----------- justfile | 4 +++ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/frontend/src/app/feature/game/coinflip/coinflip.component.css b/frontend/src/app/feature/game/coinflip/coinflip.component.css index f896ade..06c9671 100644 --- a/frontend/src/app/feature/game/coinflip/coinflip.component.css +++ b/frontend/src/app/feature/game/coinflip/coinflip.component.css @@ -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 { diff --git a/frontend/src/app/feature/game/coinflip/coinflip.component.ts b/frontend/src/app/feature/game/coinflip/coinflip.component.ts index 06cfb33..1766e4d 100644 --- a/frontend/src/app/feature/game/coinflip/coinflip.component.ts +++ b/frontend/src/app/feature/game/coinflip/coinflip.component.ts @@ -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(); diff --git a/justfile b/justfile index 1d68253..4fc777c 100644 --- a/justfile +++ b/justfile @@ -21,3 +21,7 @@ build-be: # Builds the frontend docker image build-fe: docker buildx build -f frontend/.docker/Dockerfile -t git.kjan.de/szut/casino-frontend:latest frontend + +# Formats the code duh +format: + cd frontend && bunx prettier --write "src/**/*.{ts,html,css,scss}"