Add "Playing It Safe" draft and improve type-checking

- Remove most type assertions and improve types
- Validate wordCount property
- Add "Vore Day" tag
- Add licenses
This commit is contained in:
Bad Manners 2024-08-03 20:33:49 -03:00
parent 17ef8c652c
commit fe908a4989
37 changed files with 1309 additions and 841 deletions

View file

@ -1,36 +0,0 @@
---
type Props = {
breakpoint: number;
};
const { breakpoint } = Astro.props;
---
<div id="slot-switch" data-breakpoint={breakpoint}></div>
<template id="slot-switch-big">
<slot />
</template>
<template id="slot-switch-small">
<slot />
</template>
<script>
const slotSwitch = document.querySelector("div#slot-switch") as HTMLDivElement;
const breakpointAttribute = slotSwitch.getAttribute("data-breakpoint");
if (breakpointAttribute && !isNaN(parseInt(breakpointAttribute))) {
const breakpoint = parseInt(breakpointAttribute);
const slotSwitchBig = document.querySelector("template#slot-switch-big") as HTMLTemplateElement;
const slotSwitchSmall = document.querySelector("template#slot-switch-small") as HTMLTemplateElement;
let displayBig: boolean | null = null;
function handleResize() {
const newDisplayBig = window.innerWidth >= breakpoint;
if (newDisplayBig !== displayBig) {
displayBig = newDisplayBig;
const template = displayBig ? slotSwitchBig : slotSwitchSmall;
slotSwitch.replaceChildren(template.content.cloneNode(true));
}
}
window.addEventListener("resize", handleResize);
handleResize();
}
</script>