-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Define database schema * Migrate home page to Astro * Enable actions and server output * Migrate new game page to Astro * Migrate dealer page to Astro * Fully migrate new game page to Astro * Enable view transitions * New branding * Refactor bids and tricks pages * Prevent flash before JS initialization * Add logic to end game * Add CI workflow to migrate the database * Deploy using Astro Studio
- Loading branch information
1 parent
b6abbe6
commit 6610d35
Showing
54 changed files
with
1,380 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Astro Studio | ||
|
||
env: | ||
ASTRO_STUDIO_APP_TOKEN: ${{secrets.ASTRO_STUDIO_APP_TOKEN }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
DB: | ||
permissions: | ||
contents: read | ||
actions: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Verify database schema | ||
uses: withastro/action-studio@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { defineDb, defineTable, column, NOW } from 'astro:db'; | ||
|
||
const League = defineTable({ | ||
columns: { | ||
id: column.text({ primaryKey: true }), | ||
name: column.text({ optional: true }), | ||
}, | ||
}); | ||
|
||
const Game = defineTable({ | ||
columns: { | ||
id: column.text({ primaryKey: true }), | ||
leagueId: column.text({ | ||
references: () => League.columns.id, | ||
optional: true, | ||
}), | ||
startedAt: column.date({ default: NOW }), | ||
endedAt: column.date({ optional: true }), | ||
}, | ||
}); | ||
|
||
const Player = defineTable({ | ||
columns: { | ||
id: column.text({ primaryKey: true }), | ||
name: column.text(), | ||
}, | ||
}); | ||
|
||
const PlayerInGame = defineTable({ | ||
columns: { | ||
id: column.text({ primaryKey: true }), | ||
gameId: column.text({ references: () => Game.columns.id }), | ||
playerId: column.text({ references: () => Player.columns.id }), | ||
position: column.number(), | ||
}, | ||
}); | ||
|
||
const Scores = defineTable({ | ||
columns: { | ||
id: column.text({ primaryKey: true }), | ||
gameId: column.text({ references: () => Game.columns.id }), | ||
playerId: column.text({ references: () => Player.columns.id }), | ||
round: column.number(), | ||
bid: column.number({ optional: true }), | ||
tricks: column.number({ optional: true }), | ||
}, | ||
indexes: [ | ||
{ | ||
on: ['gameId', 'playerId', 'round'], | ||
unique: true, | ||
}, | ||
], | ||
}); | ||
|
||
// https://astro.build/db/config | ||
export default defineDb({ | ||
tables: { | ||
League, | ||
Game, | ||
Player, | ||
PlayerInGame, | ||
Scores, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { db, Game, Player, PlayerInGame, Scores } from 'astro:db'; | ||
|
||
import { createId } from '../src/utils/id'; | ||
|
||
const games = [ | ||
{ id: 'KVMGQ' }, | ||
// TODO: Add complete game data | ||
{ id: 'MFFRA', endedAt: new Date() }, | ||
]; | ||
|
||
const players = [ | ||
{ id: createId(), name: 'Apple' }, | ||
{ id: createId(), name: 'Banana' }, | ||
{ id: createId(), name: 'Cherry' }, | ||
{ id: createId(), name: 'Dragonfruit' }, | ||
{ id: createId(), name: 'Elderflower' }, | ||
]; | ||
|
||
const playersInGame = players.slice(0, 3).map((player, index) => ({ | ||
id: createId(), | ||
gameId: games[0]?.id as string, | ||
playerId: player.id, | ||
position: index, | ||
})); | ||
|
||
const scores = [ | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[0]?.id as string, | ||
round: 1, | ||
bid: 1, | ||
tricks: 1, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[1]?.id as string, | ||
round: 1, | ||
bid: 0, | ||
tricks: 0, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[2]?.id as string, | ||
round: 1, | ||
bid: 1, | ||
tricks: 0, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[0]?.id as string, | ||
round: 2, | ||
bid: 1, | ||
tricks: 0, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[1]?.id as string, | ||
round: 2, | ||
bid: 1, | ||
tricks: 1, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[2]?.id as string, | ||
round: 2, | ||
bid: 1, | ||
tricks: 1, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[0]?.id as string, | ||
round: 3, | ||
bid: 0, | ||
tricks: 0, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[1]?.id as string, | ||
round: 3, | ||
bid: 2, | ||
tricks: 2, | ||
}, | ||
{ | ||
gameId: games[0]?.id as string, | ||
playerId: players[2]?.id as string, | ||
round: 3, | ||
bid: 1, | ||
tricks: 1, | ||
}, | ||
].map((score) => ({ | ||
id: `${score.gameId}-${score.playerId}-${score.round}`, | ||
...score, | ||
})); | ||
|
||
// https://astro.build/db/seed | ||
export default async function seed() { | ||
await db.insert(Player).values(players); | ||
await db.insert(Game).values(games); | ||
await db.insert(PlayerInGame).values(playersInGame); | ||
await db.insert(Scores).values(scores); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions
8
public/icons/default/site.webmanifest → public/icons/site.webmanifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.