Bedstemors Flæskesteg: animated step-by-step Danish roast (Advent of AI Slop Day 4)

This commit is contained in:
hermes committed 2026-12-05 00:20:54 +00:00
commit 7774e3aa1b
16 files changed
+2255

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
node_modules/
dist/
check_*.png
preview_shot.png
smoke.png
+37
View File
@@ -0,0 +1,37 @@
# Bedstemors Flæskesteg — Advent of AI Slop, Day 4
> Visualize step by step how to cook your favorite dish. Is it your grandmother's recipe?
Grandma's flæskesteg — Danish roast pork with crackling, rødkål and brunede
kartofler — told in ten steps through one animated canvas kitchen.
- **Ten steps, one kitchen.** Each step swaps the canvas scene: scoring the
crackling, the glowing oven at 200 °C, bubbling rødkål, the amber caramel
swirl for brunede kartofler, carving, and the final plate by candlelight.
- **Timers that actually run.** Every timed step has a real countdown. Demo
mode (default) runs them 60× faster so you can finish Christmas dinner in
the time it takes to boil a egg.
- **Servings slider** scales the shopping list from 1 to 10 people.
- **Progress + persistence.** Checked steps, servings and demo mode survive a
reload (localStorage). Complete all ten for the *Velbekomme!* confetti.
The crackling must crack, not chew.
## Stack
Vite + TypeScript, no dependencies beyond the template. The kitchen is a plain
2D canvas; every animation is a pure function of time (no particle state).
## Develop
```sh
pnpm install
pnpm dev
pnpm build # tsc + vite build
```
Built with `VITE_SITE_URL=https://pages.obahan.xyz/lullu/advent-of-slop-04-flaeskesteg`
so the og: tags resolve. `scripts/smoke4.py` smoke-tests the built `dist/`
with headless Playwright (interactions, timer, persistence, win overlay).
Live: <https://pages.obahan.xyz/lullu/advent-of-slop-04-flaeskesteg/>
+23
View File
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
<title>Bedstemors Flæskesteg — Advent of AI Slop Day 4</title>
<meta name="description" content="Grandma's flæskesteg, step by step: crackling that cracks like a campfire, simmering rødkål, amber brunede kartofler. Animated kitchen, real timers, one honest Danish recipe. Made for Advent of AI Slop Day 4." />
<meta property="og:type" content="website" />
<meta property="og:title" content="Bedstemors Flæskesteg — Advent of AI Slop Day 4" />
<meta property="og:description" content="Cook Denmark's national dish step by step: an animated kitchen, working timers, and crackling that must crack, not chew." />
<meta property="og:url" content="%VITE_SITE_URL%/" />
<meta property="og:image" content="%VITE_SITE_URL%/preview.png" />
<meta name="twitter:card" content="summary_large_image" />
<script type="module" src="./src/badge.ts"></script>
<script type="module" src="./src/main.ts"></script>
</head>
<body>
<!-- day: the day of December this was made for, 1 to 24. name: the title of that day. -->
<advent-badge day="4" name="Cooking a dish"></advent-badge>
<main id="app"></main>
</body>
</html>
+15
View File
@@ -0,0 +1,15 @@
{
"name": "advent-of-slop-entry",
"type": "module",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"packageManager": "pnpm@11.5.2",
"devDependencies": {
"typescript": "^7.0.2",
"vite": "^8.3.8"
}
}
+717
View File
@@ -0,0 +1,717 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
devDependencies:
typescript:
specifier: ^7.0.2
version: 7.0.2
vite:
specifier: ^8.3.8
version: 8.3.8
packages:
'@emnapi/core@2.0.0-beta.2':
resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==}
'@emnapi/runtime@2.0.0-beta.2':
resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==}
'@emnapi/wasi-threads@2.2.0':
resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==}
'@napi-rs/wasm-runtime@1.2.6':
resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==}
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
peerDependencies:
'@emnapi/core': ^1.7.1 || 2.0.0-beta.2
'@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2
'@oxc-project/types@0.156.0':
resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==}
'@rolldown/binding-android-arm-eabi@1.2.19':
resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
'@rolldown/binding-android-arm64@1.2.19':
resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
'@rolldown/binding-darwin-arm64@1.2.19':
resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
'@rolldown/binding-darwin-x64@1.2.19':
resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
'@rolldown/binding-freebsd-x64@1.2.19':
resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
'@rolldown/binding-linux-arm-gnueabihf@1.2.19':
resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@rolldown/binding-linux-arm64-gnu@1.2.19':
resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-arm64-musl@1.2.19':
resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rolldown/binding-linux-ppc64-gnu@1.2.19':
resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-s390x-gnu@1.2.19':
resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-x64-gnu@1.2.19':
resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-x64-musl@1.2.19':
resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [musl]
'@rolldown/binding-openharmony-arm64@1.2.19':
resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
'@rolldown/binding-wasm32-wasi@1.2.19':
resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==}
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
cpu: [wasm32]
'@rolldown/binding-win32-arm64-msvc@1.2.19':
resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
'@rolldown/binding-win32-x64-msvc@1.2.19':
resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
'@rolldown/pluginutils@1.1.1':
resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==}
'@tybys/wasm-util@0.10.5':
resolution: {integrity: sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==}
'@typescript/typescript-aix-ppc64@7.0.2':
resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==}
engines: {node: '>=16.20.0'}
cpu: [ppc64]
os: [aix]
'@typescript/typescript-darwin-arm64@7.0.2':
resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [darwin]
'@typescript/typescript-darwin-x64@7.0.2':
resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [darwin]
'@typescript/typescript-freebsd-arm64@7.0.2':
resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [freebsd]
'@typescript/typescript-freebsd-x64@7.0.2':
resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [freebsd]
'@typescript/typescript-linux-arm64@7.0.2':
resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [linux]
'@typescript/typescript-linux-arm@7.0.2':
resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==}
engines: {node: '>=16.20.0'}
cpu: [arm]
os: [linux]
'@typescript/typescript-linux-loong64@7.0.2':
resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==}
engines: {node: '>=16.20.0'}
cpu: [loong64]
os: [linux]
'@typescript/typescript-linux-mips64el@7.0.2':
resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==}
engines: {node: '>=16.20.0'}
cpu: [mips64el]
os: [linux]
'@typescript/typescript-linux-ppc64@7.0.2':
resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==}
engines: {node: '>=16.20.0'}
cpu: [ppc64]
os: [linux]
'@typescript/typescript-linux-riscv64@7.0.2':
resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==}
engines: {node: '>=16.20.0'}
cpu: [riscv64]
os: [linux]
'@typescript/typescript-linux-s390x@7.0.2':
resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==}
engines: {node: '>=16.20.0'}
cpu: [s390x]
os: [linux]
'@typescript/typescript-linux-x64@7.0.2':
resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [linux]
'@typescript/typescript-netbsd-arm64@7.0.2':
resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [netbsd]
'@typescript/typescript-netbsd-x64@7.0.2':
resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [netbsd]
'@typescript/typescript-openbsd-arm64@7.0.2':
resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [openbsd]
'@typescript/typescript-openbsd-x64@7.0.2':
resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [openbsd]
'@typescript/typescript-sunos-x64@7.0.2':
resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [sunos]
'@typescript/typescript-win32-arm64@7.0.2':
resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==}
engines: {node: '>=16.20.0'}
cpu: [arm64]
os: [win32]
'@typescript/typescript-win32-x64@7.0.2':
resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==}
engines: {node: '>=16.20.0'}
cpu: [x64]
os: [win32]
detect-libc@2.1.2:
resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==}
engines: {node: '>=8'}
fdir@6.5.0:
resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}
engines: {node: '>=12.0.0'}
peerDependencies:
picomatch: ^3 || ^4
peerDependenciesMeta:
picomatch:
optional: true
fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
lightningcss-android-arm64@1.33.0:
resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [android]
lightningcss-darwin-arm64@1.33.0:
resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [darwin]
lightningcss-darwin-x64@1.33.0:
resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [darwin]
lightningcss-freebsd-x64@1.33.0:
resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [freebsd]
lightningcss-linux-arm-gnueabihf@1.33.0:
resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==}
engines: {node: '>= 12.0.0'}
cpu: [arm]
os: [linux]
lightningcss-linux-arm64-gnu@1.33.0:
resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
libc: [glibc]
lightningcss-linux-arm64-musl@1.33.0:
resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [linux]
libc: [musl]
lightningcss-linux-x64-gnu@1.33.0:
resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
libc: [glibc]
lightningcss-linux-x64-musl@1.33.0:
resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [linux]
libc: [musl]
lightningcss-win32-arm64-msvc@1.33.0:
resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==}
engines: {node: '>= 12.0.0'}
cpu: [arm64]
os: [win32]
lightningcss-win32-x64-msvc@1.33.0:
resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==}
engines: {node: '>= 12.0.0'}
cpu: [x64]
os: [win32]
lightningcss@1.33.0:
resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==}
engines: {node: '>= 12.0.0'}
nanoid@3.3.20:
resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
picomatch@4.0.7:
resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
engines: {node: '>=12'}
postcss@8.5.33:
resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==}
engines: {node: ^10 || ^12 || >=14}
rolldown@1.2.19:
resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
source-map-js@1.2.4:
resolution: {integrity: sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==}
engines: {node: '>=6.0.0'}
tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
tslib@2.9.1:
resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==}
typescript@7.0.2:
resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==}
engines: {node: '>=16.20.0'}
hasBin: true
vite@8.3.8:
resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
'@types/node': ^20.19.0 || >=22.12.0
'@vitejs/devtools': ^0.7.1 || ^0.8.0
esbuild: ^0.27.0 || ^0.28.0
jiti: '>=1.21.0'
less: ^4.0.0
sass: ^1.70.0
sass-embedded: ^1.70.0
stylus: '>=0.54.8'
sugarss: ^5.0.0
terser: ^5.16.0
tsx: ^4.8.1
yaml: ^2.4.2
peerDependenciesMeta:
'@types/node':
optional: true
'@vitejs/devtools':
optional: true
esbuild:
optional: true
jiti:
optional: true
less:
optional: true
sass:
optional: true
sass-embedded:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
tsx:
optional: true
yaml:
optional: true
snapshots:
'@emnapi/core@2.0.0-beta.2':
dependencies:
'@emnapi/wasi-threads': 2.2.0
tslib: 2.9.1
optional: true
'@emnapi/runtime@2.0.0-beta.2':
dependencies:
tslib: 2.9.1
optional: true
'@emnapi/wasi-threads@2.2.0':
dependencies:
tslib: 2.9.1
optional: true
'@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)':
dependencies:
'@emnapi/core': 2.0.0-beta.2
'@emnapi/runtime': 2.0.0-beta.2
'@tybys/wasm-util': 0.10.5
optional: true
'@oxc-project/types@0.156.0': {}
'@rolldown/binding-android-arm-eabi@1.2.19':
optional: true
'@rolldown/binding-android-arm64@1.2.19':
optional: true
'@rolldown/binding-darwin-arm64@1.2.19':
optional: true
'@rolldown/binding-darwin-x64@1.2.19':
optional: true
'@rolldown/binding-freebsd-x64@1.2.19':
optional: true
'@rolldown/binding-linux-arm-gnueabihf@1.2.19':
optional: true
'@rolldown/binding-linux-arm64-gnu@1.2.19':
optional: true
'@rolldown/binding-linux-arm64-musl@1.2.19':
optional: true
'@rolldown/binding-linux-ppc64-gnu@1.2.19':
optional: true
'@rolldown/binding-linux-s390x-gnu@1.2.19':
optional: true
'@rolldown/binding-linux-x64-gnu@1.2.19':
optional: true
'@rolldown/binding-linux-x64-musl@1.2.19':
optional: true
'@rolldown/binding-openharmony-arm64@1.2.19':
optional: true
'@rolldown/binding-wasm32-wasi@1.2.19':
dependencies:
'@emnapi/core': 2.0.0-beta.2
'@emnapi/runtime': 2.0.0-beta.2
'@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)
optional: true
'@rolldown/binding-win32-arm64-msvc@1.2.19':
optional: true
'@rolldown/binding-win32-x64-msvc@1.2.19':
optional: true
'@rolldown/pluginutils@1.1.1': {}
'@tybys/wasm-util@0.10.5':
dependencies:
tslib: 2.9.1
optional: true
'@typescript/typescript-aix-ppc64@7.0.2':
optional: true
'@typescript/typescript-darwin-arm64@7.0.2':
optional: true
'@typescript/typescript-darwin-x64@7.0.2':
optional: true
'@typescript/typescript-freebsd-arm64@7.0.2':
optional: true
'@typescript/typescript-freebsd-x64@7.0.2':
optional: true
'@typescript/typescript-linux-arm64@7.0.2':
optional: true
'@typescript/typescript-linux-arm@7.0.2':
optional: true
'@typescript/typescript-linux-loong64@7.0.2':
optional: true
'@typescript/typescript-linux-mips64el@7.0.2':
optional: true
'@typescript/typescript-linux-ppc64@7.0.2':
optional: true
'@typescript/typescript-linux-riscv64@7.0.2':
optional: true
'@typescript/typescript-linux-s390x@7.0.2':
optional: true
'@typescript/typescript-linux-x64@7.0.2':
optional: true
'@typescript/typescript-netbsd-arm64@7.0.2':
optional: true
'@typescript/typescript-netbsd-x64@7.0.2':
optional: true
'@typescript/typescript-openbsd-arm64@7.0.2':
optional: true
'@typescript/typescript-openbsd-x64@7.0.2':
optional: true
'@typescript/typescript-sunos-x64@7.0.2':
optional: true
'@typescript/typescript-win32-arm64@7.0.2':
optional: true
'@typescript/typescript-win32-x64@7.0.2':
optional: true
detect-libc@2.1.2: {}
fdir@6.5.0(picomatch@4.0.7):
optionalDependencies:
picomatch: 4.0.7
fsevents@2.3.3:
optional: true
lightningcss-android-arm64@1.33.0:
optional: true
lightningcss-darwin-arm64@1.33.0:
optional: true
lightningcss-darwin-x64@1.33.0:
optional: true
lightningcss-freebsd-x64@1.33.0:
optional: true
lightningcss-linux-arm-gnueabihf@1.33.0:
optional: true
lightningcss-linux-arm64-gnu@1.33.0:
optional: true
lightningcss-linux-arm64-musl@1.33.0:
optional: true
lightningcss-linux-x64-gnu@1.33.0:
optional: true
lightningcss-linux-x64-musl@1.33.0:
optional: true
lightningcss-win32-arm64-msvc@1.33.0:
optional: true
lightningcss-win32-x64-msvc@1.33.0:
optional: true
lightningcss@1.33.0:
dependencies:
detect-libc: 2.1.2
optionalDependencies:
lightningcss-android-arm64: 1.33.0
lightningcss-darwin-arm64: 1.33.0
lightningcss-darwin-x64: 1.33.0
lightningcss-freebsd-x64: 1.33.0
lightningcss-linux-arm-gnueabihf: 1.33.0
lightningcss-linux-arm64-gnu: 1.33.0
lightningcss-linux-arm64-musl: 1.33.0
lightningcss-linux-x64-gnu: 1.33.0
lightningcss-linux-x64-musl: 1.33.0
lightningcss-win32-arm64-msvc: 1.33.0
lightningcss-win32-x64-msvc: 1.33.0
nanoid@3.3.20: {}
picocolors@1.1.1: {}
picomatch@4.0.7: {}
postcss@8.5.33:
dependencies:
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.4
rolldown@1.2.19:
dependencies:
'@oxc-project/types': 0.156.0
'@rolldown/pluginutils': 1.1.1
optionalDependencies:
'@rolldown/binding-android-arm-eabi': 1.2.19
'@rolldown/binding-android-arm64': 1.2.19
'@rolldown/binding-darwin-arm64': 1.2.19
'@rolldown/binding-darwin-x64': 1.2.19
'@rolldown/binding-freebsd-x64': 1.2.19
'@rolldown/binding-linux-arm-gnueabihf': 1.2.19
'@rolldown/binding-linux-arm64-gnu': 1.2.19
'@rolldown/binding-linux-arm64-musl': 1.2.19
'@rolldown/binding-linux-ppc64-gnu': 1.2.19
'@rolldown/binding-linux-s390x-gnu': 1.2.19
'@rolldown/binding-linux-x64-gnu': 1.2.19
'@rolldown/binding-linux-x64-musl': 1.2.19
'@rolldown/binding-openharmony-arm64': 1.2.19
'@rolldown/binding-wasm32-wasi': 1.2.19
'@rolldown/binding-win32-arm64-msvc': 1.2.19
'@rolldown/binding-win32-x64-msvc': 1.2.19
source-map-js@1.2.4: {}
tinyglobby@0.2.17:
dependencies:
fdir: 6.5.0(picomatch@4.0.7)
picomatch: 4.0.7
tslib@2.9.1:
optional: true
typescript@7.0.2:
optionalDependencies:
'@typescript/typescript-aix-ppc64': 7.0.2
'@typescript/typescript-darwin-arm64': 7.0.2
'@typescript/typescript-darwin-x64': 7.0.2
'@typescript/typescript-freebsd-arm64': 7.0.2
'@typescript/typescript-freebsd-x64': 7.0.2
'@typescript/typescript-linux-arm': 7.0.2
'@typescript/typescript-linux-arm64': 7.0.2
'@typescript/typescript-linux-loong64': 7.0.2
'@typescript/typescript-linux-mips64el': 7.0.2
'@typescript/typescript-linux-ppc64': 7.0.2
'@typescript/typescript-linux-riscv64': 7.0.2
'@typescript/typescript-linux-s390x': 7.0.2
'@typescript/typescript-linux-x64': 7.0.2
'@typescript/typescript-netbsd-arm64': 7.0.2
'@typescript/typescript-netbsd-x64': 7.0.2
'@typescript/typescript-openbsd-arm64': 7.0.2
'@typescript/typescript-openbsd-x64': 7.0.2
'@typescript/typescript-sunos-x64': 7.0.2
'@typescript/typescript-win32-arm64': 7.0.2
'@typescript/typescript-win32-x64': 7.0.2
vite@8.3.8:
dependencies:
lightningcss: 1.33.0
picomatch: 4.0.7
postcss: 8.5.33
rolldown: 1.2.19
tinyglobby: 0.2.17
optionalDependencies:
fsevents: 2.3.3
+5
View File
@@ -0,0 +1,5 @@
# Only install package versions published at least 7 days ago (in minutes).
minimumReleaseAge: 10080
allowBuilds:
esbuild: true
+13
View File
@@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect x="6" y="30" width="52" height="22" rx="8" fill="#7c3d2c"/>
<rect x="10" y="34" width="44" height="14" rx="6" fill="#a4553f"/>
<rect x="8" y="16" width="48" height="16" rx="6" fill="#e8c98a"/>
<g stroke="#8a6a3a" stroke-width="2.5">
<line x1="18" y1="18" x2="18" y2="30"/>
<line x1="28" y1="18" x2="28" y2="30"/>
<line x1="38" y1="18" x2="38" y2="30"/>
<line x1="48" y1="18" x2="48" y2="30"/>
<line x1="10" y1="24" x2="54" y2="24"/>
</g>
<path d="M22 10 q2 -4 0 -7 M32 10 q2 -4 0 -7 M42 10 q2 -4 0 -7" stroke="#f6ecd6" stroke-width="2.5" fill="none" stroke-linecap="round" opacity="0.8"/>
</svg>

