Files
Spaghet.io/src/components/Drawer.astro
T
spaghet 9e157a4fa3 feat(theme): implement dual light/dark colour token system with WCAG AA contrast
Replace hard-coded hex values and ad-hoc `dark:` variants with a single
semantic token layer in `src/styles/global.css` (`@theme` + `html.dark`
re-declaration), so every component uses the same Tailwind class list in
both modes.

Key changes:
- Define semantic tokens (page, surface, ink, accent, edge, etc.) and raw
  ingredient palette (--color-spaghetti-*, --color-marinara*, etc.)
- Configure dual Shiki themes (light-plus / everforest-dark) with
  `defaultColor: false` for proper per-mode code block colours, replacing
  the old `.prose pre { #1f2937 !important }` hack
- Tint background particles to match the warm cream/espresso palette
  instead of pure black dots
- Document theme rules: add tokens not `dark:` variants, keep colour rules
  inside `@layer`, never target Tailwind utility classes with unlayered
  overrides, route prose colours through `--tw-prose-*` only

All text and interactive elements meet WCAG AA contrast (4.5:1 body, 3:1
large/interactive). Light mode is a warm cream plate with white cards; dark
mode is espresso (#140C08) with raised cards.
2026-11-12 20:48:10 -05:00

55 lines
2.8 KiB
Plaintext

---
import { SITE, LINKS, RESUME } from "@consts"
import { cn, ACTIVE_NAV_COLORS, isNavActive } from "@lib/utils"
const { pathname } = Astro.url
---
<div id="drawer" class="fixed inset-0 h-0 z-40 overflow-hidden flex flex-col items-center justify-center md:hidden bg-page transition-[height] duration-300 ease-in-out">
<nav class="flex flex-col items-center space-y-2">
{
LINKS.map((LINK) => (
<a href={LINK.HREF} class={cn("flex items-center justify-center px-3 py-1 rounded-full", "text-ink hover:bg-wash hover:text-link", "transition-colors duration-300 ease-in-out", isNavActive(pathname, LINK.HREF) && "pointer-events-none", isNavActive(pathname, LINK.HREF) && ACTIVE_NAV_COLORS)}>
{LINK.TEXT}
</a>
))
}
<!-- The header pill drops its label below `sm`, so the drawer is where the
Résumé CTA keeps its text on mobile. -->
<a href={RESUME.HREF} target="_blank" rel="noopener noreferrer" aria-label={`${RESUME.TEXT} for ${SITE.AUTHOR}, opens in a new tab`} class="flex items-center justify-center gap-1.5 px-3 py-1 rounded-full bg-chip text-chip-ink stroke-current border border-edge hover:bg-link hover:text-page hover:border-link transition-colors duration-300">
<svg class="size-4 shrink-0" fill="none">
<use href={`/ui.svg#${RESUME.ICON}`}></use>
</svg>
<span>{RESUME.TEXT}</span>
</a>
</nav>
<div class="flex gap-1 mt-5">
<a href="/search" aria-label={`Search blog posts and projects on ${SITE.TITLE}`} class={cn("size-9 rounded-full p-2 items-center justify-center bg-transparent stroke-current border border-edge hover:bg-chip hover:text-chip-ink transition-colors duration-300 ease-in-out", isNavActive(pathname, "/search") && "pointer-events-none", isNavActive(pathname, "/search") && ACTIVE_NAV_COLORS)}>
<svg class="size-full">
<use href="/ui.svg#search"></use>
</svg>
</a>
<a href="/rss.xml" target="_blank" aria-label={`Rss feed for ${SITE.TITLE}`} class="size-9 rounded-full p-2 items-center justify-center bg-transparent stroke-current border border-edge hover:bg-chip hover:text-chip-ink transition-colors duration-300 ease-in-out">
<svg class="size-full">
<use href="/ui.svg#rss"></use>
</svg>
</a>
<button id="drawer-theme-button" aria-label={`Toggle light and dark theme`} class="size-9 rounded-full p-2 items-center justify-center bg-transparent stroke-current border border-edge hover:bg-chip hover:text-chip-ink transition-colors duration-300 ease-in-out">
<svg class="block dark:hidden size-full">
<use href="/ui.svg#sun"></use>
</svg>
<svg class="hidden dark:block size-full">
<use href="/ui.svg#moon"></use>
</svg>
</button>
</div>
</div>
<style>
#drawer.open {
@apply h-full;
}
</style>