Template for an Advent of AI Slop entry
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
1f25363d7d
15 files changed
+951
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// <advent-badge day="1">: the link in the top right corner, back 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 {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
z-index: 2147483647;
|
||||
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;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
background: #0f3b2d;
|
||||
}
|
||||
`;
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('advent-badge', AdventBadge);
|
||||
Reference in new issue
Block a user