After

Width:  |  Height:  |  Size: 695 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

+109
View File
@@ -0,0 +1,109 @@
# Smoke-test the built Day 4 flæskesteg site: interactions, timer, persistence, win overlay.
import http.server, threading, functools, sys, os
DIST = os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else 'dist')
httpd = http.server.ThreadingHTTPServer(('127.0.0.1', 8766), functools.partial(http.server.SimpleHTTPRequestHandler, directory=DIST))
threading.Thread(target=httpd.serve_forever, daemon=True).start()
from playwright.sync_api import sync_playwright
errs, msgs = [], []
with sync_playwright() as p:
b = p.chromium.launch(
executable_path='/home/hermeswebui/.hermes/home/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome',
args=['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'])
pg = b.new_page(viewport={'width': 1200, 'height': 630})
pg.on('pageerror', lambda e: errs.append(str(e)))
pg.on('console', lambda m: msgs.append(f"{m.type}: {m.text}"))
pg.goto('http://127.0.0.1:8766/', wait_until='networkidle')
pg.wait_for_timeout(600)
print('title:', pg.title())
assert 'Day 4' in pg.title()
# step list rendered
n_steps = pg.locator('#steps .step').count()
print('steps rendered:', n_steps)
assert n_steps == 10
# click step 6 (Brun the potatoes, 8 min) -> scene + timer box update
pg.locator('#steps .step').nth(5).click()
pg.wait_for_timeout(300)
assert 'Brun the potatoes' in pg.locator('#now-title').inner_text()
t0 = pg.locator('#timer-display').inner_text()
print('timer display initial:', t0)
# start timer (demo mode default: 60x -> 8 min finishes in 8s)
pg.locator('#timer-btn').click()
pg.wait_for_timeout(1500)
t1 = pg.locator('#timer-display').inner_text()
print('timer after 1.5s demo:', t1)
assert t1 != t0, 'timer did not count down'
pg.wait_for_timeout(7500)
done_txt = pg.locator('#timer-display').inner_text()
print('timer at end:', done_txt)
assert 'færdig' in done_txt
# checkbox -> progress updates
pg.locator('#steps .step').nth(0).locator('.done').check()
pg.locator('#steps .step').nth(1).locator('.done').check()
pg.wait_for_timeout(300)
prog = pg.locator('#progress-text').inner_text()
print('progress:', prog)
assert '2 / 10' in prog
# servings slider scales ingredients
pg.locator('#servings').fill('8')
pg.wait_for_timeout(200)
ing0 = pg.locator('#ing-list li').nth(0).inner_text()
print('ingredient at 8 servings:', ing0)
assert '3 kg' in ing0
# persistence across reload
pg.reload(wait_until='networkidle')
pg.wait_for_timeout(500)
prog2 = pg.locator('#progress-text').inner_text()
checked = pg.locator('#steps .step .done:checked').count()
serv = pg.locator('#servings').input_value()
print('after reload -> progress:', prog2, 'checked:', checked, 'servings:', serv)
assert checked == 2 and serv == '8'
# no-timer step shows disabled button
pg.locator('#steps .step').nth(0).click()
pg.wait_for_timeout(200)
assert pg.locator('#timer-btn').is_disabled()
# complete everything -> win overlay + confetti
for i in range(10):
cb = pg.locator('#steps .step').nth(i).locator('.done')
if not cb.is_checked():
cb.check()
pg.wait_for_timeout(400)
assert pg.locator('#win').is_visible(), 'win overlay missing'
print('win overlay visible, confetti:', pg.locator('.confetti').count())
pg.locator('#win-close').click()
pg.wait_for_timeout(200)
assert not pg.locator('#win').is_visible()
# reset button clears storage (test then restore clean state)
# -> instead just clear storage for a clean preview screenshot
pg.evaluate("localStorage.clear()")
pg.reload(wait_until='networkidle')
pg.wait_for_timeout(400)
assert pg.locator('#steps .step .done:checked').count() == 0
# preview screenshot: pick the 'serve' step, canvas fully visible at 1200x630
pg.locator('#steps .step').nth(9).click()
pg.wait_for_timeout(1200)
pg.evaluate("window.scrollTo(0,0)")
box = pg.locator('#scene').bounding_box()
print('canvas box:', box)
assert box['y'] + box['height'] <= 630, 'canvas clipped at 630px viewport'
pg.screenshot(path=os.path.join(os.path.dirname(DIST), 'preview_shot.png'))
# also a mid-recipe shot (oven) for reference
pg.locator('#steps .step').nth(2).click()
pg.wait_for_timeout(800)
pg.screenshot(path=os.path.join(os.path.dirname(DIST), 'check_full.png'))
print('pageerrors:', errs)
print('console errors:', [m for m in msgs if m.startswith('error')])
assert not errs
b.close()
httpd.shutdown()
print('SMOKE OK')
+56
View File
@@ -0,0 +1,56 @@
// <advent-badge day="1" name="Living fishtank">: the label in the top right corner, "Advent of AI Slop [Day 1]
// Living fishtank". Its first part links to the calendar, the rest to the door of the day this was made for.
// It draws itself in a shadow root, so its styles and the page's never touch.
const site = 'https://advent-of-slop.quesma.com';
const css = `
nav {
position: fixed;
top: 0;
right: 0;
z-index: 2147483647;
display: flex;
flex-wrap: wrap;
gap: 0 0.35em;
max-width: 100vw;
box-sizing: border-box;
padding: 0.35rem 0.7rem;
border-bottom-left-radius: 0.5rem;
background: #b8232f;
font: 700 0.8125rem/1.2 system-ui, sans-serif;
}
a {
color: #f6ecd6;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
`;
const link = (href: string, text: string): HTMLAnchorElement => {
const anchor = document.createElement('a');
anchor.href = href;
anchor.textContent = text;
return anchor;
};
class AdventBadge extends HTMLElement {
connectedCallback(): void {
const day = Number(this.getAttribute('day'));
if (!Number.isInteger(day) || day < 1 || day > 24) {
throw new Error(`<advent-badge> needs day="1" to day="24", got ${this.getAttribute('day')}`);
}
const name = this.getAttribute('name');
if (name === null || name.trim() === '') {
throw new Error('<advent-badge> needs name="...", the title of its day, such as name="Living fishtank"');
}
const style = document.createElement('style');
style.textContent = css;
const label = document.createElement('nav');
label.append(link(`${site}/`, 'Advent of AI Slop'), link(`${site}/day/${day}/`, `[Day ${day}] ${name}`));
this.attachShadow({ mode: 'open' }).append(style, label);
}
}
customElements.define('advent-badge', AdventBadge);
+334
View File
@@ -0,0 +1,334 @@
import './style.css';
import { STEPS, INGREDIENTS, formatIngredient, type Step } from './steps';
import { drawScene } from './scene';
const STORE_KEY = 'aos-day4-flaeskesteg';
const DEMO_SPEED = 60; // demo mode: 1 real second = 1 recipe minute
interface Saved {
servings: number;
demo: boolean;
current: number;
done: boolean[];
}
function loadSaved(): Saved {
const fallback: Saved = {
servings: 4,
demo: true,
current: 0,
done: STEPS.map(() => false),
};
try {
const raw = localStorage.getItem(STORE_KEY);
if (!raw) return fallback;
const parsed = JSON.parse(raw) as Partial<Saved>;
return {
servings: typeof parsed.servings === 'number' ? Math.min(10, Math.max(1, Math.round(parsed.servings))) : fallback.servings,
demo: typeof parsed.demo === 'boolean' ? parsed.demo : fallback.demo,
current: typeof parsed.current === 'number' && parsed.current >= 0 && parsed.current < STEPS.length ? parsed.current : 0,
done: Array.isArray(parsed.done) && parsed.done.length === STEPS.length
? parsed.done.map((v) => v === true) : fallback.done,
};
} catch {
return fallback;
}
}
const state = loadSaved();
// timer: at most one running countdown, tied to a step index
const timer = { step: -1, remaining: 0, running: false, finished: false };
function persist(): void {
localStorage.setItem(STORE_KEY, JSON.stringify({
servings: state.servings, demo: state.demo, current: state.current, done: state.done,
}));
}
const app = document.getElementById('app');
if (!app) throw new Error('missing #app');
app.innerHTML = `
<header>
<h1>Bedstemors Flæskesteg</h1>
<p class="sub">Grandma's roast pork with crackling, rødkål and brunede kartofler — ten steps,
one animated kitchen, and timers that actually run. The crackling must <em>crack</em>, not chew.</p>
</header>
<div id="controls">
<label class="ctl">Servings
<input id="servings" type="range" min="1" max="10" step="1" />
<span id="servings-val"></span>
</label>
<label class="ctl toggle">Demo timers (60×)
<input id="demo" type="checkbox" />
</label>
<button id="reset" class="ghost">Reset kitchen</button>
<div id="progress-wrap">
<div id="progress-bar"></div>
<span id="progress-text"></span>
</div>
</div>
<div id="stage">
<section id="left">
<canvas id="scene" width="640" height="440"></canvas>
<div id="now">
<div id="now-title"></div>
<div id="timer-box">
<span id="timer-display">--:--</span>
<button id="timer-btn">Start timer</button>
</div>
</div>
<div id="ingredients">
<h2>Indkøb — shopping list</h2>
<ul id="ing-list"></ul>
</div>
</section>
<section id="steps-col">
<ol id="steps"></ol>
</section>
</div>
<footer>Bedstemors recipe, more or less. Which means it is yours now. <span class="da">Velbekomme!</span></footer>
<div id="win" hidden>
<div id="win-card">
<h2>Middagen er klar!</h2>
<p>Ten steps, one roast, zero shortcuts. The crackling cracked — Grandma would nod.</p>
<button id="win-close">Back to the kitchen</button>
</div>
</div>
`;
const canvas = document.getElementById('scene') as HTMLCanvasElement;
const ctx = canvas.getContext('2d');
if (!ctx) throw new Error('canvas 2d unavailable');
const DPR = Math.min(2, window.devicePixelRatio || 1);
canvas.width = 640 * DPR;
canvas.height = 440 * DPR;
const servingsInput = document.getElementById('servings') as HTMLInputElement;
const servingsVal = document.getElementById('servings-val')!;
const demoInput = document.getElementById('demo') as HTMLInputElement;
const resetBtn = document.getElementById('reset')!;
const progressBar = document.getElementById('progress-bar')!;
const progressText = document.getElementById('progress-text')!;
const nowTitle = document.getElementById('now-title')!;
const timerDisplay = document.getElementById('timer-display')!;
const timerBtn = document.getElementById('timer-btn') as HTMLButtonElement;
const timerBox = document.getElementById('timer-box')!;
const ingList = document.getElementById('ing-list')!;
const stepsOl = document.getElementById('steps') as HTMLOListElement;
const win = document.getElementById('win')!;
const winClose = document.getElementById('win-close')!;
const stepEls: { li: HTMLLIElement; check: HTMLInputElement }[] = [];
function fmt(sec: number): string {
const s = Math.max(0, Math.ceil(sec));
const m = Math.floor(s / 60);
const r = s % 60;
return `${String(m).padStart(2, '0')}:${String(r).padStart(2, '0')}`;
}
function stepCard(step: Step, i: number): HTMLLIElement {
const li = document.createElement('li');
li.className = 'step';
const head = document.createElement('div');
head.className = 'step-head';
const num = document.createElement('span');
num.className = 'num';
num.textContent = String(i + 1);
const ttl = document.createElement('div');
ttl.className = 'ttl';
const strong = document.createElement('strong');
strong.textContent = step.title;
const da = document.createElement('span');
da.className = 'da';
da.textContent = step.danish;
ttl.append(strong, da);
head.append(num, ttl);
if (step.minutes > 0) {
const badge = document.createElement('span');
badge.className = 'mins';
badge.textContent = step.minutes >= 60 ? `${(step.minutes / 60).toFixed(step.minutes % 60 === 0 ? 0 : 1)} h` : `${step.minutes} min`;
head.append(badge);
}
const check = document.createElement('input');
check.type = 'checkbox';
check.className = 'done';
check.checked = state.done[i] === true;
check.title = 'Mark step done';
head.append(check);
const body = document.createElement('p');
body.className = 'step-text';
body.textContent = step.text;
li.append(head, body);
li.addEventListener('click', (e) => {
if ((e.target as HTMLElement).closest('.done')) return;
selectStep(i);
});
check.addEventListener('change', () => {
state.done[i] = check.checked;
li.classList.toggle('is-done', check.checked);
if (check.checked && state.done.every(Boolean)) showWin();
persist();
updateProgress();
});
li.classList.toggle('is-done', check.checked);
return li;
}
STEPS.forEach((step, i) => {
const li = stepCard(step, i);
const check = li.querySelector('.done') as HTMLInputElement;
stepEls.push({ li, check });
stepsOl.append(li);
});
function selectStep(i: number): void {
state.current = i;
stepEls.forEach((el, j) => el.li.classList.toggle('active', j === i));
stepEls[i]!.li.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
updateNow();
persist();
}
function updateNow(): void {
const step = STEPS[state.current]!;
nowTitle.innerHTML = `<strong>${step.title}</strong> <span class="da">${step.danish}</span>`;
if (step.minutes === 0) {
timerBox.classList.add('no-timer');
timerDisplay.textContent = 'no timer';
timerBtn.disabled = true;
timerBtn.textContent = 'eyeball it';
} else {
timerBox.classList.remove('no-timer');
if (timer.step !== state.current) {
timer.step = state.current;
timer.remaining = step.minutes * 60;
timer.running = false;
timer.finished = false;
}
timerBtn.disabled = false;
updateTimerUi();
}
}
function updateTimerUi(): void {
const step = STEPS[state.current]!;
if (step.minutes === 0) return;
if (timer.finished) {
timerDisplay.textContent = 'færdig!';
timerBtn.textContent = 'Restart';
} else {
timerDisplay.textContent = fmt(timer.remaining);
timerBtn.textContent = timer.running ? 'Pause' : 'Start timer';
}
timerDisplay.classList.toggle('running', timer.running);
timerDisplay.classList.toggle('demo', state.demo);
}
timerBtn.addEventListener('click', () => {
const step = STEPS[state.current]!;
if (step.minutes === 0) return;
if (timer.finished) {
timer.remaining = step.minutes * 60;
timer.finished = false;
}
timer.running = !timer.running;
updateTimerUi();
});
setInterval(() => {
if (!timer.running) return;
timer.remaining -= 0.2 * (state.demo ? DEMO_SPEED : 1);
if (timer.remaining <= 0) {
timer.remaining = 0;
timer.running = false;
timer.finished = true;
stepEls[timer.step]?.li.classList.add('ding');
setTimeout(() => stepEls[timer.step]?.li.classList.remove('ding'), 4000);
}
updateTimerUi();
}, 200);
function updateProgress(): void {
const n = state.done.filter(Boolean).length;
progressBar.style.width = `${(n / STEPS.length) * 100}%`;
progressText.textContent = `${n} / ${STEPS.length} steps`;
}
function updateIngredients(): void {
servingsVal.textContent = String(state.servings);
ingList.replaceChildren(...INGREDIENTS.map((ing) => {
const li = document.createElement('li');
li.textContent = formatIngredient(ing, state.servings);
const tag = document.createElement('span');
tag.className = 'ing-step';
tag.textContent = `step ${ing.step}`;
li.append(tag);
return li;
}));
}
servingsInput.value = String(state.servings);
demoInput.checked = state.demo;
servingsInput.addEventListener('input', () => {
state.servings = Number(servingsInput.value);
updateIngredients();
persist();
});
demoInput.addEventListener('change', () => {
state.demo = demoInput.checked;
updateTimerUi();
persist();
});
resetBtn.addEventListener('click', () => {
localStorage.removeItem(STORE_KEY);
location.reload();
});
winClose.addEventListener('click', () => { win.hidden = true; });
function showWin(): void {
win.hidden = false;
const colors = ['#b8232f', '#d9a441', '#5a8f5a', '#f6ecd6', '#6d3560'];
for (let i = 0; i < 70; i++) {
const c = document.createElement('i');
c.className = 'confetti';
c.style.left = `${Math.random() * 100}%`;
c.style.background = colors[i % colors.length]!;
c.style.animationDuration = `${2 + Math.random() * 2.5}s`;
c.style.animationDelay = `${Math.random() * 1.2}s`;
c.style.transform = `rotate(${Math.random() * 360}deg)`;
win.append(c);
setTimeout(() => c.remove(), 6000);
}
}
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight') selectStep(Math.min(STEPS.length - 1, state.current + 1));
if (e.key === 'ArrowLeft') selectStep(Math.max(0, state.current - 1));
});
// render loop
let start = performance.now();
function frame(now: number): void {
const t = (now - start) / 1000;
ctx!.save();
ctx!.scale(DPR, DPR);
drawScene(ctx!, 640, 440, STEPS[state.current]!.phase, t, timer.running);
ctx!.restore();
requestAnimationFrame(frame);
}
selectStep(state.current);
updateIngredients();
updateProgress();
requestAnimationFrame(frame);
+512
View File
@@ -0,0 +1,512 @@
// The animated kitchen. One canvas, one warm December kitchen; each recipe
// step swaps in a little scene: scoring the crackling, the glowing oven,
// bubbling rødkål, amber caramel, the final plate by candlelight.
// Everything is a pure function of time t (seconds) — no particle state.
import type { Phase } from './steps';
const CREAM = '#f6ecd6';
const AMBER = '#d9a441';
const RED = '#b8232f';
const BROWN = '#6b4226';
const DARK = '#141009';
const MEAT = '#a4553f';
const MEAT_DARK = '#7c3d2c';
const CRACK = '#e8c98a';
const PURPLE = '#6d3560';
const STEEL = '#3a352e';
function rr(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number | number[]): void {
ctx.beginPath();
ctx.roundRect(x, y, w, h, r);
}
// Deterministic wisps of steam rising from (x, y).
function steam(ctx: CanvasRenderingContext2D, x: number, y: number, t: number, n: number, spread: number, rise: number): void {
for (let i = 0; i < n; i++) {
const p = (t * 0.32 + i / n) % 1;
const yy = y - p * rise;
const xx = x + Math.sin((p * 5 + i) * 2.1) * spread * p;
ctx.globalAlpha = (1 - p) * 0.35;
ctx.fillStyle = CREAM;
ctx.beginPath();
ctx.arc(xx, yy, 3 + p * 9, 0, Math.PI * 2);
ctx.fill();
}
ctx.globalAlpha = 1;
}
// Bubbles rising through a liquid surface band.
function bubbles(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, t: number, color: string): void {
ctx.fillStyle = color;
for (let i = 0; i < 9; i++) {
const p = (t * 0.5 + i / 9) % 1;
const bx = x + ((i * 53) % w);
const by = y + 14 - p * 16;
ctx.globalAlpha = 0.5 * (1 - Math.abs(p - 0.8) * 2);
ctx.beginPath();
ctx.arc(bx, by, 2 + (i % 3), 0, Math.PI * 2);
ctx.fill();
}
ctx.globalAlpha = 1;
}
function snow(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, t: number): void {
ctx.save();
ctx.beginPath();
ctx.rect(x, y, w, h);
ctx.clip();
ctx.fillStyle = '#e8f4fb';
for (let i = 0; i < 26; i++) {
const p = (t * 0.06 + i * 0.137) % 1;
const sx = x + ((i * 41) % w) + Math.sin(t * 0.8 + i) * 5;
const sy = y + p * h;
ctx.globalAlpha = 0.7;
ctx.beginPath();
ctx.arc(sx, sy, 1.6 + (i % 3) * 0.7, 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
ctx.globalAlpha = 1;
}
function windowFrame(ctx: CanvasRenderingContext2D, t: number): void {
const x = 30, y = 46, w = 150, h = 110;
ctx.fillStyle = '#0e1a2b';
rr(ctx, x, y, w, h, 8); ctx.fill();
// distant rooftops under snow
ctx.fillStyle = '#1c2c44';
ctx.beginPath();
ctx.moveTo(x, y + h);
ctx.lineTo(x, y + 78); ctx.lineTo(x + 34, y + 56); ctx.lineTo(x + 68, y + 78);
ctx.lineTo(x + 68, y + 66); ctx.lineTo(x + 100, y + 44); ctx.lineTo(x + 132, y + 66);
ctx.lineTo(x + 132, y + 74); ctx.lineTo(x + w, y + 58); ctx.lineTo(x + w, y + h);
ctx.closePath(); ctx.fill();
// lit windows on the rooftops
ctx.fillStyle = AMBER;
ctx.globalAlpha = 0.8 + Math.sin(t * 2.3) * 0.15;
ctx.fillRect(x + 24, y + 68, 5, 6);
ctx.fillRect(x + 88, y + 56, 5, 6);
ctx.globalAlpha = 1;
snow(ctx, x, y, w, h, t);
ctx.strokeStyle = BROWN;
ctx.lineWidth = 7;
rr(ctx, x, y, w, h, 8); ctx.stroke();
ctx.lineWidth = 4;
ctx.beginPath();
ctx.moveTo(x + w / 2, y); ctx.lineTo(x + w / 2, y + h);
ctx.moveTo(x, y + h / 2); ctx.lineTo(x + w, y + h / 2);
ctx.stroke();
}
function lights(ctx: CanvasRenderingContext2D, w: number, t: number): void {
ctx.strokeStyle = '#2e2418';
ctx.lineWidth = 2;
ctx.beginPath();
for (let x = 0; x <= w; x += 8) {
const y = 16 + Math.sin(x / w * Math.PI * 3) * 10;
if (x === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);
}
ctx.stroke();
const cols = [AMBER, RED, '#5a8f5a', CREAM];
for (let i = 0; i < 12; i++) {
const x = 20 + i * (w - 40) / 11;
const y = 16 + Math.sin(x / w * Math.PI * 3) * 10 + 8;
const flick = 0.65 + 0.35 * Math.sin(t * 3 + i * 7.3);
ctx.globalAlpha = flick;
ctx.fillStyle = cols[i % cols.length]!;
ctx.beginPath();
ctx.arc(x, y, 4, 0, Math.PI * 2);
ctx.fill();
ctx.globalAlpha = flick * 0.25;
ctx.beginPath();
ctx.arc(x, y, 9, 0, Math.PI * 2);
ctx.fill();
}
ctx.globalAlpha = 1;
}
function counter(ctx: CanvasRenderingContext2D, w: number, h: number): void {
ctx.fillStyle = '#241a12';
ctx.fillRect(0, h - 96, w, 96);
ctx.fillStyle = BROWN;
ctx.fillRect(0, h - 96, w, 10);
ctx.fillStyle = '#31241a';
ctx.fillRect(0, h - 86, w, 4);
}
function kitchen(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = '#1d1712';
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = 'rgba(246,236,214,0.03)';
for (let x = 12; x < w; x += 46) ctx.fillRect(x, 0, 14, h - 96);
lights(ctx, w, t);
windowFrame(ctx, t);
counter(ctx, w, h);
}
// A roast: meaty body + scored crackling cap.
function roast(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, crackling: number): void {
ctx.fillStyle = MEAT_DARK;
rr(ctx, x, y + h * 0.35, w, h * 0.65, [0, 0, 14, 14]); ctx.fill();
ctx.fillStyle = MEAT;
rr(ctx, x + 4, y + h * 0.4, w - 8, h * 0.5, [0, 0, 12, 12]); ctx.fill();
ctx.fillStyle = crackling > 0.5 ? CRACK : '#d8b98a';
rr(ctx, x, y, w, h * 0.4, [10, 10, 4, 4]); ctx.fill();
ctx.strokeStyle = '#8a6a3a';
ctx.lineWidth = 2;
const n = 6;
for (let i = 1; i < n; i++) {
const lx = x + (w * i) / n;
ctx.beginPath(); ctx.moveTo(lx, y + 3); ctx.lineTo(lx, y + h * 0.4 - 3); ctx.stroke();
}
for (let j = 1; j < 3; j++) {
const ly = y + (h * 0.4 * j) / 3;
ctx.beginPath(); ctx.moveTo(x + 3, ly); ctx.lineTo(x + w - 3, ly); ctx.stroke();
}
}
function oven(ctx: CanvasRenderingContext2D, w: number, h: number, t: number, hot: boolean, flames: boolean): void {
const x = w / 2 - 150, y = h - 250, ow = 300, oh = 210;
ctx.fillStyle = STEEL;
rr(ctx, x, y, ow, oh, 12); ctx.fill();
ctx.fillStyle = '#2b261f';
rr(ctx, x + 10, y + 10, ow - 20, oh - 46, 8); ctx.fill();
const glow = hot ? 0.75 + Math.sin(t * 2) * 0.12 : 0.12;
const g = ctx.createRadialGradient(w / 2, y + oh * 0.55, 10, w / 2, y + oh * 0.55, 150);
g.addColorStop(0, `rgba(255,176,64,${glow})`);
g.addColorStop(1, `rgba(120,40,10,${glow * 0.5})`);
ctx.fillStyle = g;
rr(ctx, x + 18, y + 18, ow - 36, oh - 62, 6); ctx.fill();
// roast silhouette inside
ctx.save();
rr(ctx, x + 18, y + 18, ow - 36, oh - 62, 6);
ctx.clip();
ctx.globalAlpha = 0.85;
roast(ctx, w / 2 - 70, y + oh * 0.45, 140, 62, hot ? 1 : 0);
if (flames) {
for (let i = 0; i < 7; i++) {
const fx = x + 40 + i * (ow - 80) / 6;
const fh = 16 + Math.abs(Math.sin(t * 7 + i * 2.4)) * 22;
ctx.fillStyle = i % 2 ? '#ffb040' : '#ff7a2a';
ctx.globalAlpha = 0.8;
ctx.beginPath();
ctx.moveTo(fx - 7, y + 26);
ctx.quadraticCurveTo(fx, y + 26 + fh, fx + 7, y + 26);
ctx.closePath(); ctx.fill();
}
// crackling sparks
ctx.fillStyle = '#ffe9b0';
for (let i = 0; i < 10; i++) {
const p = (t * 1.4 + i / 10) % 1;
ctx.globalAlpha = (1 - p) * 0.9;
ctx.beginPath();
ctx.arc(w / 2 - 60 + ((i * 47) % 120), y + oh * 0.45 - p * 40, 1.8, 0, Math.PI * 2);
ctx.fill();
}
}
ctx.restore();
ctx.globalAlpha = 1;
// handle + dial
ctx.fillStyle = '#c9c2b4';
rr(ctx, x + 40, y + oh - 28, ow - 80, 9, 4); ctx.fill();
ctx.fillStyle = hot ? AMBER : '#57503f';
ctx.beginPath(); ctx.arc(x + 26, y + oh - 24, 7, 0, Math.PI * 2); ctx.fill();
if (hot) {
ctx.fillStyle = CREAM;
ctx.font = '700 15px system-ui, sans-serif';
ctx.textAlign = 'center';
ctx.fillText(flames ? '225 °C' : '200 °C', w / 2, y - 12);
}
}
function pot(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, liquid: string, t: number, bubbleColor: string): void {
ctx.fillStyle = '#4a4438';
rr(ctx, x, y, w, h, [6, 6, 18, 18]); ctx.fill();
ctx.fillStyle = '#5c5546';
rr(ctx, x - 12, y + 6, 14, 8, 4); ctx.fill();
rr(ctx, x + w - 2, y + 6, 14, 8, 4); ctx.fill();
ctx.fillStyle = liquid;
rr(ctx, x + 6, y + 8, w - 12, h * 0.35, 4); ctx.fill();
bubbles(ctx, x + 10, y + 10, w - 24, t, bubbleColor);
}
function candle(ctx: CanvasRenderingContext2D, x: number, y: number, t: number): void {
ctx.fillStyle = '#efe3c8';
rr(ctx, x - 5, y - 34, 10, 34, 3); ctx.fill();
const fl = 10 + Math.sin(t * 9 + x) * 2.5;
const g = ctx.createRadialGradient(x, y - 44, 2, x, y - 44, 26);
g.addColorStop(0, 'rgba(255,190,90,0.55)');
g.addColorStop(1, 'rgba(255,190,90,0)');
ctx.fillStyle = g;
ctx.beginPath(); ctx.arc(x, y - 44, 26, 0, Math.PI * 2); ctx.fill();
ctx.fillStyle = '#ffb040';
ctx.beginPath();
ctx.moveTo(x - 4, y - 36);
ctx.quadraticCurveTo(x + Math.sin(t * 6) * 2, y - 36 - fl, x + 4, y - 36);
ctx.closePath(); ctx.fill();
}
// ---------- per-phase scenes ----------
function sceneDry(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = '#8a6a45';
rr(ctx, w / 2 - 130, h - 170, 260, 60, 12); ctx.fill();
roast(ctx, w / 2 - 95, h - 235, 190, 70, 0);
// knife scoring: hatch lines appear one by one
const cycle = t % 6;
const drawn = Math.min(6, Math.floor(cycle / 0.9));
ctx.strokeStyle = '#3a2a18';
ctx.lineWidth = 2.5;
for (let i = 0; i < drawn; i++) {
const lx = w / 2 - 95 + (190 * (i + 1)) / 7;
ctx.beginPath(); ctx.moveTo(lx, h - 232); ctx.lineTo(lx, h - 205); ctx.stroke();
}
const kx = w / 2 - 95 + (190 * (drawn + 1)) / 7;
const bob = Math.sin(t * 8) * 3;
ctx.save();
ctx.translate(kx, h - 250 + bob);
ctx.rotate(0.5);
ctx.fillStyle = '#cfc8ba';
ctx.fillRect(-2, -34, 4, 30);
ctx.fillStyle = BROWN;
ctx.fillRect(-3, -4, 6, 16);
ctx.restore();
// falling salt grains
ctx.fillStyle = CREAM;
for (let i = 0; i < 14; i++) {
const p = (t * 0.6 + i / 14) % 1;
ctx.globalAlpha = 1 - p;
ctx.fillRect(w / 2 - 90 + ((i * 61) % 180), h - 260 + p * 30, 2, 2);
}
ctx.globalAlpha = 1;
}
function sceneBed(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
const px = w / 2 - 140, py = h - 160;
ctx.fillStyle = '#57503f';
rr(ctx, px, py, 280, 46, 10); ctx.fill();
ctx.fillStyle = '#7a8ea3';
rr(ctx, px + 8, py + 8, 264, 20, 6); ctx.fill();
// water ripples
ctx.strokeStyle = 'rgba(232,244,251,0.5)';
ctx.lineWidth = 1.5;
for (let i = 0; i < 3; i++) {
const p = (t * 0.4 + i / 3) % 1;
ctx.globalAlpha = (1 - p) * 0.6;
ctx.beginPath();
ctx.ellipse(w / 2, py + 18, 10 + p * 110, 3 + p * 6, 0, 0, Math.PI * 2);
ctx.stroke();
}
ctx.globalAlpha = 1;
// rack
ctx.strokeStyle = '#9a927f';
ctx.lineWidth = 3;
for (let i = 0; i <= 8; i++) {
const rx = px + 20 + i * 30;
ctx.beginPath(); ctx.moveTo(rx, py + 2); ctx.lineTo(rx, py - 14); ctx.stroke();
}
const bob = Math.sin(t * 1.6) * 4;
roast(ctx, w / 2 - 90, py - 78 + bob, 180, 64, 0);
}
function sceneCabbage(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = STEEL;
rr(ctx, w / 2 - 170, h - 130, 340, 26, 8); ctx.fill();
ctx.fillStyle = '#241f18';
ctx.beginPath(); ctx.arc(w / 2 - 90, h - 117, 26, 0, Math.PI * 2); ctx.fill();
pot(ctx, w / 2 - 90, h - 230, 180, 105, PURPLE, t, '#9a5a8a');
// apple wedge riding the bubbles
ctx.fillStyle = '#c9d96a';
const ax = w / 2 - 40 + Math.sin(t * 0.9) * 14;
const ay = h - 222 + Math.sin(t * 2.2) * 2;
ctx.beginPath(); ctx.moveTo(ax, ay); ctx.lineTo(ax + 16, ay - 6); ctx.lineTo(ax + 12, ay + 8); ctx.closePath(); ctx.fill();
steam(ctx, w / 2 - 30, h - 238, t, 5, 22, 90);
steam(ctx, w / 2 + 30, h - 240, t + 1.3, 4, 18, 80);
}
function scenePotatoes(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = STEEL;
rr(ctx, w / 2 - 170, h - 130, 340, 26, 8); ctx.fill();
ctx.fillStyle = '#241f18';
ctx.beginPath(); ctx.arc(w / 2 - 90, h - 117, 26, 0, Math.PI * 2); ctx.fill();
pot(ctx, w / 2 - 90, h - 230, 180, 105, '#8fa8b8', t, '#d8e6ee');
// potatoes bobbing under the surface
ctx.fillStyle = '#c9b285';
for (let i = 0; i < 5; i++) {
const px = w / 2 - 66 + i * 33;
const py = h - 216 + Math.sin(t * 2.6 + i * 1.7) * 3;
ctx.beginPath(); ctx.ellipse(px, py, 11, 8, i, 0, Math.PI * 2); ctx.fill();
}
steam(ctx, w / 2, h - 238, t, 6, 26, 95);
}
function sceneCaramel(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = STEEL;
rr(ctx, w / 2 - 170, h - 130, 340, 26, 8); ctx.fill();
ctx.fillStyle = '#241f18';
ctx.beginPath(); ctx.arc(w / 2 - 90, h - 117, 26, 0, Math.PI * 2); ctx.fill();
// pan seen at a tilt
const cx = w / 2, cy = h - 190;
ctx.fillStyle = '#33302a';
ctx.beginPath(); ctx.ellipse(cx, cy, 120, 46, 0, 0, Math.PI * 2); ctx.fill();
ctx.fillStyle = '#4a4438';
ctx.beginPath(); ctx.ellipse(cx, cy - 4, 108, 38, 0, 0, Math.PI * 2); ctx.fill();
// swirling amber caramel
const g = ctx.createRadialGradient(cx, cy - 4, 6, cx, cy - 4, 105);
g.addColorStop(0, '#e8a83a');
g.addColorStop(1, '#8a4a12');
ctx.fillStyle = g;
ctx.beginPath(); ctx.ellipse(cx, cy - 2, 100, 33, 0, 0, Math.PI * 2); ctx.fill();
ctx.save();
ctx.beginPath(); ctx.ellipse(cx, cy - 2, 100, 33, 0, 0, Math.PI * 2); ctx.clip();
ctx.strokeStyle = 'rgba(255,220,140,0.5)';
ctx.lineWidth = 4;
for (let i = 0; i < 3; i++) {
ctx.beginPath();
for (let a = 0; a < Math.PI * 2; a += 0.2) {
const rad = 20 + i * 26 + Math.sin(a * 3 + t * 1.5 + i) * 8;
const sx = cx + Math.cos(a + t * 0.7) * rad;
const sy = cy - 2 + Math.sin(a + t * 0.7) * rad * 0.32;
if (a === 0) ctx.moveTo(sx, sy); else ctx.lineTo(sx, sy);
}
ctx.stroke();
}
ctx.restore();
// potatoes rolling in the caramel
ctx.fillStyle = '#d98a2a';
for (let i = 0; i < 5; i++) {
const a = t * 0.9 + i * 1.26;
const rad = 52 + (i % 2) * 26;
ctx.beginPath();
ctx.ellipse(cx + Math.cos(a) * rad, cy - 2 + Math.sin(a) * rad * 0.32, 12, 8, 0, 0, Math.PI * 2);
ctx.fill();
}
steam(ctx, cx - 40, cy - 40, t, 4, 16, 70);
steam(ctx, cx + 45, cy - 42, t + 0.8, 4, 16, 70);
}
function sceneRest(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = '#8a6a45';
rr(ctx, w / 2 - 140, h - 165, 280, 52, 12); ctx.fill();
// foil dome
const g = ctx.createLinearGradient(w / 2 - 110, 0, w / 2 + 110, 0);
g.addColorStop(0, '#b8b4aa');
g.addColorStop(0.5, '#e8e4da');
g.addColorStop(1, '#9a968c');
ctx.fillStyle = g;
ctx.beginPath();
ctx.moveTo(w / 2 - 110, h - 160);
ctx.quadraticCurveTo(w / 2, h - 265, w / 2 + 110, h - 160);
ctx.closePath(); ctx.fill();
ctx.strokeStyle = 'rgba(90,86,78,0.6)';
ctx.lineWidth = 1.5;
for (let i = -3; i <= 3; i++) {
ctx.beginPath();
ctx.moveTo(w / 2 + i * 28, h - 160);
ctx.quadraticCurveTo(w / 2 + i * 20, h - 220, w / 2 + i * 8, h - 240 + Math.abs(i) * 14);
ctx.stroke();
}
steam(ctx, w / 2 - 60, h - 172, t, 3, 12, 50);
steam(ctx, w / 2 + 60, h - 172, t + 1.1, 3, 12, 50);
// little clock
ctx.fillStyle = CREAM;
ctx.beginPath(); ctx.arc(w / 2 + 150, h - 230, 26, 0, Math.PI * 2); ctx.fill();
ctx.strokeStyle = BROWN; ctx.lineWidth = 3;
ctx.beginPath(); ctx.arc(w / 2 + 150, h - 230, 26, 0, Math.PI * 2); ctx.stroke();
const a = -Math.PI / 2 + (t % 10) / 10 * Math.PI * 2;
ctx.beginPath(); ctx.moveTo(w / 2 + 150, h - 230); ctx.lineTo(w / 2 + 150 + Math.cos(a) * 17, h - 230 + Math.sin(a) * 17); ctx.stroke();
}
function sceneCarve(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
ctx.fillStyle = '#8a6a45';
rr(ctx, w / 2 - 150, h - 170, 300, 60, 12); ctx.fill();
const cycle = t % 8;
const slices = Math.min(5, Math.floor(cycle / 1.4));
roast(ctx, w / 2 - 100 + slices * 14, h - 240, 200 - slices * 14, 72, 1);
// cut slices with crackling tops
for (let i = 0; i < slices; i++) {
const sx = w / 2 - 118 + i * 26;
ctx.fillStyle = MEAT;
rr(ctx, sx, h - 232, 18, 64, 6); ctx.fill();
ctx.fillStyle = CRACK;
rr(ctx, sx, h - 236, 18, 12, 3); ctx.fill();
}
const kx = w / 2 - 100 + slices * 14 + 6;
const bob = Math.abs(Math.sin(t * 6)) * 10;
ctx.save();
ctx.translate(kx, h - 250 + bob);
ctx.rotate(0.35);
ctx.fillStyle = '#cfc8ba';
ctx.beginPath();
ctx.moveTo(0, 0); ctx.lineTo(46, 8); ctx.lineTo(46, 14); ctx.lineTo(0, 10);
ctx.closePath(); ctx.fill();
ctx.fillStyle = BROWN;
ctx.fillRect(-22, 1, 22, 8);
ctx.restore();
}
function sceneServe(ctx: CanvasRenderingContext2D, w: number, h: number, t: number): void {
// table cloth
ctx.fillStyle = '#3d2b20';
rr(ctx, w / 2 - 190, h - 175, 380, 70, 14); ctx.fill();
// big warm plate
ctx.fillStyle = '#e8e0cc';
ctx.beginPath(); ctx.ellipse(w / 2 - 20, h - 145, 150, 42, 0, 0, Math.PI * 2); ctx.fill();
ctx.fillStyle = '#d6ccb4';
ctx.beginPath(); ctx.ellipse(w / 2 - 20, h - 148, 122, 32, 0, 0, Math.PI * 2); ctx.fill();
// sliced roast with gravy
for (let i = 0; i < 4; i++) {
const sx = w / 2 - 105 + i * 30;
ctx.fillStyle = MEAT;
rr(ctx, sx, h - 172, 24, 40, 8); ctx.fill();
ctx.fillStyle = CRACK;
rr(ctx, sx, h - 176, 24, 10, 3); ctx.fill();
}
ctx.fillStyle = '#5a3a1a';
ctx.beginPath();
ctx.ellipse(w / 2 - 60, h - 128, 52, 9, 0, 0, Math.PI * 2); ctx.fill();
// rødkål
ctx.fillStyle = PURPLE;
ctx.beginPath(); ctx.ellipse(w / 2 + 52, h - 150, 34, 16, 0, 0, Math.PI * 2); ctx.fill();
ctx.fillStyle = '#8a4a7a';
ctx.beginPath(); ctx.ellipse(w / 2 + 46, h - 154, 18, 8, 0, 0, Math.PI * 2); ctx.fill();
// amber potatoes
ctx.fillStyle = '#d98a2a';
for (let i = 0; i < 4; i++) {
ctx.beginPath();
ctx.ellipse(w / 2 + 92 + (i % 2) * 20, h - 148 - Math.floor(i / 2) * 14, 10, 8, 0, 0, Math.PI * 2);
ctx.fill();
}
steam(ctx, w / 2 - 60, h - 185, t, 4, 20, 70);
steam(ctx, w / 2 + 50, h - 170, t + 1.4, 3, 14, 55);
// gravy jug + candles
ctx.fillStyle = '#e0d6c0';
rr(ctx, w / 2 + 140, h - 210, 40, 44, 8); ctx.fill();
ctx.fillStyle = '#5a3a1a';
rr(ctx, w / 2 + 144, h - 206, 32, 10, 4); ctx.fill();
candle(ctx, w / 2 - 160, h - 175, t);
candle(ctx, w / 2 + 175, h - 165, t + 2);
}
export function drawScene(ctx: CanvasRenderingContext2D, w: number, h: number, phase: Phase, t: number, active: boolean): void {
kitchen(ctx, w, h, t);
switch (phase) {
case 'dry': sceneDry(ctx, w, h, t); break;
case 'bed': sceneBed(ctx, w, h, t); break;
case 'oven': oven(ctx, w, h, t, true, false); if (active) steam(ctx, w / 2, h - 250, t, 3, 20, 60); break;
case 'cabbage': sceneCabbage(ctx, w, h, t); break;
case 'potatoes': scenePotatoes(ctx, w, h, t); break;
case 'caramel': sceneCaramel(ctx, w, h, t); break;
case 'crisp': oven(ctx, w, h, t, true, true); break;
case 'rest': sceneRest(ctx, w, h, t); break;
case 'carve': sceneCarve(ctx, w, h, t); break;
case 'serve': sceneServe(ctx, w, h, t); break;
}
// subtle vignette
const v = ctx.createRadialGradient(w / 2, h / 2, h * 0.45, w / 2, h / 2, h * 0.95);
v.addColorStop(0, 'rgba(0,0,0,0)');
v.addColorStop(1, 'rgba(0,0,0,0.45)');
ctx.fillStyle = v;
ctx.fillRect(0, 0, w, h);
}
+122
View File
@@ -0,0 +1,122 @@
// The recipe: Bedstemors flæskesteg — roast pork with crackling, rødkål and
// brunede kartofler. Ten steps, each with an animated kitchen phase and an
// optional countdown (in real seconds; demo mode runs them 60× faster).
export type Phase =
| 'dry' | 'bed' | 'oven' | 'cabbage' | 'potatoes'
| 'caramel' | 'crisp' | 'rest' | 'carve' | 'serve';
export interface Step {
title: string;
danish: string;
minutes: number; // 0 = no timer for this step
phase: Phase;
text: string;
}
export const STEPS: Step[] = [
{
title: 'Dry the crackling',
danish: 'Sværen skal være tør',
minutes: 0,
phase: 'dry',
text: 'Pat the skin of a 1.5 kg pork roast bone-dry and score it in a crosshatch, knife tip down to the fat — never through it. Rub coarse salt deep into every cut. Grandma\u2019s trick: leave it uncovered in the fridge overnight. Dry skin is crispy skin; there is no shortcut.',
},
{
title: 'Make its bed',
danish: 'On the rack, fat side up',
minutes: 0,
phase: 'bed',
text: 'Set the roast fat side up on a rack over a roasting pan with 2 dl of water in the bottom. The water stops the drippings from burning \u2014 those drippings become gravy, and gravy is the whole point of the pan.',
},
{
title: 'Into the oven',
danish: '200 °C, mid-rack',
minutes: 90,
phase: 'oven',
text: 'Roast at 200 °C, roughly 1 hour per 500 g. Every 20 minutes, baste the meat with the pan juices \u2014 do not wet the crackling. The kitchen will start to smell like December; that is your timer.',
},
{
title: 'Simmer the red cabbage',
danish: 'Rødkål med æble',
minutes: 40,
phase: 'cabbage',
text: 'Simmer the rødkål with a quartered apple, a knob of butter and a pinch of sugar while the roast works. Old-school: braise your own cabbage for an hour. Honest-school: the good jarred kind, warmed properly. Grandma won\u2019t tell.',
},
{
title: 'Boil the potatoes',
danish: 'Små kartofler, let møre',
minutes: 20,
phase: 'potatoes',
text: 'Boil small potatoes in salted water until just tender \u2014 they still have to survive a roll in hot caramel. Drain well and keep them warm under a cloth.',
},
{
title: 'Brun the potatoes',
danish: 'Brunede kartofler',
minutes: 8,
phase: 'caramel',
text: 'Melt sugar in a pan until it turns the colour of a hazelnut, swirl in butter, then roll in the potatoes until every one wears an amber coat. Do not stir with a spoon \u2014 swirl with the pan, or you get sugar rocks.',
},
{
title: 'Crisp the crackling',
danish: 'Sværen skal springe',
minutes: 12,
phase: 'crisp',
text: 'If the crackling is still pale and soft, turn the oven to 225 °C (or grill) for the last 10\u201315 minutes. Watch it like a hawk \u2014 it goes from perfect to charcoal in one phone call. Done right it cracks like a campfire.',
},
{
title: 'Rest, then gravy',
danish: 'Brun sovs på faconen',
minutes: 10,
phase: 'rest',
text: 'Let the meat rest 10 minutes under foil. Pour the pan juices into a saucepan, skim off the fat, and build a dark brown gravy with a little browned roux. Salt, pepper, taste \u2014 it should taste like the roast\u2019s own diary.',
},
{
title: 'Carve',
danish: 'Sværen først, kødet tyndt',
minutes: 0,
phase: 'carve',
text: 'Carve the crackling into neat squares first, while it is still warm and brittle, then slice the meat thin. Every plate gets one square that cracks and one slice that doesn\u2019t need a saw.',
},
{
title: 'Serve',
danish: 'Velbekomme!',
minutes: 0,
phase: 'serve',
text: 'Roast and crackling on a warm plate, a spoonful of rødkål, the amber potatoes beside it, gravy in a jug that has been warmed too. Light the candles. It is Grandma\u2019s recipe now \u2014 which means yours.',
},
];
export interface Ingredient {
name: string;
perServing: number; // grams or ml
unit: string;
step: number; // which step it belongs to (1-based)
}
export const INGREDIENTS: Ingredient[] = [
{ name: 'Pork roast, skin on', perServing: 375, unit: 'g', step: 1 },
{ name: 'Coarse salt', perServing: 5, unit: 'g', step: 1 },
{ name: 'Water in the pan', perServing: 0, unit: '', step: 2 },
{ name: 'Red cabbage', perServing: 125, unit: 'g', step: 4 },
{ name: 'Apples', perServing: 0.5, unit: '', step: 4 },
{ name: 'Butter', perServing: 15, unit: 'g', step: 4 },
{ name: 'Small potatoes', perServing: 375, unit: 'g', step: 5 },
{ name: 'Sugar', perServing: 12, unit: 'g', step: 6 },
{ name: 'Brown roux', perServing: 8, unit: 'g', step: 8 },
];
export function formatIngredient(ing: Ingredient, servings: number): string {
if (ing.name === 'Water in the pan') return '2 dl water in the pan';
if (ing.unit === '') {
const n = Math.round(ing.perServing * servings * 2) / 2;
return `${n % 1 === 0 ? n : n.toFixed(1)} ${ing.name.toLowerCase()}${n === 1 ? '' : 's'}`;
}
const g = ing.perServing * servings;
if (g >= 1000) {
const kg = Math.round(g / 50) * 50 / 1000;
return `${kg % 1 === 0 ? kg.toFixed(0) : kg} kg ${ing.name.toLowerCase()}`;
}
const rounded = g >= 200 ? Math.round(g / 25) * 25 : Math.round(g / 5) * 5;
return `${rounded} ${ing.unit} ${ing.name.toLowerCase()}`;
}
+286
View File
@@ -0,0 +1,286 @@
:root {
--bg: #1d1712;
--panel: #261e16;
--panel-2: #2f251b;
--line: #46372a;
--cream: #f6ecd6;
--dim: #c9b99a;
--amber: #d9a441;
--red: #b8232f;
--green: #5a8f5a;
}
* { box-sizing: border-box; }
body {
margin: 0;
background:
radial-gradient(1200px 500px at 50% -10%, rgba(217, 164, 65, 0.10), transparent 60%),
var(--bg);
color: var(--cream);
font: 400 16px/1.55 Georgia, 'Times New Roman', serif;
}
#app {
max-width: 1180px;
margin: 0 auto;
padding: 1rem 1.2rem 3rem;
}
header { text-align: center; margin-bottom: 0.8rem; }
h1 {
margin: 0 0 0.3rem;
font-size: clamp(1.7rem, 4vw, 2.35rem);
letter-spacing: 0.01em;
color: var(--cream);
}
h1::after {
content: "";
display: block;
width: 120px;
height: 3px;
margin: 0.45rem auto 0;
background: linear-gradient(90deg, transparent, var(--red), transparent);
}
.sub {
max-width: 660px;
margin: 0.4rem auto 0;
color: var(--dim);
font-size: 0.95rem;
}
.da { color: var(--amber); font-style: italic; font-size: 0.86em; }
#controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 1rem 1.6rem;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
padding: 0.55rem 1.1rem;
margin-bottom: 0.7rem;
font-family: system-ui, sans-serif;
font-size: 0.88rem;
}
.ctl { display: flex; align-items: center; gap: 0.55rem; color: var(--dim); }
input[type="range"] { accent-color: var(--red); width: 130px; }
input[type="checkbox"] { accent-color: var(--amber); width: 16px; height: 16px; }
#servings-val {
min-width: 7.5ch;
color: var(--cream);
font-weight: 700;
}
button {
font: 700 0.85rem system-ui, sans-serif;
color: var(--cream);
background: var(--red);
border: 0;
border-radius: 8px;
padding: 0.45rem 0.9rem;
cursor: pointer;
}
button:hover { filter: brightness(1.15); }
button:disabled { background: var(--line); color: var(--dim); cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--dim); }
#progress-wrap {
flex: 1 1 180px;
min-width: 160px;
position: relative;
height: 22px;
background: #171310;
border: 1px solid var(--line);
border-radius: 999px;
overflow: hidden;
}
#progress-bar {
height: 100%;
width: 0;
background: linear-gradient(90deg, var(--red), var(--amber));
transition: width 0.4s ease;
}
#progress-text {
position: absolute;
inset: 0;
display: grid;
place-items: center;
font-size: 0.72rem;
font-weight: 700;
color: var(--cream);
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}
#stage {
display: grid;
grid-template-columns: minmax(0, 600px) minmax(320px, 1fr);
gap: 1.2rem;
align-items: start;
}
@media (max-width: 900px) {
#stage { grid-template-columns: 1fr; }
}
#left { display: grid; gap: 0.9rem; }
canvas#scene {
width: 100%;
aspect-ratio: 640 / 440;
border: 1px solid var(--line);
border-radius: 14px;
background: #141009;
}
#now {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.7rem;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
padding: 0.65rem 1rem;
}
#now-title { font-size: 1.05rem; }
#timer-box { display: flex; align-items: center; gap: 0.7rem; }
#timer-display {
font: 700 1.5rem/1 ui-monospace, "Cascadia Mono", monospace;
color: var(--dim);
min-width: 6.5ch;
text-align: right;
}
#timer-display.running { color: var(--green); }
#timer-display.demo { color: var(--amber); }
#timer-display.running.demo { color: var(--amber); }
.no-timer #timer-display { font-size: 0.9rem; }
#ingredients {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 12px;
padding: 0.8rem 1.1rem 1rem;
}
#ingredients h2 {
margin: 0 0 0.5rem;
font-size: 0.95rem;
font-family: system-ui, sans-serif;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--amber);
}
#ing-list {
margin: 0;
padding: 0;
list-style: none;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
gap: 0.25rem 1rem;
font-size: 0.92rem;
}
#ing-list li { display: flex; justify-content: space-between; gap: 0.6rem; }
.ing-step {
font: 600 0.68rem/1.6 system-ui, sans-serif;
color: var(--dim);
background: var(--panel-2);
border: 1px solid var(--line);
border-radius: 999px;
padding: 0 0.5rem;
height: fit-content;
white-space: nowrap;
}
#steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.step {
background: var(--panel);
border: 1px solid var(--line);
border-left: 4px solid var(--line);
border-radius: 12px;
padding: 0.7rem 0.95rem;
cursor: pointer;
transition: border-color 0.2s, background 0.2s;
}
.step:hover { background: var(--panel-2); }
.step.active { border-left-color: var(--amber); background: var(--panel-2); }
.step.is-done { opacity: 0.55; }
.step.is-done .step-text { display: none; }
.step.is-done .ttl strong { text-decoration: line-through; }
.step.ding { animation: ding 0.5s ease 6; }
@keyframes ding {
50% { border-left-color: var(--green); background: #2c3524; }
}
.step-head { display: flex; align-items: center; gap: 0.7rem; }
.num {
flex: none;
width: 26px; height: 26px;
display: grid; place-items: center;
border-radius: 50%;
background: var(--red);
color: var(--cream);
font: 700 0.8rem system-ui, sans-serif;
}
.ttl { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.ttl strong { font-size: 1rem; }
.mins {
font: 700 0.72rem system-ui, sans-serif;
color: var(--amber);
border: 1px solid var(--line);
border-radius: 999px;
padding: 0.15rem 0.55rem;
white-space: nowrap;
}
.done { flex: none; width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
.step-text { margin: 0.5rem 0 0; color: var(--dim); font-size: 0.93rem; }
footer {
margin-top: 2rem;
text-align: center;
color: var(--dim);
font-size: 0.9rem;
}
#win {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: rgba(10, 7, 4, 0.78);
overflow: hidden;
}
#win[hidden] { display: none; }
#win-card {
position: relative;
z-index: 2;
max-width: 420px;
margin: 1rem;
text-align: center;
background: var(--panel);
border: 1px solid var(--amber);
border-radius: 16px;
padding: 1.8rem 1.6rem;
}
#win-card h2 { margin: 0 0 0.5rem; color: var(--amber); }
#win-card p { color: var(--dim); margin: 0 0 1.2rem; }
.confetti {
position: absolute;
top: -14px;
width: 9px; height: 14px;
border-radius: 2px;
animation: fall linear forwards;
}
@keyframes fall {
to { transform: translateY(110vh) rotate(720deg); opacity: 0.7; }
}
+15
View File
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2023",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"types": ["vite/client"],
"strict": true,
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true,
"noEmit": true
},
"include": ["src"]
}
+6
View File
@@ -0,0 +1,6 @@
import { defineConfig } from 'vite';
export default defineConfig({
// Relative links, so the build works under https://<you>.github.io/<repository>/ whatever the repository is called.
base: './',
});