This commit is contained in:
2026-03-16 07:35:20 +01:00
commit 5d54d1cf7b
20 changed files with 2676 additions and 0 deletions

23
frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
node_modules
# Output
.output
.vercel
.netlify
.wrangler
/.svelte-kit
/build
# OS
.DS_Store
Thumbs.db
# Env
.env
.env.*
!.env.example
!.env.test
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

1
frontend/.npmrc Normal file
View File

@@ -0,0 +1 @@
engine-strict=true

42
frontend/README.md Normal file
View File

@@ -0,0 +1,42 @@
# sv
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
## Creating a project
If you're seeing this, you've probably already done this step. Congrats!
```sh
# create a new project
npx sv create my-app
```
To recreate this project with the same configuration:
```sh
# recreate this project
npx sv@0.12.7 create --template minimal --types ts --install npm frontend
```
## Developing
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
```sh
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
## Building
To create a production version of your app:
```sh
npm run build
```
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.

1666
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

23
frontend/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "frontend",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"prepare": "svelte-kit sync || echo ''",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^7.0.0",
"@sveltejs/kit": "^2.50.2",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"svelte": "^5.51.0",
"svelte-check": "^4.4.2",
"typescript": "^5.9.3",
"vite": "^7.3.1"
}
}

13
frontend/src/app.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
// See https://svelte.dev/docs/kit/types#app.d.ts
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
export {};

11
frontend/src/app.html Normal file
View File

@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View File

@@ -0,0 +1,350 @@
<script>
let { card } = $props();
const RARITY_BADGE = {
common: { symbol: "C", label: "Common", bg: "#c8c8c8", color: "#333" },
uncommon: { symbol: "U", label: "Uncommon", bg: "#4a7a50", color: "#fff" },
rare: { symbol: "R", label: "Rare", bg: "#2a5a9b", color: "#fff" },
super_rare: { symbol: "SR", label: "Super Rare", bg: "#7a3a9b", color: "#fff" },
epic: { symbol: "E", label: "Epic", bg: "#9b3a3a", color: "#fff" },
legendary: { symbol: "L", label: "Legendary", bg: "#b87820", color: "#fff" },
};
const TYPE_COLORS = {
person: { bg: "#f0e0c8", header: "#b87830" },
location: { bg: "#d8e8d4", header: "#4a7a50" },
artwork: { bg: "#e4d4e8", header: "#7a5090" },
life_form: { bg: "#ccdce8", header: "#3a6878" },
conflict: { bg: "#e8d4d4", header: "#8b2020" },
group: { bg: "#e8e4d0", header: "#748c12" },
science_thing: { bg: "#c7c5c1", header: "#060c17" },
vehicle: { bg: "#c7c1c4", header: "#801953" },
other: { bg: "#dddad4", header: "#6a6860" },
};
const FOIL_RARITIES = new Set(["super_rare", "epic", "legendary"]);
let rarity = $derived(card.card_rarity);
let badge = $derived(RARITY_BADGE[rarity] ?? RARITY_BADGE.common);
let foil = $derived(FOIL_RARITIES.has(rarity))
let foilOffset = $derived(foil ? `${-(Math.random() * 5).toFixed(2)}s` : '0s');
let super_rare = $derived(rarity == "super_rare");
let epic = $derived(rarity == "epic");
let legendary = $derived(rarity === "legendary");
let colors = $derived(TYPE_COLORS[card.card_type] ?? TYPE_COLORS.other);
let typeLabel = $derived(card.card_type.charAt(0).toUpperCase() + card.card_type.slice(1).replace("_", " "));
let wikiUrl = $derived("https://en.wikipedia.org/wiki/" + encodeURIComponent(card.name.replace(/ /g, "_")));
</script>
<div class="card" class:foil class:super_rare class:epic class:legendary style="--foil-offset: {foilOffset}">
<div class="card-inner" style="--bg: {colors.bg}; --header: {colors.header}">
<div class="card-header">
<span class="card-name">{card.name}</span>
<span class="card-type-badge">{typeLabel}</span>
</div>
<div class="card-image-wrap">
{#if card.image_link}
<img src={card.image_link} alt={card.name} class="card-image" />
{:else}
<div class="card-image-placeholder">
<span>{card.name[0]}</span>
</div>
{/if}
<div class="rarity-badge" title={badge.label} style="--rb: {badge.bg}; --rc: {badge.color}">{badge.symbol}</div>
<a href={wikiUrl} target="_blank" rel="noopener noreferrer" class="wiki-link" title="Open Wikipedia article">
<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<circle cx="25" cy="25" r="24" fill="white" stroke="#888" stroke-width="1"/>
<text x="25" y="33" text-anchor="middle" font-family="serif" font-size="28" font-weight="bold" fill="#000">W</text>
</svg>
</a>
<div class="cost-bubbles">
{#each { length: card.cost } as _}
<div class="cost-bubble"></div>
{/each}
</div>
</div>
<div class="card-divider"></div>
<div class="card-text">{card.text}</div>
<div class="card-footer">
<span class="stat">ATK <strong>{card.attack}</strong></span>
<span class="card-date">{new Date(card.created_at).toLocaleDateString()}</span>
<span class="stat">DEF <strong>{card.defense}</strong></span>
</div>
</div>
</div>
<style>
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');
.card {
width: 300px;
border-radius: 12px;
padding: 7px;
background: #111;
border: 2px solid #111;
box-shadow: 0 4px 24px rgba(0,0,0,0.5);
font-family: 'Crimson Text', serif;
position: relative;
transition: transform 0.2s ease, box-shadow 0.2s ease;
flex-shrink: 0;
user-select: none;
-webkit-user-select: none;
}
.card:hover {
transform: translateY(-4px) scale(1.02);
box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.card.foil::before {
content: "";
position: absolute;
inset: 0;
border-radius: 12px;
animation: foil-shift 2.5s ease-in-out infinite alternate;
animation-delay: var(--foil-offset, 0s);
pointer-events: none;
z-index: 2;
mix-blend-mode: screen;
}
.card.super_rare::before {
background: repeating-linear-gradient(
105deg,
transparent 0%,
rgba(255,255,255,0.15) 20%,
rgba(200,220,255,0.2) 35%,
rgba(255,255,255,0.15) 50%,
transparent 70%
);
background-size: 300% 300%;
}
.card.foil.epic::before {
background: repeating-linear-gradient(
105deg,
rgba(255,0,128,0.3) 0%,
rgba(255,200,0,0.3) 10%,
rgba(0,255,128,0.3) 20%,
rgba(0,200,255,0.3) 30%,
rgba(128,0,255,0.3) 40%,
rgba(255,0,128,0.3) 50%
);
background-size: 300% 300%;
}
.card.foil.legendary::before {
background: repeating-linear-gradient(
105deg,
rgba(255,215,0,0.30) 0%,
rgba(255,180,0,0.15) 15%,
rgba(255,255,180,0.35) 30%,
rgba(255,200,0,0.15) 45%,
rgba(255,215,0,0.30) 60%
);
animation-duration: 1.8s;
background-size: 300% 300%;
}
@keyframes foil-shift {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
.card-inner {
border-radius: 8px;
overflow: hidden;
background: var(--bg);
border: 2px solid #000;
display: flex;
flex-direction: column;
}
.card-header {
padding: 9px 12px 7px;
background: var(--header);
border-bottom: 2px solid #000;
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 8px;
}
.card-name {
font-family: 'Cinzel', serif;
font-size: 13px;
font-weight: 700;
color: #fff;
line-height: 1.3;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.card-type-badge {
font-family: 'Cinzel', serif;
font-size: 9px;
color: rgba(255,255,255,0.95);
text-transform: uppercase;
letter-spacing: 0.05em;
white-space: nowrap;
text-shadow: 0 1px 3px rgba(0,0,0,0.7);
background: rgba(0,0,0,0.25);
padding: 1px 5px;
border-radius: 3px;
}
.card-image-wrap {
position: relative;
width: 100%;
aspect-ratio: 4/3;
background: #222;
overflow: hidden;
border-bottom: 2px solid #000;
}
.card-image {
width: 100%;
height: 100%;
object-fit: cover;
object-position: 50% 25%;
display: block;
}
.card-image-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background: #ddd;
font-family: 'Cinzel', serif;
font-size: 64px;
color: rgba(0,0,0,0.15);
}
.rarity-badge {
position: absolute;
top: 7px;
left: 7px;
width: 26px;
height: 26px;
border-radius: 50%;
background: var(--rb);
border: 2.5px solid #000;
color: var(--rc);
font-family: 'Cinzel', serif;
font-size: 9px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
z-index: 3;
letter-spacing: -0.02em;
}
.wiki-link {
position: absolute;
top: 7px;
right: 7px;
width: 26px;
height: 26px;
border-radius: 50%;
background: rgba(255,255,255,0.92);
border: 1.5px solid #000;
display: flex;
align-items: center;
justify-content: center;
z-index: 3;
transition: background 0.15s, transform 0.15s;
}
.wiki-link:hover {
background: rgba(255,255,255,1);
transform: scale(1.15);
}
.card-divider {
height: 2px;
background: #000;
}
.card-text {
padding: 10px 12px;
font-size: 13px;
line-height: 1.55;
color: #1a1208;
font-style: italic;
background: #f0e6cc;
border-bottom: 2px solid #000;
height: 110px;
overflow: hidden;
}
.card-footer {
padding: 7px 12px;
background: #e8d8b8;
display: flex;
justify-content: space-between;
align-items: center;
}
.stat {
font-family: 'Cinzel', serif;
font-size: 11px;
color: #2a2010;
letter-spacing: 0.03em;
}
.stat strong {
color: #000;
font-size: 15px;
}
.card-date {
font-size: 10px;
color: rgba(0,0,0,0.5);
font-style: italic;
font-family: 'Crimson Text', serif;
}
.cost-bubbles {
position: absolute;
bottom: 6px;
left: 8px;
display: flex;
gap: 3px;
flex-wrap: wrap;
justify-content: center;
max-width: calc(100% - 16px);
}
.cost-bubble {
width: 16px;
height: 16px;
border-radius: 50%;
background: #6ea0ec;
border: 2.5px solid #000;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
color: #08152c;
font-size: 12px;
font-weight: 700;
font-family: 'Cinzel', serif;
line-height: 1;
}
</style>

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.

View File

@@ -0,0 +1,11 @@
<script lang="ts">
import favicon from '$lib/assets/favicon.svg';
let { children } = $props();
</script>
<svelte:head>
<link rel="icon" href={favicon} />
</svelte:head>
{@render children()}

View File

@@ -0,0 +1,63 @@
<script>
import Card from "$lib/Card.svelte";
let cards = $state([]);
let loading = $state(false);
async function openPack() {
loading = true;
try {
const res = await fetch("http://localhost:8000/pack/14");
if (!res.ok) throw new Error(`HTTP ${res.status}`);
cards = await res.json();
} catch (e) {
console.error("Failed to open pack:", e);
} finally {
loading = false;
}
}
</script>
<main>
<button onclick={openPack} disabled={loading}>
{loading ? "Opening..." : "Open Pack"}
</button>
<div class="pack">
{#each cards as card}
<Card {card} />
{/each}
</div>
</main>
<style>
main {
min-height: 100vh;
background: #0d0a04;
padding: 2rem;
}
button {
display: block;
margin: 0 auto 2rem;
padding: 10px 28px;
font-family: 'Cinzel', serif;
font-size: 14px;
background: #2e1c05;
color: #f0d080;
border: 1px solid #6b4c1e;
border-radius: 6px;
cursor: pointer;
}
button:hover:not(:disabled) {
background: #3d2507;
}
.pack {
display: flex;
flex-wrap: wrap;
gap: 16px;
justify-content: center;
}
</style>

View File

@@ -0,0 +1,3 @@
# allow crawling everything by default
User-agent: *
Disallow:

17
frontend/svelte.config.js Normal file
View File

@@ -0,0 +1,17 @@
import adapter from '@sveltejs/adapter-auto';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter()
},
vitePlugin: {
dynamicCompileOptions: ({ filename }) =>
filename.includes('node_modules') ? undefined : { runes: true }
}
};
export default config;

20
frontend/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"rewriteRelativeImportExtensions": true,
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// To make changes to top-level options such as include and exclude, we recommend extending
// the generated config; see https://svelte.dev/docs/kit/configuration#typescript
}

6
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
});