Skip to content

Commit

Permalink
Run format and ignore pocketbase
Browse files Browse the repository at this point in the history
  • Loading branch information
phamduylong committed Sep 20, 2024
1 parent 0c9f38b commit 5e8f821
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 27 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
pnpm-lock.yaml
package-lock.json
yarn.lock
pocketbase
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ After everything is set up, you shall have a directory named **AliasWebBased** i
npm run dev -- --open
```

A new browser window should open with the application preseting.
A new browser window should open with the application presenting.

## Notes

Expand Down
31 changes: 16 additions & 15 deletions src/lib/components/ResultModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
import { getModalStore } from '@skeletonlabs/skeleton';
import { CircleX } from 'lucide-svelte';
const modalStore = getModalStore();
const baseCss : string = "flex w-1/2 justify-center h-full card"
let result : string = "";
let team1Css : string = baseCss, team2Css : string = baseCss;
if($modalStore[0]) {
if($modalStore[0].meta.team1_score > $modalStore[0].meta.team2_score) {
team1Css += " variant-ghost-success";
team2Css += " variant-ghost-error";
result = "Team " + $modalStore[0].meta.team1 + " wins!";
} else if($modalStore[0].meta.team1_score < $modalStore[0].meta.team2_score) {
team1Css += " variant-ghost-error";
team2Css += " variant-ghost-success";
result = "Team " + $modalStore[0].meta.team2 + " wins!";
const baseCss: string = 'flex w-1/2 justify-center h-full card';
let result: string = '';
let team1Css: string = baseCss,
team2Css: string = baseCss;
if ($modalStore[0]) {
if ($modalStore[0].meta.team1_score > $modalStore[0].meta.team2_score) {
team1Css += ' variant-ghost-success';
team2Css += ' variant-ghost-error';
result = 'Team ' + $modalStore[0].meta.team1 + ' wins!';
} else if ($modalStore[0].meta.team1_score < $modalStore[0].meta.team2_score) {
team1Css += ' variant-ghost-error';
team2Css += ' variant-ghost-success';
result = 'Team ' + $modalStore[0].meta.team2 + ' wins!';
} else {
team1Css += " variant-ghost-surface";
team2Css += " variant-ghost-surface";
team1Css += ' variant-ghost-surface';
team2Css += ' variant-ghost-surface';
result = "It's a tie!";
}
}
Expand All @@ -28,7 +29,7 @@
<h3 class="h3 my-2 mx-4">Game result: {result}</h3>
<button class="my-2 mx-4" on:click={() => modalStore.clear()}><CircleX /></button>
</div>
<hr/>
<hr />
<div class="flex w-full h-full divide-x-2F">
<div class={team1Css}>
<p class="m-10 text-center">
Expand Down
14 changes: 12 additions & 2 deletions src/lib/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ export function validateGame(game: Game): string[] {
erroneousMessages.push('Game ID is invalid');
}

if (!game.team1 || typeof game.team1 !== 'string' || game.team1 === '' || game.team1.length > 16) {
if (
!game.team1 ||
typeof game.team1 !== 'string' ||
game.team1 === '' ||
game.team1.length > 16
) {
erroneousMessages.push('Name of team 1 is invalid');
}

if (!game.team2 || typeof game.team2 !== 'string' || game.team2 === '' || game.team2.length > 16) {
if (
!game.team2 ||
typeof game.team2 !== 'string' ||
game.team2 === '' ||
game.team2.length > 16
) {
erroneousMessages.push('Name of team 2 is invalid');
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<Toast />

<!-- Singleton Modal -->
<Modal components={modalRegistry}/>
<Modal components={modalRegistry} />
<!-- App Bar -->
<AppBar>
<svelte:fragment slot="lead">
Expand Down
28 changes: 21 additions & 7 deletions src/routes/create/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,27 @@
</svelte:head>

{#if form?.success}
<!-- Game was created successfully, let's show users how to share the game -->
<h1 class="h1 text-center mt-12 mx-4 md:mt-20 font-bold">Copy game URL</h1>
<h3 class="h3 text-center mt-12 mx-4 md:mt-20 font-bold">Copy and share the game URL to play with friends</h3>
<div class="w-4/5 md:w-1/2 relative top-[15%] left-1/2 -translate-x-1/2 -translate-y-1/2 text-token card variant-soft p-4 flex items-center gap-4">
<input title="Game URL" class="input" type="text" readonly={true} value="{browser ? window.location.origin : ''}/game/{form?.gameId}" data-clipboard="gameURL" />
<button title="Copy game URL" use:clipboard={{ input: 'gameURL' }} class="btn variant-filled"><p class="font-bold">Copy</p><Clipboard/></button>
</div>
<!-- Game was created successfully, let's show users how to share the game -->
<h1 class="h1 text-center mt-12 mx-4 md:mt-20 font-bold">Copy game URL</h1>
<h3 class="h3 text-center mt-12 mx-4 md:mt-20 font-bold">
Copy and share the game URL to play with friends
</h3>
<div
class="w-4/5 md:w-1/2 relative top-[15%] left-1/2 -translate-x-1/2 -translate-y-1/2 text-token card variant-soft p-4 flex items-center gap-4"
>
<input
title="Game URL"
class="input"
type="text"
readonly={true}
value="{browser ? window.location.origin : ''}/game/{form?.gameId}"
data-clipboard="gameURL"
/>
<button title="Copy game URL" use:clipboard={{ input: 'gameURL' }} class="btn variant-filled"
><p class="font-bold">Copy</p>
<Clipboard /></button
>
</div>
{:else}
<h1 class="h1 text-center mt-12 md:mt-20 font-bold">Create a new game</h1>
<form
Expand Down
2 changes: 1 addition & 1 deletion src/routes/game/[gameid]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
})
.catch((err) => {
console.error(err);
const toast : ToastSettings = {
const toast: ToastSettings = {
message: `Failed to fetch game result. Error: ${err}`,
timeout: 4000,
background: 'variant-filled-error'
Expand Down

0 comments on commit 5e8f821

Please sign in to comment.