From cd563cdfc23924316a7bc5c94231aca7b6ecbf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Migda=C5=82?= Date: Wed, 2 Dec 2026 12:01:33 +0100 Subject: [PATCH] Badge: Advent of AI Slop [Day N] and the title of the day Two links: the calendar, and the door of the day. Co-Authored-By: Claude Fable 5.2 --- AGENTS.md | 6 ++++-- index.html | 4 ++-- src/badge.ts | 35 ++++++++++++++++++++++++++--------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2cac0ac..4877420 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,8 @@ One small web page, made for one day of [Advent of AI Slop](https://advent-of-sl ## What is here - `index.html` and `src/main.ts`: the page. -- `src/badge.ts`: the "Advent of AI Slop" link in the top right corner. +- `src/badge.ts`: the label in the top right corner, "Advent of AI Slop [Day 1] Living fishtank", which links to the + calendar and to the day. - `public/preview.png`: the picture shown when the link is shared. - `.github/workflows/pages.yml`: publishes the page on GitHub Pages after every push to `main`. @@ -18,7 +19,8 @@ What the page does and how it looks is free: any library, any framework, any sty Keep these in `index.html`: - ``, the description and the `og:` tags, rewritten for what was built. -- `<advent-badge day="N">` with the day this is for, and the script that loads `src/badge.ts`. +- `<advent-badge day="N" name="...">` with the day this is for and the title of that day, and the script that loads + `src/badge.ts`. Replace `public/preview.png` with a 1200 by 630 screenshot of the finished page. diff --git a/index.html b/index.html index 36e6804..b676af2 100644 --- a/index.html +++ b/index.html @@ -15,8 +15,8 @@ <script type="module" src="./src/main.ts"></script> </head> <body> - <!-- day: the day of December this was made for, 1 to 24. --> - <advent-badge day="1"></advent-badge> + <!-- day: the day of December this was made for, 1 to 24. name: the title of that day. --> + <advent-badge day="1" name="Living fishtank"></advent-badge> <main id="app"></main> </body> </html> diff --git a/src/badge.ts b/src/badge.ts index 04ca30e..c81df86 100644 --- a/src/badge.ts +++ b/src/badge.ts @@ -1,38 +1,55 @@ -// <advent-badge day="1">: the link in the top right corner, back to the door of the day this was made for. +// <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 = ` - a { + 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; - color: #f6ecd6; font: 700 0.8125rem/1.2 system-ui, sans-serif; + } + a { + color: #f6ecd6; text-decoration: none; } a:hover { - background: #0f3b2d; + 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 link = document.createElement('a'); - link.href = `${site}/day/${day}/`; - link.textContent = 'Advent of AI Slop'; - link.title = `Made for day ${day} of Advent of AI Slop`; - this.attachShadow({ mode: 'open' }).append(style, link); + 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); } }