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
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:
parent
8b6e026e0a
commit
bb5f26ab60
3 changed files with 30 additions and 21 deletions
|
@ -98,9 +98,18 @@ button:not([disabled]):active {
|
||||||
|
|
||||||
/* Animation for results */
|
/* Animation for results */
|
||||||
@keyframes popIn {
|
@keyframes popIn {
|
||||||
0% { transform: scale(0.8); opacity: 0; }
|
0% {
|
||||||
70% { transform: scale(1.1); opacity: 1; }
|
transform: scale(0.8);
|
||||||
100% { transform: scale(1); opacity: 1; }
|
opacity: 0;
|
||||||
|
}
|
||||||
|
70% {
|
||||||
|
transform: scale(1.1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-text {
|
.result-text {
|
||||||
|
|
|
@ -20,14 +20,7 @@ import { CoinflipGame, CoinflipRequest } from './models/coinflip.model';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-coinflip',
|
selector: 'app-coinflip',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [AnimatedNumberComponent, CurrencyPipe, FormsModule, CommonModule, NgIf, NgClass],
|
||||||
AnimatedNumberComponent,
|
|
||||||
CurrencyPipe,
|
|
||||||
FormsModule,
|
|
||||||
CommonModule,
|
|
||||||
NgIf,
|
|
||||||
NgClass
|
|
||||||
],
|
|
||||||
templateUrl: './coinflip.component.html',
|
templateUrl: './coinflip.component.html',
|
||||||
styleUrl: './coinflip.component.css',
|
styleUrl: './coinflip.component.css',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
@ -71,15 +64,15 @@ export default class CoinflipComponent implements OnInit {
|
||||||
updateBet(event: Event) {
|
updateBet(event: Event) {
|
||||||
const inputElement = event.target as HTMLInputElement;
|
const inputElement = event.target as HTMLInputElement;
|
||||||
let value = Number(inputElement.value);
|
let value = Number(inputElement.value);
|
||||||
|
|
||||||
// Reset invalid bet state
|
// Reset invalid bet state
|
||||||
this.isInvalidBet.set(false);
|
this.isInvalidBet.set(false);
|
||||||
|
|
||||||
// Enforce minimum bet of 1
|
// Enforce minimum bet of 1
|
||||||
if (value <= 0) {
|
if (value <= 0) {
|
||||||
value = 1;
|
value = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cap bet at available balance and show feedback
|
// Cap bet at available balance and show feedback
|
||||||
if (value > this.balance()) {
|
if (value > this.balance()) {
|
||||||
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
|
// Update the input field directly to show the user the max value
|
||||||
inputElement.value = String(value);
|
inputElement.value = String(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update signals
|
// Update signals
|
||||||
this.betInputValue.set(value);
|
this.betInputValue.set(value);
|
||||||
this.currentBet.set(value);
|
this.currentBet.set(value);
|
||||||
|
@ -220,29 +213,32 @@ export default class CoinflipComponent implements OnInit {
|
||||||
if (navigationKeys.includes(event.key)) {
|
if (navigationKeys.includes(event.key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only allow numbers
|
// Only allow numbers
|
||||||
if (!/^\d$/.test(event.key)) {
|
if (!/^\d$/.test(event.key)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the value that would result after the keypress
|
// Get the value that would result after the keypress
|
||||||
const input = event.target as HTMLInputElement;
|
const input = event.target as HTMLInputElement;
|
||||||
const currentValue = input.value;
|
const currentValue = input.value;
|
||||||
const cursorPosition = input.selectionStart || 0;
|
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);
|
const numValue = Number(newValue);
|
||||||
|
|
||||||
// Prevent values greater than balance
|
// Prevent values greater than balance
|
||||||
if (numValue > this.balance()) {
|
if (numValue > this.balance()) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We removed the paste handler for simplicity since the updateBet method
|
// We removed the paste handler for simplicity since the updateBet method
|
||||||
// will handle any value that gets into the input field
|
// will handle any value that gets into the input field
|
||||||
|
|
||||||
getResultClass() {
|
getResultClass() {
|
||||||
if (!this.gameResult()) return '';
|
if (!this.gameResult()) return '';
|
||||||
const result = this.gameResult();
|
const result = this.gameResult();
|
||||||
|
|
4
justfile
4
justfile
|
@ -21,3 +21,7 @@ build-be:
|
||||||
# Builds the frontend docker image
|
# Builds the frontend docker image
|
||||||
build-fe:
|
build-fe:
|
||||||
docker buildx build -f frontend/.docker/Dockerfile -t git.kjan.de/szut/casino-frontend:latest frontend
|
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}"
|
||||||
|
|
Reference in a new issue