@still-void/ui 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/article-Dl8rGW5l.d.cts +177 -0
- package/dist/article-Dl8rGW5l.d.ts +177 -0
- package/dist/index.cjs +142 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -24
- package/dist/index.d.ts +40 -24
- package/dist/index.js +136 -63
- package/dist/index.js.map +1 -1
- package/dist/react/client/index.cjs +49 -42
- package/dist/react/client/index.cjs.map +1 -1
- package/dist/react/client/index.d.cts +29 -7
- package/dist/react/client/index.d.ts +29 -7
- package/dist/react/client/index.js +49 -42
- package/dist/react/client/index.js.map +1 -1
- package/dist/react/index.cjs +99 -63
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +22 -5
- package/dist/react/index.d.ts +22 -5
- package/dist/react/index.js +98 -63
- package/dist/react/index.js.map +1 -1
- package/dist/style.css +309 -262
- package/dist/theme.css +161 -95
- package/package.json +1 -1
- package/dist/article-CNQxbFAz.d.cts +0 -120
- package/dist/article-CNQxbFAz.d.ts +0 -120
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tokens/colors.ts","../src/tokens/typography.ts","../src/tokens/spacing.ts","../src/tokens/motion.ts","../src/tokens/categories.ts","../src/recipes/cx.ts","../src/recipes/shell.ts","../src/recipes/content.ts","../src/recipes/article.ts","../src/behaviors/themeManager.ts","../src/behaviors/scrollSpy.ts","../src/behaviors/readingProgress.ts","../src/behaviors/clipboard.ts"],"sourcesContent":["/**\n * Quiet Tech color tokens.\n * Values ported literally from the Quiet Tech spec (blog.kalleopinheiro.dev).\n * Do not round or \"approximate\" — fidelity rule.\n */\nexport const colors = {\n dark: {\n bg: '#0A0A0C',\n bgElev: '#111114',\n surface: '#16161B',\n surface2: '#1C1C22',\n border: 'rgba(255,255,255,0.08)',\n borderStrong: 'rgba(255,255,255,0.14)',\n text: '#EDEDF0',\n text2: '#8B8B96',\n // Corrected from #5A5A66 (~2.6:1 on surface) to meet WCAG AA 4.5:1 — text3 is used for\n // real copy (metadata, TOC links), not decoration, so it must be readable, not just muted.\n text3: '#83838F',\n },\n light: {\n bg: '#F7F7F5',\n bgElev: '#FFFFFF',\n surface: '#FFFFFF',\n surface2: '#F2F2EF',\n border: 'rgba(0,0,0,0.08)',\n borderStrong: 'rgba(0,0,0,0.14)',\n text: '#16161B',\n text2: '#5A5A66',\n // Corrected from #8B8B96 (~3.1:1 on white) to meet WCAG AA 4.5:1, same reasoning as dark.\n text3: '#6F6F78',\n },\n} as const;\n\nexport const accents = {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n} as const;\n\nexport type ThemeMode = keyof typeof colors;\nexport type AccentName = keyof typeof accents;\nexport type ColorScheme = (typeof colors)[ThemeMode];\n\nexport const themeModes = Object.keys(colors) as ThemeMode[];\nexport const accentNames = Object.keys(accents) as AccentName[];\n\nexport const DEFAULT_MODE: ThemeMode = 'dark';\nexport const DEFAULT_ACCENT: AccentName = 'cyan';\n","/**\n * Quiet Tech typography tokens.\n * Families are fixed by the spec: Sora (display), Manrope (body), JetBrains Mono (code).\n * System fallbacks are loading fallbacks only — the final family must be the correct one.\n */\nexport const fontFamilies = {\n display: \"'Sora', ui-sans-serif, system-ui, sans-serif\",\n body: \"'Manrope', ui-sans-serif, system-ui, sans-serif\",\n mono: \"'JetBrains Mono', ui-monospace, 'SF Mono', monospace\",\n} as const;\n\nexport const fontWeights = {\n regular: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n} as const;\n\nexport const fontSizes = {\n xs: '0.75rem', // 12px — meta, pills\n sm: '0.8125rem', // 13px — captions, code\n base: '0.9375rem', // 15px — body\n md: '1rem', // 16px — lead paragraphs\n lg: '1.125rem', // 18px — article lead\n xl: '1.375rem', // 22px — card titles, h3\n '2xl': '1.75rem', // 28px — h2\n '3xl': '2.25rem', // 36px — article title\n '4xl': '2.75rem', // 44px — hero display\n} as const;\n\nexport const lineHeights = {\n tight: 1.15,\n snug: 1.3,\n normal: 1.5,\n relaxed: 1.7,\n} as const;\n\nexport const letterSpacings = {\n display: '-0.02em',\n normal: '0',\n wide: '0.08em',\n} as const;\n\nexport type FontFamily = keyof typeof fontFamilies;\nexport type FontSize = keyof typeof fontSizes;\nexport type FontWeight = keyof typeof fontWeights;\n","/**\n * Quiet Tech spacing scale (4→72px) and radii (6/8/12/16/full).\n */\nexport const spacing = {\n 1: '4px',\n 2: '8px',\n 3: '12px',\n 4: '16px',\n 5: '20px',\n 6: '24px',\n 8: '32px',\n 10: '40px',\n 12: '48px',\n 14: '56px',\n 16: '64px',\n 18: '72px',\n} as const;\n\nexport const radii = {\n sm: '6px',\n md: '8px',\n lg: '12px',\n xl: '16px',\n full: '9999px',\n} as const;\n\nexport type SpacingStep = keyof typeof spacing;\nexport type Radius = keyof typeof radii;\n","/**\n * Quiet Tech motion tokens.\n * Hover transitions use the signature easing; the reading progress bar is linear.\n */\nexport const easings = {\n hover: 'cubic-bezier(.3,.7,.4,1)',\n linear: 'linear',\n} as const;\n\nexport const durations = {\n fast: '120ms',\n base: '200ms',\n slow: '320ms',\n} as const;\n\nexport type Easing = keyof typeof easings;\nexport type Duration = keyof typeof durations;\n","import { accents, type AccentName } from './colors';\n\n/**\n * Blog categories from the prototype. Categories render as a colored dot + label\n * (never an emoji). The pill also accepts any CSS color for whitelabel use.\n */\nexport type CategoryName = 'ia' | 'prompt' | 'dev' | 'arch' | 'ts';\n\nexport const defaultCategoryColors: Record<CategoryName, AccentName> = {\n ia: 'violet',\n prompt: 'amber',\n dev: 'mint',\n arch: 'cyan',\n ts: 'cyan',\n};\n\n/** Resolve an accent name or raw CSS color to a CSS color value. */\nexport function resolveAccentColor(color: AccentName | (string & {})): string {\n return color in accents ? accents[color as AccentName] : color;\n}\n\n/** Resolve a category name, accent name, or raw CSS color to a CSS color value. */\nexport function resolveCategoryColor(\n color: CategoryName | AccentName | (string & {}),\n): string {\n if (color in defaultCategoryColors) {\n return accents[defaultCategoryColors[color as CategoryName]];\n }\n return resolveAccentColor(color);\n}\n","/** Minimal class-name joiner. Falsy values are dropped. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { cx } from './cx';\n\n/**\n * Shell recipes: Header, Logo, Footer.\n * Recipes are pure functions returning class strings — no DOM, no framework.\n * Safe in Next.js Server Components; usable via [class] in Angular, :class in Vue.\n */\n\nexport interface HeaderOptions {\n /** Frosted glass background (sticky headers). */\n glass?: boolean;\n}\n\nexport function header(options: HeaderOptions = {}): string {\n return cx('qt-header', options.glass !== false && 'qt-glass');\n}\n\nexport const headerClasses = {\n nav: 'qt-header__nav',\n link: 'qt-header__link',\n linkActive: cx('qt-header__link', 'qt-header__link--active'),\n actions: 'qt-header__actions',\n} as const;\n\nexport function logo(): string {\n return 'qt-logo';\n}\n\nexport const logoClasses = {\n dot: 'qt-logo__dot',\n} as const;\n\nexport function footer(): string {\n return 'qt-footer';\n}\n\nexport const footerClasses = {\n links: 'qt-footer__links',\n link: 'qt-footer__link',\n} as const;\n","import { cx } from './cx';\n\n/**\n * Content recipes: CategoryPill, PostCard, FeaturedPostCard, PostGrid,\n * Sidebar, Hero, Skeleton. Pure functions — Server Component safe.\n */\n\nexport interface CategoryPillOptions {\n interactive?: boolean;\n active?: boolean;\n}\n\nexport function categoryPill(options: CategoryPillOptions = {}): string {\n return cx(\n 'qt-pill',\n options.interactive && 'qt-pill--interactive',\n options.active && 'qt-pill--active',\n );\n}\n\nexport const categoryPillClasses = {\n dot: 'qt-pill__dot',\n} as const;\n\nexport interface PostCardOptions {\n dense?: boolean;\n hover?: boolean;\n}\n\nexport function postCard(options: PostCardOptions = {}): string {\n return cx(\n 'qt-post-card',\n options.dense && 'qt-post-card--dense',\n options.hover !== false && 'qt-card-hover',\n );\n}\n\nexport const postCardClasses = {\n meta: 'qt-post-card__meta',\n title: 'qt-post-card__title',\n excerpt: 'qt-post-card__excerpt',\n} as const;\n\nexport function featuredPostCard(): string {\n return cx('qt-featured-card', 'qt-gradient-border', 'qt-card-hover');\n}\n\nexport const featuredPostCardClasses = {\n body: 'qt-featured-card__body',\n title: 'qt-featured-card__title',\n visual: 'qt-featured-card__visual',\n} as const;\n\nexport function postGrid(): string {\n return 'qt-post-grid';\n}\n\nexport interface LayoutOptions {\n withSidebar?: boolean;\n}\n\nexport function layout(options: LayoutOptions = {}): string {\n return cx('qt-layout', options.withSidebar && 'qt-layout--with-sidebar');\n}\n\nexport function sidebar(): string {\n return 'qt-sidebar';\n}\n\nexport const sidebarClasses = {\n sectionTitle: 'qt-sidebar__section-title',\n} as const;\n\nexport function hero(): string {\n return 'qt-hero';\n}\n\nexport const heroClasses = {\n eyebrow: 'qt-hero__eyebrow',\n title: 'qt-hero__title',\n description: 'qt-hero__description',\n} as const;\n\nexport interface SkeletonOptions {\n small?: boolean;\n}\n\nexport function skeletonLine(options: SkeletonOptions = {}): string {\n return cx('qt-skeleton', 'qt-skeleton-line', options.small && 'qt-skeleton-line--sm');\n}\n\nexport function cardSkeleton(): string {\n return 'qt-card-skeleton';\n}\n","import { cx } from './cx';\n\n/**\n * Article recipes: CodeBlock, Callout, TableOfContents, ReadingProgress,\n * ArticleHeader, Prose. Pure functions — Server Component safe.\n */\n\nexport function codeBlock(): string {\n return 'qt-code-block';\n}\n\nexport const codeBlockClasses = {\n header: 'qt-code-block__header',\n pre: 'qt-code-block__pre',\n copy: 'qt-code-block__copy',\n copyCopied: cx('qt-code-block__copy', 'qt-code-block__copy--copied'),\n} as const;\n\nexport type CalloutKind = 'note' | 'warn' | 'aha';\n\nexport function callout(kind: CalloutKind): string {\n return cx('qt-callout', `qt-callout--${kind}`);\n}\n\nexport const calloutClasses = {\n label: 'qt-callout__label',\n} as const;\n\nexport const calloutLabels: Record<CalloutKind, string> = {\n note: 'Note',\n warn: 'Warn',\n aha: 'Aha!',\n};\n\nexport function tableOfContents(): string {\n return 'qt-toc';\n}\n\nexport interface TocLinkOptions {\n active?: boolean;\n /** Heading depth, 2 (h2) or 3 (h3). Depth 3 indents. */\n depth?: 2 | 3;\n}\n\nexport function tocLink(options: TocLinkOptions = {}): string {\n return cx(\n 'qt-toc__link',\n options.active && 'qt-toc__link--active',\n options.depth === 3 && 'qt-toc__link--depth-3',\n );\n}\n\nexport function readingProgress(): string {\n return 'qt-reading-progress';\n}\n\nexport const readingProgressClasses = {\n bar: 'qt-reading-progress__bar',\n} as const;\n\n/** CSS var read by `.qt-reading-progress__bar` (0 → 1). */\nexport const READING_PROGRESS_VAR = '--qt-reading-progress';\n\nexport function articleHeader(): string {\n return 'qt-article-header';\n}\n\nexport const articleHeaderClasses = {\n title: 'qt-article-header__title',\n meta: 'qt-article-header__meta',\n author: 'qt-article-header__author',\n} as const;\n\nexport function prose(): string {\n return 'qt-prose';\n}\n\nexport const proseClasses = {\n lead: 'qt-prose__lead',\n} as const;\n","import {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n accentNames,\n themeModes,\n type AccentName,\n type ThemeMode,\n} from '../tokens/colors';\n\nexport interface ThemeState {\n mode: ThemeMode;\n accent: AccentName;\n}\n\nexport interface ThemeManagerOptions {\n /** Element receiving data-theme / data-accent. Defaults to <html>. */\n root?: HTMLElement;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key. Pass null to disable persistence. */\n storageKey?: string | null;\n}\n\nexport interface ThemeManager {\n getState: () => ThemeState;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n subscribe: (listener: (state: ThemeState) => void) => () => void;\n destroy: () => void;\n}\n\nconst DEFAULT_STORAGE_KEY = 'quiet-tech-theme';\n\nfunction isMode(value: unknown): value is ThemeMode {\n return themeModes.includes(value as ThemeMode);\n}\n\nfunction isAccent(value: unknown): value is AccentName {\n return accentNames.includes(value as AccentName);\n}\n\nfunction readStorage(key: string): Partial<ThemeState> {\n try {\n const raw = window.localStorage.getItem(key);\n if (!raw) return {};\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return {};\n const { mode, accent } = parsed as Record<string, unknown>;\n return {\n ...(isMode(mode) ? { mode } : {}),\n ...(isAccent(accent) ? { accent } : {}),\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Framework-agnostic theme controller. Applies `data-theme` and `data-accent`\n * attributes; theme.css does the rest via CSS vars. If the server already\n * rendered the attributes (RSC/SSR), those win over defaults, so there is\n * no flash of wrong theme.\n */\nexport function createThemeManager(options: ThemeManagerOptions = {}): ThemeManager {\n const root = options.root ?? document.documentElement;\n const storageKey = options.storageKey === null ? null : (options.storageKey ?? DEFAULT_STORAGE_KEY);\n\n const ssrMode = root.getAttribute('data-theme');\n const ssrAccent = root.getAttribute('data-accent');\n const stored = storageKey ? readStorage(storageKey) : {};\n\n let state: ThemeState = {\n mode: stored.mode ?? (isMode(ssrMode) ? ssrMode : (options.defaultMode ?? DEFAULT_MODE)),\n accent:\n stored.accent ?? (isAccent(ssrAccent) ? ssrAccent : (options.defaultAccent ?? DEFAULT_ACCENT)),\n };\n\n const listeners = new Set<(state: ThemeState) => void>();\n\n function apply(): void {\n root.setAttribute('data-theme', state.mode);\n root.setAttribute('data-accent', state.accent);\n if (storageKey) {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(state));\n } catch {\n // storage unavailable (private mode, quota) — theme still applies\n }\n }\n for (const listener of listeners) listener(state);\n }\n\n apply();\n\n return {\n getState: () => state,\n setMode(mode) {\n state = { ...state, mode };\n apply();\n },\n setAccent(accent) {\n state = { ...state, accent };\n apply();\n },\n toggleMode() {\n state = { ...state, mode: state.mode === 'dark' ? 'light' : 'dark' };\n apply();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n destroy() {\n listeners.clear();\n },\n };\n}\n","export interface ScrollSpyOptions {\n /** Called whenever the active heading changes. `null` when none is visible. */\n onChange: (activeId: string | null) => void;\n /** Forwarded to IntersectionObserver. Default biases toward the reading line. */\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport interface ScrollSpy {\n destroy: () => void;\n}\n\n/**\n * Watches headings by id and reports which one is active.\n * Framework-agnostic core used by the React TableOfContents.\n */\nexport function createScrollSpy(ids: readonly string[], options: ScrollSpyOptions): ScrollSpy {\n const visible = new Map<string, number>();\n\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n visible.set(entry.target.id, entry.intersectionRatio);\n } else {\n visible.delete(entry.target.id);\n }\n }\n // First visible id in document order wins.\n const active = ids.find((id) => visible.has(id)) ?? null;\n options.onChange(active);\n },\n {\n rootMargin: options.rootMargin ?? '0px 0px -70% 0px',\n threshold: options.threshold ?? 0,\n },\n );\n\n for (const id of ids) {\n const el = document.getElementById(id);\n if (el) observer.observe(el);\n }\n\n return {\n destroy: () => observer.disconnect(),\n };\n}\n","import { READING_PROGRESS_VAR } from '../recipes/article';\n\nexport interface ReadingProgressOptions {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement;\n /** Receives progress in [0, 1]. */\n onChange?: (percent: number) => void;\n /** Element that receives the CSS var (default: <html>). Pass null to skip. */\n varTarget?: HTMLElement | null;\n}\n\nexport interface ReadingProgress {\n getPercent: () => number;\n destroy: () => void;\n}\n\n/**\n * Tracks document (or element) reading progress. Writes the\n * `--qt-reading-progress` CSS var consumed by `.qt-reading-progress__bar`.\n */\nexport function createReadingProgress(options: ReadingProgressOptions = {}): ReadingProgress {\n const varTarget =\n options.varTarget === null ? null : (options.varTarget ?? document.documentElement);\n let percent = 0;\n\n function measure(): number {\n if (options.target) {\n const rect = options.target.getBoundingClientRect();\n const viewport = window.innerHeight;\n const total = rect.height - viewport;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, -rect.top / total));\n }\n const doc = document.documentElement;\n const total = doc.scrollHeight - window.innerHeight;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, window.scrollY / total));\n }\n\n function update(): void {\n percent = measure();\n varTarget?.style.setProperty(READING_PROGRESS_VAR, String(percent));\n options.onChange?.(percent);\n }\n\n update();\n window.addEventListener('scroll', update, { passive: true });\n window.addEventListener('resize', update, { passive: true });\n\n return {\n getPercent: () => percent,\n destroy() {\n window.removeEventListener('scroll', update);\n window.removeEventListener('resize', update);\n },\n };\n}\n","/** Copy text to the clipboard. Returns false when the Clipboard API is unavailable or denied. */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) return false;\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAKO,IAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA,IAGP,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,IAEP,OAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AACT;AAMO,IAAM,aAAa,OAAO,KAAK,MAAM;AACrC,IAAM,cAAc,OAAO,KAAK,OAAO;AAEvC,IAAM,eAA0B;AAChC,IAAM,iBAA6B;;;AC3CnC,IAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AACR;AAEO,IAAM,cAAc;AAAA,EACzB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AA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UAAkB;AACzB,QAAI,QAAQ,QAAQ;AAClB,YAAM,OAAO,QAAQ,OAAO,sBAAsB;AAClD,YAAM,WAAW,OAAO;AACxB,YAAMA,SAAQ,KAAK,SAAS;AAC5B,UAAIA,UAAS,EAAG,QAAO;AACvB,aAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,KAAK,MAAMA,MAAK,CAAC;AAAA,IACnD;AACA,UAAM,MAAM,SAAS;AACrB,UAAM,QAAQ,IAAI,eAAe,OAAO;AACxC,QAAI,SAAS,EAAG,QAAO;AACvB,WAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,OAAO,UAAU,KAAK,CAAC;AAAA,EACxD;AAEA,WAAS,SAAe;AACtB,cAAU,QAAQ;AAClB,eAAW,MAAM,YAAY,sBAAsB,OAAO,OAAO,CAAC;AAClE,YAAQ,WAAW,OAAO;AAAA,EAC5B;AAEA,SAAO;AACP,SAAO,iBAAiB,UAAU,QAAQ,EAAE,SAAS,KAAK,CAAC;AAC3D,SAAO,iBAAiB,UAAU,QAAQ,EAAE,SAAS,KAAK,CAAC;AAE3D,SAAO;AAAA,IACL,YAAY,MAAM;AAAA,IAClB,UAAU;AACR,aAAO,oBAAoB,UAAU,MAAM;AAC3C,aAAO,oBAAoB,UAAU,MAAM;AAAA,IAC7C;AAAA,EACF;AACF;;;ACvDA,eAAsB,gBAAgB,MAAgC;AACpE,MAAI,CAAC,UAAU,WAAW,UAAW,QAAO;AAC5C,MAAI;AACF,UAAM,UAAU,UAAU,UAAU,IAAI;AACxC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["total"]}
|
|
1
|
+
{"version":3,"sources":["../src/tokens/colors.ts","../src/tokens/typography.ts","../src/tokens/spacing.ts","../src/tokens/motion.ts","../src/tokens/categories.ts","../src/tokens/zIndex.ts","../src/recipes/cx.ts","../src/recipes/shell.ts","../src/recipes/content.ts","../src/recipes/article.ts","../src/behaviors/themeManager.ts","../src/behaviors/scrollSpy.ts","../src/behaviors/readingProgress.ts","../src/behaviors/clipboard.ts"],"sourcesContent":["/**\n * Still Void color tokens.\n * Values ported literally from the Still Void spec (blog.kalleopinheiro.dev).\n * Do not round or \"approximate\" — fidelity rule.\n */\nexport const colors = {\n dark: {\n bg: '#0A0A0C',\n bgElev: '#111114',\n surface: '#16161B',\n surface2: '#1C1C22',\n border: 'rgba(255,255,255,0.08)',\n borderStrong: 'rgba(255,255,255,0.14)',\n text: '#EDEDF0',\n text2: '#8B8B96',\n // Corrected from #5A5A66 (~2.6:1 on surface) to meet WCAG AA 4.5:1 — text3 is used for\n // real copy (metadata, TOC links), not decoration, so it must be readable, not just muted.\n text3: '#83838F',\n },\n light: {\n bg: '#F7F7F5',\n bgElev: '#FFFFFF',\n surface: '#FFFFFF',\n surface2: '#F2F2EF',\n border: 'rgba(0,0,0,0.08)',\n borderStrong: 'rgba(0,0,0,0.14)',\n text: '#16161B',\n text2: '#5A5A66',\n // Corrected from #8B8B96 (~3.1:1 on white) to meet WCAG AA 4.5:1, same reasoning as dark.\n // A further step from #6F6F78 to #6D6D76: the first fix cleared white/paper (≥4.7:1) but\n // was only ~4.44:1 against surface2 (#F2F2EF), the darkest of the light surfaces — still a\n // failure. Verified against bg/bgElev/surface/surface2 together, not just one background.\n text3: '#6D6D76',\n },\n} as const;\n\nexport const accents = {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n} as const;\n\n/**\n * Text/UI-safe accent variants (\"ink\"). `accents` above is tuned for surface use\n * (dots, gradient border, progress bar) and fails WCAG AA as text on light\n * backgrounds (e.g. cyan is ~1.8:1 on white). These preserve the dark-mode\n * values (already ≥6.9:1) and darken each hue for light mode to clear 4.5:1\n * against both light surfaces. Used anywhere the accent colors text: prose\n * links, active TOC state, callout labels, hero eyebrow, copy-success, focus ring.\n */\nexport const accentsInk = {\n dark: {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n },\n light: {\n cyan: 'oklch(0.525 0.09 210)',\n violet: 'oklch(0.545 0.14 295)',\n mint: 'oklch(0.52 0.1 160)',\n amber: 'oklch(0.535 0.11 75)',\n },\n} as const;\n\n/**\n * Semantic state colors — independent of the switchable `accent`, so a\n * consumer picking `data-accent=\"amber\"` never collides a warning with the\n * site accent. Fixed per meaning in both surface and text/UI (\"ink\") forms,\n * same split as `accents`/`accentsInk`.\n */\nexport const semantic = {\n dark: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n light: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n} as const;\n\nexport const semanticInk = {\n dark: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n light: {\n danger: 'oklch(0.555 0.19 25)',\n success: 'oklch(0.515 0.14 150)',\n info: 'oklch(0.525 0.09 210)',\n warning: 'oklch(0.535 0.11 75)',\n },\n} as const;\n\nexport type ThemeMode = keyof typeof colors;\nexport type AccentName = keyof typeof accents;\nexport type ColorScheme = (typeof colors)[ThemeMode];\nexport type SemanticName = keyof (typeof semantic)['dark'];\n\nexport const themeModes = Object.keys(colors) as ThemeMode[];\nexport const accentNames = Object.keys(accents) as AccentName[];\n\nexport const DEFAULT_MODE: ThemeMode = 'dark';\nexport const DEFAULT_ACCENT: AccentName = 'cyan';\n","/**\n * Still Void typography tokens.\n * Families are fixed by the spec: Sora (display), Manrope (body), JetBrains Mono (code).\n * System fallbacks are loading fallbacks only — the final family must be the correct one.\n */\nexport const fontFamilies = {\n display: \"'Sora', ui-sans-serif, system-ui, sans-serif\",\n body: \"'Manrope', ui-sans-serif, system-ui, sans-serif\",\n mono: \"'JetBrains Mono', ui-monospace, 'SF Mono', monospace\",\n} as const;\n\nexport const fontWeights = {\n regular: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n} as const;\n\nexport const fontSizes = {\n xs: '0.75rem', // 12px — meta, pills\n sm: '0.8125rem', // 13px — captions, code\n base: '0.9375rem', // 15px — body\n md: '1rem', // 16px — lead paragraphs\n lg: '1.125rem', // 18px — article lead\n xl: '1.375rem', // 22px — card titles, h3\n '2xl': '1.75rem', // 28px — h2\n '3xl': '2.25rem', // 36px — article title\n '4xl': '2.75rem', // 44px — hero display\n} as const;\n\nexport const lineHeights = {\n tight: 1.15,\n snug: 1.3,\n normal: 1.5,\n relaxed: 1.7,\n} as const;\n\nexport const letterSpacings = {\n display: '-0.02em',\n normal: '0',\n wide: '0.08em',\n} as const;\n\nexport type FontFamily = keyof typeof fontFamilies;\nexport type FontSize = keyof typeof fontSizes;\nexport type FontWeight = keyof typeof fontWeights;\n","/**\n * Still Void spacing scale (4→72px) and radii (6/8/12/16/full).\n */\nexport const spacing = {\n 1: '4px',\n 2: '8px',\n 3: '12px',\n 4: '16px',\n 5: '20px',\n 6: '24px',\n 8: '32px',\n 10: '40px',\n 12: '48px',\n 14: '56px',\n 16: '64px',\n 18: '72px',\n} as const;\n\nexport const radii = {\n sm: '6px',\n md: '8px',\n lg: '12px',\n xl: '16px',\n full: '9999px',\n} as const;\n\nexport type SpacingStep = keyof typeof spacing;\nexport type Radius = keyof typeof radii;\n","/**\n * Still Void motion tokens.\n * Hover transitions use the signature easing; the reading progress bar is linear.\n */\nexport const easings = {\n hover: 'cubic-bezier(.3,.7,.4,1)',\n linear: 'linear',\n} as const;\n\nexport const durations = {\n fast: '120ms',\n base: '200ms',\n slow: '320ms',\n} as const;\n\nexport type Easing = keyof typeof easings;\nexport type Duration = keyof typeof durations;\n","import { accents, type AccentName } from './colors';\n\n/**\n * Blog categories from the prototype. Categories render as a colored dot + label\n * (never an emoji). The pill also accepts any CSS color for whitelabel use.\n */\nexport type CategoryName = 'ia' | 'prompt' | 'dev' | 'arch' | 'ts';\n\nexport const defaultCategoryColors: Record<CategoryName, AccentName> = {\n ia: 'violet',\n prompt: 'amber',\n dev: 'mint',\n arch: 'cyan',\n ts: 'cyan',\n};\n\nconst hasOwn = <T extends object>(obj: T, key: string): key is Extract<keyof T, string> =>\n Object.prototype.hasOwnProperty.call(obj, key);\n\n/** Resolve an accent name or raw CSS color to a CSS color value. */\nexport function resolveAccentColor(color: AccentName | (string & {})): string {\n return hasOwn(accents, color) ? accents[color] : color;\n}\n\n/** Resolve a category name, accent name, or raw CSS color to a CSS color value. */\nexport function resolveCategoryColor(\n color: CategoryName | AccentName | (string & {}),\n): string {\n if (hasOwn(defaultCategoryColors, color)) {\n return accents[defaultCategoryColors[color]];\n }\n return resolveAccentColor(color);\n}\n","/**\n * Still Void z-index scale. Named steps instead of arbitrary numbers so new\n * layered components (dropdown, modal, toast, tooltip) stack predictably\n * against the existing sticky header and reading progress bar.\n */\nexport const zIndex = {\n dropdown: 10,\n sticky: 20,\n backdrop: 30,\n modal: 40,\n toast: 50,\n tooltip: 60,\n} as const;\n\nexport type ZIndexStep = keyof typeof zIndex;\n","/** Minimal class-name joiner. Falsy values are dropped. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { cx } from './cx';\n\n/**\n * Shell recipes: Header, Logo, Footer.\n * Recipes are pure functions returning class strings — no DOM, no framework.\n * Safe in Next.js Server Components; usable via [class] in Angular, :class in Vue.\n */\n\nexport interface HeaderOptions {\n /** Frosted glass background (sticky headers). */\n glass?: boolean;\n}\n\nexport function header(options: HeaderOptions = {}): string {\n return cx('sv-header', options.glass !== false && 'sv-glass');\n}\n\nexport const headerClasses = {\n nav: 'sv-header__nav',\n link: 'sv-header__link',\n linkActive: cx('sv-header__link', 'sv-header__link--active'),\n actions: 'sv-header__actions',\n} as const;\n\nexport function logo(): string {\n return 'sv-logo';\n}\n\nexport const logoClasses = {\n dot: 'sv-logo__dot',\n} as const;\n\nexport function footer(): string {\n return 'sv-footer';\n}\n\nexport const footerClasses = {\n links: 'sv-footer__links',\n link: 'sv-footer__link',\n} as const;\n","import { cx } from './cx';\n\n/**\n * Content recipes: CategoryPill, PostCard, FeaturedPostCard, PostGrid,\n * Sidebar, Hero, Skeleton. Pure functions — Server Component safe.\n */\n\nexport interface CategoryPillOptions {\n interactive?: boolean;\n active?: boolean;\n}\n\nexport function categoryPill(options: CategoryPillOptions = {}): string {\n return cx(\n 'sv-pill',\n options.interactive && 'sv-pill--interactive',\n options.active && 'sv-pill--active',\n );\n}\n\nexport const categoryPillClasses = {\n dot: 'sv-pill__dot',\n} as const;\n\nexport interface PostCardOptions {\n dense?: boolean;\n hover?: boolean;\n}\n\nexport function postCard(options: PostCardOptions = {}): string {\n return cx(\n 'sv-post-card',\n options.dense && 'sv-post-card--dense',\n options.hover !== false && 'sv-card-hover',\n );\n}\n\nexport const postCardClasses = {\n meta: 'sv-post-card__meta',\n title: 'sv-post-card__title',\n excerpt: 'sv-post-card__excerpt',\n} as const;\n\nexport function featuredPostCard(): string {\n return cx('sv-featured-card', 'sv-gradient-border', 'sv-card-hover');\n}\n\nexport const featuredPostCardClasses = {\n body: 'sv-featured-card__body',\n title: 'sv-featured-card__title',\n visual: 'sv-featured-card__visual',\n} as const;\n\nexport function postGrid(): string {\n return 'sv-post-grid';\n}\n\nexport interface LayoutOptions {\n withSidebar?: boolean;\n}\n\nexport function layout(options: LayoutOptions = {}): string {\n return cx('sv-layout', options.withSidebar && 'sv-layout--with-sidebar');\n}\n\nexport function sidebar(): string {\n return 'sv-sidebar';\n}\n\nexport const sidebarClasses = {\n sectionTitle: 'sv-sidebar__section-title',\n} as const;\n\nexport function hero(): string {\n return 'sv-hero';\n}\n\nexport const heroClasses = {\n eyebrow: 'sv-hero__eyebrow',\n title: 'sv-hero__title',\n description: 'sv-hero__description',\n} as const;\n\nexport interface SkeletonOptions {\n small?: boolean;\n}\n\nexport function skeletonLine(options: SkeletonOptions = {}): string {\n return cx('sv-skeleton', 'sv-skeleton-line', options.small && 'sv-skeleton-line--sm');\n}\n\nexport function cardSkeleton(): string {\n return 'sv-card-skeleton';\n}\n","import { cx } from './cx';\n\n/**\n * Article recipes: CodeBlock, Callout, TableOfContents, ReadingProgress,\n * ArticleHeader, Prose. Pure functions — Server Component safe.\n */\n\nexport function codeBlock(): string {\n return 'sv-code-block';\n}\n\nexport const codeBlockClasses = {\n header: 'sv-code-block__header',\n pre: 'sv-code-block__pre',\n copy: 'sv-code-block__copy',\n copyCopied: cx('sv-code-block__copy', 'sv-code-block__copy--copied'),\n} as const;\n\nexport type CalloutKind = 'note' | 'warn' | 'aha';\n\nexport function callout(kind: CalloutKind): string {\n return cx('sv-callout', `sv-callout--${kind}`);\n}\n\nexport const calloutClasses = {\n label: 'sv-callout__label',\n} as const;\n\nexport const calloutLabels: Record<CalloutKind, string> = {\n note: 'Note',\n warn: 'Warn',\n aha: 'Aha!',\n};\n\nexport function tableOfContents(): string {\n return 'sv-toc';\n}\n\nexport interface TocLinkOptions {\n active?: boolean;\n /** Heading depth, 2 (h2) or 3 (h3). Depth 3 indents. */\n depth?: 2 | 3;\n}\n\nexport function tocLink(options: TocLinkOptions = {}): string {\n return cx(\n 'sv-toc__link',\n options.active && 'sv-toc__link--active',\n options.depth === 3 && 'sv-toc__link--depth-3',\n );\n}\n\nexport function readingProgress(): string {\n return 'sv-reading-progress';\n}\n\nexport const readingProgressClasses = {\n bar: 'sv-reading-progress__bar',\n} as const;\n\n/** CSS var read by `.sv-reading-progress__bar` (0 → 1). */\nexport const READING_PROGRESS_VAR = '--sv-reading-progress';\n\nexport function articleHeader(): string {\n return 'sv-article-header';\n}\n\nexport const articleHeaderClasses = {\n title: 'sv-article-header__title',\n meta: 'sv-article-header__meta',\n author: 'sv-article-header__author',\n} as const;\n\nexport function prose(): string {\n return 'sv-prose';\n}\n\nexport const proseClasses = {\n lead: 'sv-prose__lead',\n} as const;\n","import {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n accentNames,\n themeModes,\n type AccentName,\n type ThemeMode,\n} from '../tokens/colors';\n\nexport interface ThemeState {\n mode: ThemeMode;\n accent: AccentName;\n}\n\nexport interface ThemeManagerOptions {\n /** Element receiving data-theme / data-accent. Defaults to <html>. */\n root?: HTMLElement;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key. Pass null to disable persistence. */\n storageKey?: string | null;\n}\n\nexport interface ThemeManager {\n getState: () => ThemeState;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n subscribe: (listener: (state: ThemeState) => void) => () => void;\n destroy: () => void;\n}\n\nexport const DEFAULT_STORAGE_KEY = 'still-void-theme';\n\nfunction isMode(value: unknown): value is ThemeMode {\n return themeModes.includes(value as ThemeMode);\n}\n\nfunction isAccent(value: unknown): value is AccentName {\n return accentNames.includes(value as AccentName);\n}\n\nfunction readStorage(key: string): Partial<ThemeState> {\n try {\n const raw = window.localStorage.getItem(key);\n if (!raw) return {};\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return {};\n const { mode, accent } = parsed as Record<string, unknown>;\n return {\n ...(isMode(mode) ? { mode } : {}),\n ...(isAccent(accent) ? { accent } : {}),\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Framework-agnostic theme controller. Applies `data-theme` and `data-accent`\n * attributes; theme.css does the rest via CSS vars. If the server already\n * rendered the attributes (RSC/SSR), those win over defaults, so there is\n * no flash of wrong theme.\n */\nexport function createThemeManager(options: ThemeManagerOptions = {}): ThemeManager {\n const root = options.root ?? document.documentElement;\n const storageKey = options.storageKey === null ? null : (options.storageKey ?? DEFAULT_STORAGE_KEY);\n\n const ssrMode = root.getAttribute('data-theme');\n const ssrAccent = root.getAttribute('data-accent');\n const stored = storageKey ? readStorage(storageKey) : {};\n\n let state: ThemeState = {\n mode: stored.mode ?? (isMode(ssrMode) ? ssrMode : (options.defaultMode ?? DEFAULT_MODE)),\n accent:\n stored.accent ?? (isAccent(ssrAccent) ? ssrAccent : (options.defaultAccent ?? DEFAULT_ACCENT)),\n };\n\n const listeners = new Set<(state: ThemeState) => void>();\n\n function apply(): void {\n root.setAttribute('data-theme', state.mode);\n root.setAttribute('data-accent', state.accent);\n if (storageKey) {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(state));\n } catch {\n // storage unavailable (private mode, quota) — theme still applies\n }\n }\n for (const listener of listeners) listener(state);\n }\n\n apply();\n\n return {\n getState: () => state,\n setMode(mode) {\n state = { ...state, mode };\n apply();\n },\n setAccent(accent) {\n state = { ...state, accent };\n apply();\n },\n toggleMode() {\n state = { ...state, mode: state.mode === 'dark' ? 'light' : 'dark' };\n apply();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n destroy() {\n listeners.clear();\n },\n };\n}\n","export interface ScrollSpyOptions {\n /** Called whenever the active heading changes. `null` when none is visible. */\n onChange: (activeId: string | null) => void;\n /** Forwarded to IntersectionObserver. Default biases toward the reading line. */\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport interface ScrollSpy {\n destroy: () => void;\n}\n\n/**\n * Watches headings by id and reports which one is active.\n * Framework-agnostic core used by the React TableOfContents.\n */\nexport function createScrollSpy(ids: readonly string[], options: ScrollSpyOptions): ScrollSpy {\n const visible = new Map<string, number>();\n\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n visible.set(entry.target.id, entry.intersectionRatio);\n } else {\n visible.delete(entry.target.id);\n }\n }\n // First visible id in document order wins.\n const active = ids.find((id) => visible.has(id)) ?? null;\n options.onChange(active);\n },\n {\n rootMargin: options.rootMargin ?? '0px 0px -70% 0px',\n threshold: options.threshold ?? 0,\n },\n );\n\n for (const id of ids) {\n const el = document.getElementById(id);\n if (el) observer.observe(el);\n }\n\n return {\n destroy: () => observer.disconnect(),\n };\n}\n","import { READING_PROGRESS_VAR } from '../recipes/article';\n\n// jsdom (used in tests) doesn't implement requestAnimationFrame; fall back to\n// a timer so the throttling logic stays testable outside a real browser.\nconst raf: (cb: () => void) => number =\n typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function'\n ? (cb) => window.requestAnimationFrame(cb)\n : (cb) => setTimeout(cb, 16) as unknown as number;\nconst cancelRaf: (id: number) => void =\n typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function'\n ? (id) => window.cancelAnimationFrame(id)\n : (id) => clearTimeout(id as unknown as ReturnType<typeof setTimeout>);\n\nexport interface ReadingProgressOptions {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement;\n /** Receives progress in [0, 1]. */\n onChange?: (percent: number) => void;\n /** Element that receives the CSS var (default: <html>). Pass null to skip. */\n varTarget?: HTMLElement | null;\n}\n\nexport interface ReadingProgress {\n getPercent: () => number;\n destroy: () => void;\n}\n\n/**\n * Tracks document (or element) reading progress. Writes the\n * `--sv-reading-progress` CSS var consumed by `.sv-reading-progress__bar`.\n */\nexport function createReadingProgress(options: ReadingProgressOptions = {}): ReadingProgress {\n const varTarget =\n options.varTarget === null ? null : (options.varTarget ?? document.documentElement);\n let percent = 0;\n\n function measure(): number {\n if (options.target) {\n const rect = options.target.getBoundingClientRect();\n const viewport = window.innerHeight;\n const total = rect.height - viewport;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, -rect.top / total));\n }\n const doc = document.documentElement;\n const total = doc.scrollHeight - window.innerHeight;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, window.scrollY / total));\n }\n\n function update(): void {\n percent = measure();\n varTarget?.style.setProperty(READING_PROGRESS_VAR, String(percent));\n options.onChange?.(percent);\n }\n\n // Coalesce scroll/resize bursts into one measurement per animation frame —\n // without this, `measure()` (a forced layout read) runs once per event.\n let frame: number | null = null;\n function onFrame(): void {\n frame = null;\n update();\n }\n function schedule(): void {\n if (frame !== null) return;\n frame = raf(onFrame);\n }\n\n update();\n window.addEventListener('scroll', schedule, { passive: true });\n window.addEventListener('resize', schedule, { passive: true });\n\n return {\n getPercent: () => percent,\n destroy() {\n window.removeEventListener('scroll', schedule);\n window.removeEventListener('resize', schedule);\n if (frame !== null) cancelRaf(frame);\n },\n };\n}\n","/** Copy text to the clipboard. Returns false when the Clipboard API is unavailable or denied. */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) return false;\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";AAKO,IAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA,IAGP,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,OAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AACT;AAUO,IAAM,aAAa;AAAA,EACxB,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;AAQO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,MAAM;AAAA,IACN,SA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AAS,EAAG,QAAO;AACvB,aAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,KAAK,MAAMA,MAAK,CAAC;AAAA,IACnD;AACA,UAAM,MAAM,SAAS;AACrB,UAAM,QAAQ,IAAI,eAAe,OAAO;AACxC,QAAI,SAAS,EAAG,QAAO;AACvB,WAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,OAAO,UAAU,KAAK,CAAC;AAAA,EACxD;AAEA,WAAS,SAAe;AACtB,cAAU,QAAQ;AAClB,eAAW,MAAM,YAAY,sBAAsB,OAAO,OAAO,CAAC;AAClE,YAAQ,WAAW,OAAO;AAAA,EAC5B;AAIA,MAAI,QAAuB;AAC3B,WAAS,UAAgB;AACvB,YAAQ;AACR,WAAO;AAAA,EACT;AACA,WAAS,WAAiB;AACxB,QAAI,UAAU,KAAM;AACpB,YAAQ,IAAI,OAAO;AAAA,EACrB;AAEA,SAAO;AACP,SAAO,iBAAiB,UAAU,UAAU,EAAE,SAAS,KAAK,CAAC;AAC7D,SAAO,iBAAiB,UAAU,UAAU,EAAE,SAAS,KAAK,CAAC;AAE7D,SAAO;AAAA,IACL,YAAY,MAAM;AAAA,IAClB,UAAU;AACR,aAAO,oBAAoB,UAAU,QAAQ;AAC7C,aAAO,oBAAoB,UAAU,QAAQ;AAC7C,UAAI,UAAU,KAAM,WAAU,KAAK;AAAA,IACrC;AAAA,EACF;AACF;;;AC/EA,eAAsB,gBAAgB,MAAgC;AACpE,MAAI,CAAC,UAAU,WAAW,UAAW,QAAO;AAC5C,MAAI;AACF,UAAM,UAAU,UAAU,UAAU,IAAI;AACxC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["total"]}
|
|
@@ -60,7 +60,10 @@ var colors = {
|
|
|
60
60
|
text: "#16161B",
|
|
61
61
|
text2: "#5A5A66",
|
|
62
62
|
// Corrected from #8B8B96 (~3.1:1 on white) to meet WCAG AA 4.5:1, same reasoning as dark.
|
|
63
|
-
|
|
63
|
+
// A further step from #6F6F78 to #6D6D76: the first fix cleared white/paper (≥4.7:1) but
|
|
64
|
+
// was only ~4.44:1 against surface2 (#F2F2EF), the darkest of the light surfaces — still a
|
|
65
|
+
// failure. Verified against bg/bgElev/surface/surface2 together, not just one background.
|
|
66
|
+
text3: "#6D6D76"
|
|
64
67
|
}
|
|
65
68
|
};
|
|
66
69
|
var accents = {
|
|
@@ -75,7 +78,7 @@ var DEFAULT_MODE = "dark";
|
|
|
75
78
|
var DEFAULT_ACCENT = "cyan";
|
|
76
79
|
|
|
77
80
|
// src/behaviors/themeManager.ts
|
|
78
|
-
var DEFAULT_STORAGE_KEY = "
|
|
81
|
+
var DEFAULT_STORAGE_KEY = "still-void-theme";
|
|
79
82
|
function isMode(value) {
|
|
80
83
|
return themeModes.includes(value);
|
|
81
84
|
}
|
|
@@ -199,7 +202,7 @@ function ThemeToggle({ className, ...rest }) {
|
|
|
199
202
|
{
|
|
200
203
|
type: "button",
|
|
201
204
|
onClick: toggleMode,
|
|
202
|
-
className: cx("
|
|
205
|
+
className: cx("sv-header__link", className),
|
|
203
206
|
"aria-label": `Switch to ${next} theme`,
|
|
204
207
|
...rest,
|
|
205
208
|
children: mode === "dark" ? "Light" : "Dark"
|
|
@@ -223,28 +226,28 @@ async function copyToClipboard(text) {
|
|
|
223
226
|
|
|
224
227
|
// src/recipes/article.ts
|
|
225
228
|
var codeBlockClasses = {
|
|
226
|
-
header: "
|
|
227
|
-
pre: "
|
|
228
|
-
copy: "
|
|
229
|
-
copyCopied: cx("
|
|
229
|
+
header: "sv-code-block__header",
|
|
230
|
+
pre: "sv-code-block__pre",
|
|
231
|
+
copy: "sv-code-block__copy",
|
|
232
|
+
copyCopied: cx("sv-code-block__copy", "sv-code-block__copy--copied")
|
|
230
233
|
};
|
|
231
234
|
function tableOfContents() {
|
|
232
|
-
return "
|
|
235
|
+
return "sv-toc";
|
|
233
236
|
}
|
|
234
237
|
function tocLink(options = {}) {
|
|
235
238
|
return cx(
|
|
236
|
-
"
|
|
237
|
-
options.active && "
|
|
238
|
-
options.depth === 3 && "
|
|
239
|
+
"sv-toc__link",
|
|
240
|
+
options.active && "sv-toc__link--active",
|
|
241
|
+
options.depth === 3 && "sv-toc__link--depth-3"
|
|
239
242
|
);
|
|
240
243
|
}
|
|
241
244
|
function readingProgress() {
|
|
242
|
-
return "
|
|
245
|
+
return "sv-reading-progress";
|
|
243
246
|
}
|
|
244
247
|
var readingProgressClasses = {
|
|
245
|
-
bar: "
|
|
248
|
+
bar: "sv-reading-progress__bar"
|
|
246
249
|
};
|
|
247
|
-
var READING_PROGRESS_VAR = "--
|
|
250
|
+
var READING_PROGRESS_VAR = "--sv-reading-progress";
|
|
248
251
|
|
|
249
252
|
// src/react/client/CopyButton.tsx
|
|
250
253
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -291,6 +294,8 @@ var import_react4 = require("react");
|
|
|
291
294
|
var import_react3 = require("react");
|
|
292
295
|
|
|
293
296
|
// src/behaviors/readingProgress.ts
|
|
297
|
+
var raf = typeof window !== "undefined" && typeof window.requestAnimationFrame === "function" ? (cb) => window.requestAnimationFrame(cb) : (cb) => setTimeout(cb, 16);
|
|
298
|
+
var cancelRaf = typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function" ? (id) => window.cancelAnimationFrame(id) : (id) => clearTimeout(id);
|
|
294
299
|
function createReadingProgress(options = {}) {
|
|
295
300
|
const varTarget = options.varTarget === null ? null : options.varTarget ?? document.documentElement;
|
|
296
301
|
let percent = 0;
|
|
@@ -312,14 +317,24 @@ function createReadingProgress(options = {}) {
|
|
|
312
317
|
varTarget?.style.setProperty(READING_PROGRESS_VAR, String(percent));
|
|
313
318
|
options.onChange?.(percent);
|
|
314
319
|
}
|
|
320
|
+
let frame = null;
|
|
321
|
+
function onFrame() {
|
|
322
|
+
frame = null;
|
|
323
|
+
update();
|
|
324
|
+
}
|
|
325
|
+
function schedule() {
|
|
326
|
+
if (frame !== null) return;
|
|
327
|
+
frame = raf(onFrame);
|
|
328
|
+
}
|
|
315
329
|
update();
|
|
316
|
-
window.addEventListener("scroll",
|
|
317
|
-
window.addEventListener("resize",
|
|
330
|
+
window.addEventListener("scroll", schedule, { passive: true });
|
|
331
|
+
window.addEventListener("resize", schedule, { passive: true });
|
|
318
332
|
return {
|
|
319
333
|
getPercent: () => percent,
|
|
320
334
|
destroy() {
|
|
321
|
-
window.removeEventListener("scroll",
|
|
322
|
-
window.removeEventListener("resize",
|
|
335
|
+
window.removeEventListener("scroll", schedule);
|
|
336
|
+
window.removeEventListener("resize", schedule);
|
|
337
|
+
if (frame !== null) cancelRaf(frame);
|
|
323
338
|
}
|
|
324
339
|
};
|
|
325
340
|
}
|
|
@@ -363,15 +378,18 @@ function useScrollSpy(ids, rootMargin) {
|
|
|
363
378
|
}, [key, rootMargin]);
|
|
364
379
|
return activeId;
|
|
365
380
|
}
|
|
366
|
-
function useReadingProgress(target) {
|
|
381
|
+
function useReadingProgress(target, step = 1) {
|
|
367
382
|
const [percent, setPercent] = (0, import_react3.useState)(0);
|
|
368
383
|
(0, import_react3.useEffect)(() => {
|
|
369
384
|
const progress = createReadingProgress({
|
|
370
385
|
target: target ?? void 0,
|
|
371
|
-
onChange:
|
|
386
|
+
onChange: (value) => {
|
|
387
|
+
const bucket = step > 0 ? Math.round(value / step) * step : value;
|
|
388
|
+
setPercent((prev) => prev === bucket ? prev : bucket);
|
|
389
|
+
}
|
|
372
390
|
});
|
|
373
391
|
return () => progress.destroy();
|
|
374
|
-
}, [target]);
|
|
392
|
+
}, [target, step]);
|
|
375
393
|
return percent;
|
|
376
394
|
}
|
|
377
395
|
|
|
@@ -394,27 +412,16 @@ function TableOfContents({ items, rootMargin, className, ...rest }) {
|
|
|
394
412
|
|
|
395
413
|
// src/react/client/ReadingProgress.tsx
|
|
396
414
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
397
|
-
function ReadingProgress({ target, className, ...rest }) {
|
|
398
|
-
const percent = useReadingProgress(target);
|
|
399
|
-
|
|
400
|
-
"
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
className: cx(readingProgress(), className),
|
|
408
|
-
...rest,
|
|
409
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
410
|
-
"div",
|
|
411
|
-
{
|
|
412
|
-
className: readingProgressClasses.bar,
|
|
413
|
-
style: { transform: `scaleX(${percent})` }
|
|
414
|
-
}
|
|
415
|
-
)
|
|
416
|
-
}
|
|
417
|
-
);
|
|
415
|
+
function ReadingProgress({ target, announce, className, ...rest }) {
|
|
416
|
+
const percent = useReadingProgress(target, announce ? 0.1 : 1);
|
|
417
|
+
const a11yProps = announce ? {
|
|
418
|
+
role: "progressbar",
|
|
419
|
+
"aria-valuemin": 0,
|
|
420
|
+
"aria-valuemax": 100,
|
|
421
|
+
"aria-valuenow": Math.round(percent * 100),
|
|
422
|
+
"aria-label": "Reading progress"
|
|
423
|
+
} : { "aria-hidden": true };
|
|
424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cx(readingProgress(), className), ...a11yProps, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: readingProgressClasses.bar }) });
|
|
418
425
|
}
|
|
419
426
|
// Annotate the CommonJS export names for ESM import in node:
|
|
420
427
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/react/client/index.ts","../../../src/react/client/ThemeProvider.tsx","../../../src/tokens/colors.ts","../../../src/behaviors/themeManager.ts","../../../src/recipes/cx.ts","../../../src/react/client/ThemeToggle.tsx","../../../src/react/client/CopyButton.tsx","../../../src/behaviors/clipboard.ts","../../../src/recipes/article.ts","../../../src/react/client/TableOfContents.tsx","../../../src/react/client/hooks.ts","../../../src/behaviors/readingProgress.ts","../../../src/behaviors/scrollSpy.ts","../../../src/react/client/ReadingProgress.tsx"],"sourcesContent":["/**\n * @quiet-tech/ui/react/client — Client Components.\n * The build prepends 'use client' to this entry; import from here only what\n * needs interactivity and compose into Server Components via slots.\n */\nexport * from './ThemeProvider';\nexport * from './ThemeToggle';\nexport * from './CopyButton';\nexport * from './TableOfContents';\nexport * from './ReadingProgress';\nexport * from './hooks';\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n createThemeManager,\n type ThemeManager,\n type ThemeState,\n} from '../../behaviors/themeManager';\nimport {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n type AccentName,\n type ThemeMode,\n} from '../../tokens/colors';\n\nexport interface ThemeContextValue {\n mode: ThemeMode;\n accent: AccentName;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key; null disables persistence. */\n storageKey?: string | null;\n}\n\n/**\n * Wraps the app and drives data-theme/data-accent on <html> via the\n * framework-agnostic theme manager. For zero-flash SSR, also render the\n * attributes on <html> in your root layout:\n * <html data-theme=\"dark\" data-accent=\"cyan\" suppressHydrationWarning>\n */\nexport function ThemeProvider({\n children,\n defaultMode = DEFAULT_MODE,\n defaultAccent = DEFAULT_ACCENT,\n storageKey,\n}: ThemeProviderProps) {\n const managerRef = useRef<ThemeManager | null>(null);\n const [state, setState] = useState<ThemeState>({ mode: defaultMode, accent: defaultAccent });\n\n useEffect(() => {\n const manager = createThemeManager({ defaultMode, defaultAccent, storageKey });\n managerRef.current = manager;\n setState(manager.getState());\n const unsubscribe = manager.subscribe(setState);\n return () => {\n unsubscribe();\n manager.destroy();\n managerRef.current = null;\n };\n // Recreating the manager on default changes would clobber user choice.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const value = useMemo<ThemeContextValue>(\n () => ({\n mode: state.mode,\n accent: state.accent,\n setMode: (mode) => managerRef.current?.setMode(mode),\n setAccent: (accent) => managerRef.current?.setAccent(accent),\n toggleMode: () => managerRef.current?.toggleMode(),\n }),\n [state],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error('useTheme must be used within ThemeProvider');\n return ctx;\n}\n","/**\n * Quiet Tech color tokens.\n * Values ported literally from the Quiet Tech spec (blog.kalleopinheiro.dev).\n * Do not round or \"approximate\" — fidelity rule.\n */\nexport const colors = {\n dark: {\n bg: '#0A0A0C',\n bgElev: '#111114',\n surface: '#16161B',\n surface2: '#1C1C22',\n border: 'rgba(255,255,255,0.08)',\n borderStrong: 'rgba(255,255,255,0.14)',\n text: '#EDEDF0',\n text2: '#8B8B96',\n // Corrected from #5A5A66 (~2.6:1 on surface) to meet WCAG AA 4.5:1 — text3 is used for\n // real copy (metadata, TOC links), not decoration, so it must be readable, not just muted.\n text3: '#83838F',\n },\n light: {\n bg: '#F7F7F5',\n bgElev: '#FFFFFF',\n surface: '#FFFFFF',\n surface2: '#F2F2EF',\n border: 'rgba(0,0,0,0.08)',\n borderStrong: 'rgba(0,0,0,0.14)',\n text: '#16161B',\n text2: '#5A5A66',\n // Corrected from #8B8B96 (~3.1:1 on white) to meet WCAG AA 4.5:1, same reasoning as dark.\n text3: '#6F6F78',\n },\n} as const;\n\nexport const accents = {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n} as const;\n\nexport type ThemeMode = keyof typeof colors;\nexport type AccentName = keyof typeof accents;\nexport type ColorScheme = (typeof colors)[ThemeMode];\n\nexport const themeModes = Object.keys(colors) as ThemeMode[];\nexport const accentNames = Object.keys(accents) as AccentName[];\n\nexport const DEFAULT_MODE: ThemeMode = 'dark';\nexport const DEFAULT_ACCENT: AccentName = 'cyan';\n","import {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n accentNames,\n themeModes,\n type AccentName,\n type ThemeMode,\n} from '../tokens/colors';\n\nexport interface ThemeState {\n mode: ThemeMode;\n accent: AccentName;\n}\n\nexport interface ThemeManagerOptions {\n /** Element receiving data-theme / data-accent. Defaults to <html>. */\n root?: HTMLElement;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key. Pass null to disable persistence. */\n storageKey?: string | null;\n}\n\nexport interface ThemeManager {\n getState: () => ThemeState;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n subscribe: (listener: (state: ThemeState) => void) => () => void;\n destroy: () => void;\n}\n\nconst DEFAULT_STORAGE_KEY = 'quiet-tech-theme';\n\nfunction isMode(value: unknown): value is ThemeMode {\n return themeModes.includes(value as ThemeMode);\n}\n\nfunction isAccent(value: unknown): value is AccentName {\n return accentNames.includes(value as AccentName);\n}\n\nfunction readStorage(key: string): Partial<ThemeState> {\n try {\n const raw = window.localStorage.getItem(key);\n if (!raw) return {};\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return {};\n const { mode, accent } = parsed as Record<string, unknown>;\n return {\n ...(isMode(mode) ? { mode } : {}),\n ...(isAccent(accent) ? { accent } : {}),\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Framework-agnostic theme controller. Applies `data-theme` and `data-accent`\n * attributes; theme.css does the rest via CSS vars. If the server already\n * rendered the attributes (RSC/SSR), those win over defaults, so there is\n * no flash of wrong theme.\n */\nexport function createThemeManager(options: ThemeManagerOptions = {}): ThemeManager {\n const root = options.root ?? document.documentElement;\n const storageKey = options.storageKey === null ? null : (options.storageKey ?? DEFAULT_STORAGE_KEY);\n\n const ssrMode = root.getAttribute('data-theme');\n const ssrAccent = root.getAttribute('data-accent');\n const stored = storageKey ? readStorage(storageKey) : {};\n\n let state: ThemeState = {\n mode: stored.mode ?? (isMode(ssrMode) ? ssrMode : (options.defaultMode ?? DEFAULT_MODE)),\n accent:\n stored.accent ?? (isAccent(ssrAccent) ? ssrAccent : (options.defaultAccent ?? DEFAULT_ACCENT)),\n };\n\n const listeners = new Set<(state: ThemeState) => void>();\n\n function apply(): void {\n root.setAttribute('data-theme', state.mode);\n root.setAttribute('data-accent', state.accent);\n if (storageKey) {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(state));\n } catch {\n // storage unavailable (private mode, quota) — theme still applies\n }\n }\n for (const listener of listeners) listener(state);\n }\n\n apply();\n\n return {\n getState: () => state,\n setMode(mode) {\n state = { ...state, mode };\n apply();\n },\n setAccent(accent) {\n state = { ...state, accent };\n apply();\n },\n toggleMode() {\n state = { ...state, mode: state.mode === 'dark' ? 'light' : 'dark' };\n apply();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n destroy() {\n listeners.clear();\n },\n };\n}\n","/** Minimal class-name joiner. Falsy values are dropped. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { useTheme } from './ThemeProvider';\n\nexport interface ThemeToggleProps extends ComponentPropsWithoutRef<'button'> {}\n\n/** Dark/light toggle. Compose into <Header actions={...} />. */\nexport function ThemeToggle({ className, ...rest }: ThemeToggleProps) {\n const { mode, toggleMode } = useTheme();\n const next = mode === 'dark' ? 'light' : 'dark';\n return (\n <button\n type=\"button\"\n onClick={toggleMode}\n className={cx('qt-header__link', className)}\n aria-label={`Switch to ${next} theme`}\n {...rest}\n >\n {mode === 'dark' ? 'Light' : 'Dark'}\n </button>\n );\n}\n","import { useEffect, useRef, useState, type ComponentPropsWithoutRef } from 'react';\nimport { copyToClipboard } from '../../behaviors/clipboard';\nimport { codeBlockClasses } from '../../recipes/article';\nimport { cx } from '../../recipes/cx';\n\nconst COPIED_FEEDBACK_MS = 2000;\n\nexport interface CopyButtonProps extends ComponentPropsWithoutRef<'button'> {\n /** Text copied to the clipboard. */\n code: string;\n label?: string;\n copiedLabel?: string;\n}\n\n/** Copy-to-clipboard button for <CodeBlock actions={...} />. */\nexport function CopyButton({\n code,\n label = 'Copy',\n copiedLabel = 'Copied',\n className,\n ...rest\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (timerRef.current) clearTimeout(timerRef.current);\n },\n [],\n );\n\n async function handleCopy(): Promise<void> {\n const ok = await copyToClipboard(code);\n if (!ok) return;\n setCopied(true);\n if (timerRef.current) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => setCopied(false), COPIED_FEEDBACK_MS);\n }\n\n return (\n <button\n type=\"button\"\n onClick={handleCopy}\n className={cx(copied ? codeBlockClasses.copyCopied : codeBlockClasses.copy, className)}\n aria-live=\"polite\"\n {...rest}\n >\n {copied ? copiedLabel : label}\n </button>\n );\n}\n","/** Copy text to the clipboard. Returns false when the Clipboard API is unavailable or denied. */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) return false;\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n","import { cx } from './cx';\n\n/**\n * Article recipes: CodeBlock, Callout, TableOfContents, ReadingProgress,\n * ArticleHeader, Prose. Pure functions — Server Component safe.\n */\n\nexport function codeBlock(): string {\n return 'qt-code-block';\n}\n\nexport const codeBlockClasses = {\n header: 'qt-code-block__header',\n pre: 'qt-code-block__pre',\n copy: 'qt-code-block__copy',\n copyCopied: cx('qt-code-block__copy', 'qt-code-block__copy--copied'),\n} as const;\n\nexport type CalloutKind = 'note' | 'warn' | 'aha';\n\nexport function callout(kind: CalloutKind): string {\n return cx('qt-callout', `qt-callout--${kind}`);\n}\n\nexport const calloutClasses = {\n label: 'qt-callout__label',\n} as const;\n\nexport const calloutLabels: Record<CalloutKind, string> = {\n note: 'Note',\n warn: 'Warn',\n aha: 'Aha!',\n};\n\nexport function tableOfContents(): string {\n return 'qt-toc';\n}\n\nexport interface TocLinkOptions {\n active?: boolean;\n /** Heading depth, 2 (h2) or 3 (h3). Depth 3 indents. */\n depth?: 2 | 3;\n}\n\nexport function tocLink(options: TocLinkOptions = {}): string {\n return cx(\n 'qt-toc__link',\n options.active && 'qt-toc__link--active',\n options.depth === 3 && 'qt-toc__link--depth-3',\n );\n}\n\nexport function readingProgress(): string {\n return 'qt-reading-progress';\n}\n\nexport const readingProgressClasses = {\n bar: 'qt-reading-progress__bar',\n} as const;\n\n/** CSS var read by `.qt-reading-progress__bar` (0 → 1). */\nexport const READING_PROGRESS_VAR = '--qt-reading-progress';\n\nexport function articleHeader(): string {\n return 'qt-article-header';\n}\n\nexport const articleHeaderClasses = {\n title: 'qt-article-header__title',\n meta: 'qt-article-header__meta',\n author: 'qt-article-header__author',\n} as const;\n\nexport function prose(): string {\n return 'qt-prose';\n}\n\nexport const proseClasses = {\n lead: 'qt-prose__lead',\n} as const;\n","import { useMemo, type ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { tableOfContents, tocLink } from '../../recipes/article';\nimport type { TocItem } from '../../types';\nimport { useScrollSpy } from './hooks';\n\nexport interface TableOfContentsProps extends ComponentPropsWithoutRef<'nav'> {\n items: TocItem[];\n /** IntersectionObserver rootMargin override. */\n rootMargin?: string;\n}\n\n/** Article table of contents with scroll-spy active state. */\nexport function TableOfContents({ items, rootMargin, className, ...rest }: TableOfContentsProps) {\n const ids = useMemo(() => items.map((item) => item.id), [items]);\n const activeId = useScrollSpy(ids, rootMargin);\n\n return (\n <nav className={cx(tableOfContents(), className)} aria-label=\"Table of contents\" {...rest}>\n {items.map((item) => (\n <a\n key={item.id}\n href={`#${item.id}`}\n className={tocLink({ active: item.id === activeId, depth: item.depth })}\n aria-current={item.id === activeId ? 'true' : undefined}\n >\n {item.label}\n </a>\n ))}\n </nav>\n );\n}\n","import { useEffect, useState } from 'react';\nimport { createReadingProgress } from '../../behaviors/readingProgress';\nimport { createScrollSpy } from '../../behaviors/scrollSpy';\n\n/** Reports which heading id is currently active while scrolling. */\nexport function useScrollSpy(ids: readonly string[], rootMargin?: string): string | null {\n const [activeId, setActiveId] = useState<string | null>(null);\n const key = ids.join('|');\n\n useEffect(() => {\n const spy = createScrollSpy(ids, { onChange: setActiveId, rootMargin });\n return () => spy.destroy();\n // `key` captures ids content; the array identity itself may change per render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key, rootMargin]);\n\n return activeId;\n}\n\n/** Reading progress of the page (or target element), in [0, 1]. */\nexport function useReadingProgress(target?: HTMLElement | null): number {\n const [percent, setPercent] = useState(0);\n\n useEffect(() => {\n const progress = createReadingProgress({\n target: target ?? undefined,\n onChange: setPercent,\n });\n return () => progress.destroy();\n }, [target]);\n\n return percent;\n}\n","import { READING_PROGRESS_VAR } from '../recipes/article';\n\nexport interface ReadingProgressOptions {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement;\n /** Receives progress in [0, 1]. */\n onChange?: (percent: number) => void;\n /** Element that receives the CSS var (default: <html>). Pass null to skip. */\n varTarget?: HTMLElement | null;\n}\n\nexport interface ReadingProgress {\n getPercent: () => number;\n destroy: () => void;\n}\n\n/**\n * Tracks document (or element) reading progress. Writes the\n * `--qt-reading-progress` CSS var consumed by `.qt-reading-progress__bar`.\n */\nexport function createReadingProgress(options: ReadingProgressOptions = {}): ReadingProgress {\n const varTarget =\n options.varTarget === null ? null : (options.varTarget ?? document.documentElement);\n let percent = 0;\n\n function measure(): number {\n if (options.target) {\n const rect = options.target.getBoundingClientRect();\n const viewport = window.innerHeight;\n const total = rect.height - viewport;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, -rect.top / total));\n }\n const doc = document.documentElement;\n const total = doc.scrollHeight - window.innerHeight;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, window.scrollY / total));\n }\n\n function update(): void {\n percent = measure();\n varTarget?.style.setProperty(READING_PROGRESS_VAR, String(percent));\n options.onChange?.(percent);\n }\n\n update();\n window.addEventListener('scroll', update, { passive: true });\n window.addEventListener('resize', update, { passive: true });\n\n return {\n getPercent: () => percent,\n destroy() {\n window.removeEventListener('scroll', update);\n window.removeEventListener('resize', update);\n },\n };\n}\n","export interface ScrollSpyOptions {\n /** Called whenever the active heading changes. `null` when none is visible. */\n onChange: (activeId: string | null) => void;\n /** Forwarded to IntersectionObserver. Default biases toward the reading line. */\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport interface ScrollSpy {\n destroy: () => void;\n}\n\n/**\n * Watches headings by id and reports which one is active.\n * Framework-agnostic core used by the React TableOfContents.\n */\nexport function createScrollSpy(ids: readonly string[], options: ScrollSpyOptions): ScrollSpy {\n const visible = new Map<string, number>();\n\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n visible.set(entry.target.id, entry.intersectionRatio);\n } else {\n visible.delete(entry.target.id);\n }\n }\n // First visible id in document order wins.\n const active = ids.find((id) => visible.has(id)) ?? null;\n options.onChange(active);\n },\n {\n rootMargin: options.rootMargin ?? '0px 0px -70% 0px',\n threshold: options.threshold ?? 0,\n },\n );\n\n for (const id of ids) {\n const el = document.getElementById(id);\n if (el) observer.observe(el);\n }\n\n return {\n destroy: () => observer.disconnect(),\n };\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { readingProgress, readingProgressClasses } from '../../recipes/article';\nimport { useReadingProgress } from './hooks';\n\nexport interface ReadingProgressProps extends ComponentPropsWithoutRef<'div'> {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement | null;\n}\n\n/** Fixed top progress bar. Motion is linear by spec. */\nexport function ReadingProgress({ target, className, ...rest }: ReadingProgressProps) {\n const percent = useReadingProgress(target);\n return (\n <div\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(percent * 100)}\n aria-label=\"Reading progress\"\n className={cx(readingProgress(), className)}\n {...rest}\n >\n <div\n className={readingProgressClasses.bar}\n style={{ transform: `scaleX(${percent})` }}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;;;ACHA,IAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA,IAGP,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,IAEP,OAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AACT;AAMO,IAAM,aAAa,OAAO,KAAK,MAAM;AACrC,IAAM,cAAc,OAAO,KAAK,OAAO;AAEvC,IAAM,eAA0B;AAChC,IAAM,iBAA6B;;;AChB1C,IAAM,sBAAsB;AAE5B,SAAS,OAAO,OAAoC;AAClD,SAAO,WAAW,SAAS,KAAkB;AAC/C;AAEA,SAAS,SAAS,OAAqC;AACrD,SAAO,YAAY,SAAS,KAAmB;AACjD;AAEA,SAAS,YAAY,KAAkC;AACrD,MAAI;AACF,UAAM,MAAM,OAAO,aAAa,QAAQ,GAAG;AAC3C,QAAI,CAAC,IAAK,QAAO,CAAC;AAClB,UAAM,SAAkB,KAAK,MAAM,GAAG;AACtC,QAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO,CAAC;AAC3D,UAAM,EAAE,M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C,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,uBAAuB;AAAA,UAClC,OAAO,EAAE,WAAW,UAAU,OAAO,IAAI;AAAA;AAAA,MAC3C;AAAA;AAAA,EACF;AAEJ;","names":["import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_react","total","import_jsx_runtime","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/react/client/index.ts","../../../src/react/client/ThemeProvider.tsx","../../../src/tokens/colors.ts","../../../src/behaviors/themeManager.ts","../../../src/recipes/cx.ts","../../../src/react/client/ThemeToggle.tsx","../../../src/react/client/CopyButton.tsx","../../../src/behaviors/clipboard.ts","../../../src/recipes/article.ts","../../../src/react/client/TableOfContents.tsx","../../../src/react/client/hooks.ts","../../../src/behaviors/readingProgress.ts","../../../src/behaviors/scrollSpy.ts","../../../src/react/client/ReadingProgress.tsx"],"sourcesContent":["/**\n * @still-void/ui/react/client — Client Components.\n * The build prepends 'use client' to this entry; import from here only what\n * needs interactivity and compose into Server Components via slots.\n */\nexport * from './ThemeProvider';\nexport * from './ThemeToggle';\nexport * from './CopyButton';\nexport * from './TableOfContents';\nexport * from './ReadingProgress';\nexport * from './hooks';\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n createThemeManager,\n type ThemeManager,\n type ThemeState,\n} from '../../behaviors/themeManager';\nimport {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n type AccentName,\n type ThemeMode,\n} from '../../tokens/colors';\n\nexport interface ThemeContextValue {\n mode: ThemeMode;\n accent: AccentName;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | null>(null);\n\nexport interface ThemeProviderProps {\n children: ReactNode;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key; null disables persistence. */\n storageKey?: string | null;\n}\n\n/**\n * Wraps the app and drives data-theme/data-accent on <html> via the\n * framework-agnostic theme manager. For zero-flash SSR, also render the\n * attributes on <html> in your root layout:\n * <html data-theme=\"dark\" data-accent=\"cyan\" suppressHydrationWarning>\n */\nexport function ThemeProvider({\n children,\n defaultMode = DEFAULT_MODE,\n defaultAccent = DEFAULT_ACCENT,\n storageKey,\n}: ThemeProviderProps) {\n const managerRef = useRef<ThemeManager | null>(null);\n const [state, setState] = useState<ThemeState>({ mode: defaultMode, accent: defaultAccent });\n\n useEffect(() => {\n const manager = createThemeManager({ defaultMode, defaultAccent, storageKey });\n managerRef.current = manager;\n setState(manager.getState());\n const unsubscribe = manager.subscribe(setState);\n return () => {\n unsubscribe();\n manager.destroy();\n managerRef.current = null;\n };\n // Recreating the manager on default changes would clobber user choice.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const value = useMemo<ThemeContextValue>(\n () => ({\n mode: state.mode,\n accent: state.accent,\n setMode: (mode) => managerRef.current?.setMode(mode),\n setAccent: (accent) => managerRef.current?.setAccent(accent),\n toggleMode: () => managerRef.current?.toggleMode(),\n }),\n [state],\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\nexport function useTheme(): ThemeContextValue {\n const ctx = useContext(ThemeContext);\n if (!ctx) throw new Error('useTheme must be used within ThemeProvider');\n return ctx;\n}\n","/**\n * Still Void color tokens.\n * Values ported literally from the Still Void spec (blog.kalleopinheiro.dev).\n * Do not round or \"approximate\" — fidelity rule.\n */\nexport const colors = {\n dark: {\n bg: '#0A0A0C',\n bgElev: '#111114',\n surface: '#16161B',\n surface2: '#1C1C22',\n border: 'rgba(255,255,255,0.08)',\n borderStrong: 'rgba(255,255,255,0.14)',\n text: '#EDEDF0',\n text2: '#8B8B96',\n // Corrected from #5A5A66 (~2.6:1 on surface) to meet WCAG AA 4.5:1 — text3 is used for\n // real copy (metadata, TOC links), not decoration, so it must be readable, not just muted.\n text3: '#83838F',\n },\n light: {\n bg: '#F7F7F5',\n bgElev: '#FFFFFF',\n surface: '#FFFFFF',\n surface2: '#F2F2EF',\n border: 'rgba(0,0,0,0.08)',\n borderStrong: 'rgba(0,0,0,0.14)',\n text: '#16161B',\n text2: '#5A5A66',\n // Corrected from #8B8B96 (~3.1:1 on white) to meet WCAG AA 4.5:1, same reasoning as dark.\n // A further step from #6F6F78 to #6D6D76: the first fix cleared white/paper (≥4.7:1) but\n // was only ~4.44:1 against surface2 (#F2F2EF), the darkest of the light surfaces — still a\n // failure. Verified against bg/bgElev/surface/surface2 together, not just one background.\n text3: '#6D6D76',\n },\n} as const;\n\nexport const accents = {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n} as const;\n\n/**\n * Text/UI-safe accent variants (\"ink\"). `accents` above is tuned for surface use\n * (dots, gradient border, progress bar) and fails WCAG AA as text on light\n * backgrounds (e.g. cyan is ~1.8:1 on white). These preserve the dark-mode\n * values (already ≥6.9:1) and darken each hue for light mode to clear 4.5:1\n * against both light surfaces. Used anywhere the accent colors text: prose\n * links, active TOC state, callout labels, hero eyebrow, copy-success, focus ring.\n */\nexport const accentsInk = {\n dark: {\n cyan: 'oklch(0.78 0.12 210)',\n violet: 'oklch(0.72 0.14 295)',\n mint: 'oklch(0.78 0.10 160)',\n amber: 'oklch(0.78 0.12 75)',\n },\n light: {\n cyan: 'oklch(0.525 0.09 210)',\n violet: 'oklch(0.545 0.14 295)',\n mint: 'oklch(0.52 0.1 160)',\n amber: 'oklch(0.535 0.11 75)',\n },\n} as const;\n\n/**\n * Semantic state colors — independent of the switchable `accent`, so a\n * consumer picking `data-accent=\"amber\"` never collides a warning with the\n * site accent. Fixed per meaning in both surface and text/UI (\"ink\") forms,\n * same split as `accents`/`accentsInk`.\n */\nexport const semantic = {\n dark: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n light: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n} as const;\n\nexport const semanticInk = {\n dark: {\n danger: 'oklch(0.68 0.19 25)',\n success: 'oklch(0.75 0.15 150)',\n info: 'oklch(0.78 0.12 210)',\n warning: 'oklch(0.78 0.12 75)',\n },\n light: {\n danger: 'oklch(0.555 0.19 25)',\n success: 'oklch(0.515 0.14 150)',\n info: 'oklch(0.525 0.09 210)',\n warning: 'oklch(0.535 0.11 75)',\n },\n} as const;\n\nexport type ThemeMode = keyof typeof colors;\nexport type AccentName = keyof typeof accents;\nexport type ColorScheme = (typeof colors)[ThemeMode];\nexport type SemanticName = keyof (typeof semantic)['dark'];\n\nexport const themeModes = Object.keys(colors) as ThemeMode[];\nexport const accentNames = Object.keys(accents) as AccentName[];\n\nexport const DEFAULT_MODE: ThemeMode = 'dark';\nexport const DEFAULT_ACCENT: AccentName = 'cyan';\n","import {\n DEFAULT_ACCENT,\n DEFAULT_MODE,\n accentNames,\n themeModes,\n type AccentName,\n type ThemeMode,\n} from '../tokens/colors';\n\nexport interface ThemeState {\n mode: ThemeMode;\n accent: AccentName;\n}\n\nexport interface ThemeManagerOptions {\n /** Element receiving data-theme / data-accent. Defaults to <html>. */\n root?: HTMLElement;\n defaultMode?: ThemeMode;\n defaultAccent?: AccentName;\n /** localStorage key. Pass null to disable persistence. */\n storageKey?: string | null;\n}\n\nexport interface ThemeManager {\n getState: () => ThemeState;\n setMode: (mode: ThemeMode) => void;\n setAccent: (accent: AccentName) => void;\n toggleMode: () => void;\n subscribe: (listener: (state: ThemeState) => void) => () => void;\n destroy: () => void;\n}\n\nexport const DEFAULT_STORAGE_KEY = 'still-void-theme';\n\nfunction isMode(value: unknown): value is ThemeMode {\n return themeModes.includes(value as ThemeMode);\n}\n\nfunction isAccent(value: unknown): value is AccentName {\n return accentNames.includes(value as AccentName);\n}\n\nfunction readStorage(key: string): Partial<ThemeState> {\n try {\n const raw = window.localStorage.getItem(key);\n if (!raw) return {};\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) return {};\n const { mode, accent } = parsed as Record<string, unknown>;\n return {\n ...(isMode(mode) ? { mode } : {}),\n ...(isAccent(accent) ? { accent } : {}),\n };\n } catch {\n return {};\n }\n}\n\n/**\n * Framework-agnostic theme controller. Applies `data-theme` and `data-accent`\n * attributes; theme.css does the rest via CSS vars. If the server already\n * rendered the attributes (RSC/SSR), those win over defaults, so there is\n * no flash of wrong theme.\n */\nexport function createThemeManager(options: ThemeManagerOptions = {}): ThemeManager {\n const root = options.root ?? document.documentElement;\n const storageKey = options.storageKey === null ? null : (options.storageKey ?? DEFAULT_STORAGE_KEY);\n\n const ssrMode = root.getAttribute('data-theme');\n const ssrAccent = root.getAttribute('data-accent');\n const stored = storageKey ? readStorage(storageKey) : {};\n\n let state: ThemeState = {\n mode: stored.mode ?? (isMode(ssrMode) ? ssrMode : (options.defaultMode ?? DEFAULT_MODE)),\n accent:\n stored.accent ?? (isAccent(ssrAccent) ? ssrAccent : (options.defaultAccent ?? DEFAULT_ACCENT)),\n };\n\n const listeners = new Set<(state: ThemeState) => void>();\n\n function apply(): void {\n root.setAttribute('data-theme', state.mode);\n root.setAttribute('data-accent', state.accent);\n if (storageKey) {\n try {\n window.localStorage.setItem(storageKey, JSON.stringify(state));\n } catch {\n // storage unavailable (private mode, quota) — theme still applies\n }\n }\n for (const listener of listeners) listener(state);\n }\n\n apply();\n\n return {\n getState: () => state,\n setMode(mode) {\n state = { ...state, mode };\n apply();\n },\n setAccent(accent) {\n state = { ...state, accent };\n apply();\n },\n toggleMode() {\n state = { ...state, mode: state.mode === 'dark' ? 'light' : 'dark' };\n apply();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n destroy() {\n listeners.clear();\n },\n };\n}\n","/** Minimal class-name joiner. Falsy values are dropped. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { useTheme } from './ThemeProvider';\n\nexport interface ThemeToggleProps extends ComponentPropsWithoutRef<'button'> {}\n\n/** Dark/light toggle. Compose into <Header actions={...} />. */\nexport function ThemeToggle({ className, ...rest }: ThemeToggleProps) {\n const { mode, toggleMode } = useTheme();\n const next = mode === 'dark' ? 'light' : 'dark';\n return (\n <button\n type=\"button\"\n onClick={toggleMode}\n className={cx('sv-header__link', className)}\n aria-label={`Switch to ${next} theme`}\n {...rest}\n >\n {mode === 'dark' ? 'Light' : 'Dark'}\n </button>\n );\n}\n","import { useEffect, useRef, useState, type ComponentPropsWithoutRef } from 'react';\nimport { copyToClipboard } from '../../behaviors/clipboard';\nimport { codeBlockClasses } from '../../recipes/article';\nimport { cx } from '../../recipes/cx';\n\nconst COPIED_FEEDBACK_MS = 2000;\n\nexport interface CopyButtonProps extends ComponentPropsWithoutRef<'button'> {\n /** Text copied to the clipboard. */\n code: string;\n label?: string;\n copiedLabel?: string;\n}\n\n/** Copy-to-clipboard button for <CodeBlock actions={...} />. */\nexport function CopyButton({\n code,\n label = 'Copy',\n copiedLabel = 'Copied',\n className,\n ...rest\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (timerRef.current) clearTimeout(timerRef.current);\n },\n [],\n );\n\n async function handleCopy(): Promise<void> {\n const ok = await copyToClipboard(code);\n if (!ok) return;\n setCopied(true);\n if (timerRef.current) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => setCopied(false), COPIED_FEEDBACK_MS);\n }\n\n return (\n <button\n type=\"button\"\n onClick={handleCopy}\n className={cx(copied ? codeBlockClasses.copyCopied : codeBlockClasses.copy, className)}\n aria-live=\"polite\"\n {...rest}\n >\n {copied ? copiedLabel : label}\n </button>\n );\n}\n","/** Copy text to the clipboard. Returns false when the Clipboard API is unavailable or denied. */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n if (!navigator.clipboard?.writeText) return false;\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n return false;\n }\n}\n","import { cx } from './cx';\n\n/**\n * Article recipes: CodeBlock, Callout, TableOfContents, ReadingProgress,\n * ArticleHeader, Prose. Pure functions — Server Component safe.\n */\n\nexport function codeBlock(): string {\n return 'sv-code-block';\n}\n\nexport const codeBlockClasses = {\n header: 'sv-code-block__header',\n pre: 'sv-code-block__pre',\n copy: 'sv-code-block__copy',\n copyCopied: cx('sv-code-block__copy', 'sv-code-block__copy--copied'),\n} as const;\n\nexport type CalloutKind = 'note' | 'warn' | 'aha';\n\nexport function callout(kind: CalloutKind): string {\n return cx('sv-callout', `sv-callout--${kind}`);\n}\n\nexport const calloutClasses = {\n label: 'sv-callout__label',\n} as const;\n\nexport const calloutLabels: Record<CalloutKind, string> = {\n note: 'Note',\n warn: 'Warn',\n aha: 'Aha!',\n};\n\nexport function tableOfContents(): string {\n return 'sv-toc';\n}\n\nexport interface TocLinkOptions {\n active?: boolean;\n /** Heading depth, 2 (h2) or 3 (h3). Depth 3 indents. */\n depth?: 2 | 3;\n}\n\nexport function tocLink(options: TocLinkOptions = {}): string {\n return cx(\n 'sv-toc__link',\n options.active && 'sv-toc__link--active',\n options.depth === 3 && 'sv-toc__link--depth-3',\n );\n}\n\nexport function readingProgress(): string {\n return 'sv-reading-progress';\n}\n\nexport const readingProgressClasses = {\n bar: 'sv-reading-progress__bar',\n} as const;\n\n/** CSS var read by `.sv-reading-progress__bar` (0 → 1). */\nexport const READING_PROGRESS_VAR = '--sv-reading-progress';\n\nexport function articleHeader(): string {\n return 'sv-article-header';\n}\n\nexport const articleHeaderClasses = {\n title: 'sv-article-header__title',\n meta: 'sv-article-header__meta',\n author: 'sv-article-header__author',\n} as const;\n\nexport function prose(): string {\n return 'sv-prose';\n}\n\nexport const proseClasses = {\n lead: 'sv-prose__lead',\n} as const;\n","import { useMemo, type ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { tableOfContents, tocLink } from '../../recipes/article';\nimport type { TocItem } from '../../types';\nimport { useScrollSpy } from './hooks';\n\nexport interface TableOfContentsProps extends ComponentPropsWithoutRef<'nav'> {\n items: TocItem[];\n /** IntersectionObserver rootMargin override. */\n rootMargin?: string;\n}\n\n/** Article table of contents with scroll-spy active state. */\nexport function TableOfContents({ items, rootMargin, className, ...rest }: TableOfContentsProps) {\n const ids = useMemo(() => items.map((item) => item.id), [items]);\n const activeId = useScrollSpy(ids, rootMargin);\n\n return (\n <nav className={cx(tableOfContents(), className)} aria-label=\"Table of contents\" {...rest}>\n {items.map((item) => (\n <a\n key={item.id}\n href={`#${item.id}`}\n className={tocLink({ active: item.id === activeId, depth: item.depth })}\n aria-current={item.id === activeId ? 'true' : undefined}\n >\n {item.label}\n </a>\n ))}\n </nav>\n );\n}\n","import { useEffect, useState } from 'react';\nimport { createReadingProgress } from '../../behaviors/readingProgress';\nimport { createScrollSpy } from '../../behaviors/scrollSpy';\n\n/** Reports which heading id is currently active while scrolling. */\nexport function useScrollSpy(ids: readonly string[], rootMargin?: string): string | null {\n const [activeId, setActiveId] = useState<string | null>(null);\n const key = ids.join('|');\n\n useEffect(() => {\n const spy = createScrollSpy(ids, { onChange: setActiveId, rootMargin });\n return () => spy.destroy();\n // `key` captures ids content; the array identity itself may change per render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key, rootMargin]);\n\n return activeId;\n}\n\n/**\n * Reading progress of the page (or target element), in [0, 1].\n *\n * The visual bar is driven by the `--sv-reading-progress` CSS var (written on\n * every rAF-throttled scroll tick regardless of this hook), so React state\n * only needs to update when the *reported* value's bucket changes — not on\n * every scroll frame. `step` sets the bucket size; the default (1, i.e. only\n * the 0 and 1 buckets) keeps re-renders to a couple per page for consumers\n * that don't need the numeric value, while `announce` on `<ReadingProgress>`\n * passes 0.1 for a coarse 10%-step live value.\n */\nexport function useReadingProgress(target?: HTMLElement | null, step = 1): number {\n const [percent, setPercent] = useState(0);\n\n useEffect(() => {\n const progress = createReadingProgress({\n target: target ?? undefined,\n onChange: (value) => {\n const bucket = step > 0 ? Math.round(value / step) * step : value;\n setPercent((prev) => (prev === bucket ? prev : bucket));\n },\n });\n return () => progress.destroy();\n }, [target, step]);\n\n return percent;\n}\n","import { READING_PROGRESS_VAR } from '../recipes/article';\n\n// jsdom (used in tests) doesn't implement requestAnimationFrame; fall back to\n// a timer so the throttling logic stays testable outside a real browser.\nconst raf: (cb: () => void) => number =\n typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function'\n ? (cb) => window.requestAnimationFrame(cb)\n : (cb) => setTimeout(cb, 16) as unknown as number;\nconst cancelRaf: (id: number) => void =\n typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function'\n ? (id) => window.cancelAnimationFrame(id)\n : (id) => clearTimeout(id as unknown as ReturnType<typeof setTimeout>);\n\nexport interface ReadingProgressOptions {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement;\n /** Receives progress in [0, 1]. */\n onChange?: (percent: number) => void;\n /** Element that receives the CSS var (default: <html>). Pass null to skip. */\n varTarget?: HTMLElement | null;\n}\n\nexport interface ReadingProgress {\n getPercent: () => number;\n destroy: () => void;\n}\n\n/**\n * Tracks document (or element) reading progress. Writes the\n * `--sv-reading-progress` CSS var consumed by `.sv-reading-progress__bar`.\n */\nexport function createReadingProgress(options: ReadingProgressOptions = {}): ReadingProgress {\n const varTarget =\n options.varTarget === null ? null : (options.varTarget ?? document.documentElement);\n let percent = 0;\n\n function measure(): number {\n if (options.target) {\n const rect = options.target.getBoundingClientRect();\n const viewport = window.innerHeight;\n const total = rect.height - viewport;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, -rect.top / total));\n }\n const doc = document.documentElement;\n const total = doc.scrollHeight - window.innerHeight;\n if (total <= 0) return 1;\n return Math.min(1, Math.max(0, window.scrollY / total));\n }\n\n function update(): void {\n percent = measure();\n varTarget?.style.setProperty(READING_PROGRESS_VAR, String(percent));\n options.onChange?.(percent);\n }\n\n // Coalesce scroll/resize bursts into one measurement per animation frame —\n // without this, `measure()` (a forced layout read) runs once per event.\n let frame: number | null = null;\n function onFrame(): void {\n frame = null;\n update();\n }\n function schedule(): void {\n if (frame !== null) return;\n frame = raf(onFrame);\n }\n\n update();\n window.addEventListener('scroll', schedule, { passive: true });\n window.addEventListener('resize', schedule, { passive: true });\n\n return {\n getPercent: () => percent,\n destroy() {\n window.removeEventListener('scroll', schedule);\n window.removeEventListener('resize', schedule);\n if (frame !== null) cancelRaf(frame);\n },\n };\n}\n","export interface ScrollSpyOptions {\n /** Called whenever the active heading changes. `null` when none is visible. */\n onChange: (activeId: string | null) => void;\n /** Forwarded to IntersectionObserver. Default biases toward the reading line. */\n rootMargin?: string;\n threshold?: number | number[];\n}\n\nexport interface ScrollSpy {\n destroy: () => void;\n}\n\n/**\n * Watches headings by id and reports which one is active.\n * Framework-agnostic core used by the React TableOfContents.\n */\nexport function createScrollSpy(ids: readonly string[], options: ScrollSpyOptions): ScrollSpy {\n const visible = new Map<string, number>();\n\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n visible.set(entry.target.id, entry.intersectionRatio);\n } else {\n visible.delete(entry.target.id);\n }\n }\n // First visible id in document order wins.\n const active = ids.find((id) => visible.has(id)) ?? null;\n options.onChange(active);\n },\n {\n rootMargin: options.rootMargin ?? '0px 0px -70% 0px',\n threshold: options.threshold ?? 0,\n },\n );\n\n for (const id of ids) {\n const el = document.getElementById(id);\n if (el) observer.observe(el);\n }\n\n return {\n destroy: () => observer.disconnect(),\n };\n}\n","import type { ComponentPropsWithoutRef } from 'react';\nimport { cx } from '../../recipes/cx';\nimport { readingProgress, readingProgressClasses } from '../../recipes/article';\nimport { useReadingProgress } from './hooks';\n\nexport interface ReadingProgressProps extends ComponentPropsWithoutRef<'div'> {\n /** Element whose scroll extent defines 100%. Defaults to the document. */\n target?: HTMLElement | null;\n /**\n * Expose progress to assistive tech as a live `role=\"progressbar\"`,\n * updated in coarse 10% steps. Off by default: the bar is a visual aid for\n * a value the user already has (their own scroll position), and a value\n * that changes continuously during scroll would otherwise spam screen\n * readers with `aria-valuenow` updates.\n */\n announce?: boolean;\n}\n\n/**\n * Fixed top progress bar. Motion is linear by spec. The fill is driven by\n * the `--sv-reading-progress` CSS var (see style.css), not React state, so\n * scrolling doesn't re-render this component on every frame.\n */\nexport function ReadingProgress({ target, announce, className, ...rest }: ReadingProgressProps) {\n const percent = useReadingProgress(target, announce ? 0.1 : 1);\n const a11yProps = announce\n ? {\n role: 'progressbar' as const,\n 'aria-valuemin': 0,\n 'aria-valuemax': 100,\n 'aria-valuenow': Math.round(percent * 100),\n 'aria-label': 'Reading progress',\n }\n : { 'aria-hidden': true as const };\n\n return (\n <div className={cx(readingProgress(), className)} {...a11yProps} {...rest}>\n <div className={readingProgressClasses.bar} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;;;ACHA,IAAM,SAAS;AAAA,EACpB,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA,IAGP,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,IAAI;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,OAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU;AA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B,GAAG,SAAS,GAAI,GAAG,WAAY,GAAG,MACnE,uDAAC,SAAI,WAAW,uBAAuB,KAAK,GAC9C;AAEJ;","names":["import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_react","total","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Values ported literally from the
|
|
5
|
+
* Still Void color tokens.
|
|
6
|
+
* Values ported literally from the Still Void spec (blog.kalleopinheiro.dev).
|
|
7
7
|
* Do not round or "approximate" — fidelity rule.
|
|
8
8
|
*/
|
|
9
9
|
declare const colors: {
|
|
@@ -27,7 +27,7 @@ declare const colors: {
|
|
|
27
27
|
readonly borderStrong: "rgba(0,0,0,0.14)";
|
|
28
28
|
readonly text: "#16161B";
|
|
29
29
|
readonly text2: "#5A5A66";
|
|
30
|
-
readonly text3: "#
|
|
30
|
+
readonly text3: "#6D6D76";
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
declare const accents: {
|
|
@@ -93,13 +93,35 @@ declare function TableOfContents({ items, rootMargin, className, ...rest }: Tabl
|
|
|
93
93
|
interface ReadingProgressProps extends ComponentPropsWithoutRef<'div'> {
|
|
94
94
|
/** Element whose scroll extent defines 100%. Defaults to the document. */
|
|
95
95
|
target?: HTMLElement | null;
|
|
96
|
+
/**
|
|
97
|
+
* Expose progress to assistive tech as a live `role="progressbar"`,
|
|
98
|
+
* updated in coarse 10% steps. Off by default: the bar is a visual aid for
|
|
99
|
+
* a value the user already has (their own scroll position), and a value
|
|
100
|
+
* that changes continuously during scroll would otherwise spam screen
|
|
101
|
+
* readers with `aria-valuenow` updates.
|
|
102
|
+
*/
|
|
103
|
+
announce?: boolean;
|
|
96
104
|
}
|
|
97
|
-
/**
|
|
98
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Fixed top progress bar. Motion is linear by spec. The fill is driven by
|
|
107
|
+
* the `--sv-reading-progress` CSS var (see style.css), not React state, so
|
|
108
|
+
* scrolling doesn't re-render this component on every frame.
|
|
109
|
+
*/
|
|
110
|
+
declare function ReadingProgress({ target, announce, className, ...rest }: ReadingProgressProps): react.JSX.Element;
|
|
99
111
|
|
|
100
112
|
/** Reports which heading id is currently active while scrolling. */
|
|
101
113
|
declare function useScrollSpy(ids: readonly string[], rootMargin?: string): string | null;
|
|
102
|
-
/**
|
|
103
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Reading progress of the page (or target element), in [0, 1].
|
|
116
|
+
*
|
|
117
|
+
* The visual bar is driven by the `--sv-reading-progress` CSS var (written on
|
|
118
|
+
* every rAF-throttled scroll tick regardless of this hook), so React state
|
|
119
|
+
* only needs to update when the *reported* value's bucket changes — not on
|
|
120
|
+
* every scroll frame. `step` sets the bucket size; the default (1, i.e. only
|
|
121
|
+
* the 0 and 1 buckets) keeps re-renders to a couple per page for consumers
|
|
122
|
+
* that don't need the numeric value, while `announce` on `<ReadingProgress>`
|
|
123
|
+
* passes 0.1 for a coarse 10%-step live value.
|
|
124
|
+
*/
|
|
125
|
+
declare function useReadingProgress(target?: HTMLElement | null, step?: number): number;
|
|
104
126
|
|
|
105
127
|
export { CopyButton, type CopyButtonProps, ReadingProgress, type ReadingProgressProps, TableOfContents, type TableOfContentsProps, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, useReadingProgress, useScrollSpy, useTheme };
|
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Values ported literally from the
|
|
5
|
+
* Still Void color tokens.
|
|
6
|
+
* Values ported literally from the Still Void spec (blog.kalleopinheiro.dev).
|
|
7
7
|
* Do not round or "approximate" — fidelity rule.
|
|
8
8
|
*/
|
|
9
9
|
declare const colors: {
|
|
@@ -27,7 +27,7 @@ declare const colors: {
|
|
|
27
27
|
readonly borderStrong: "rgba(0,0,0,0.14)";
|
|
28
28
|
readonly text: "#16161B";
|
|
29
29
|
readonly text2: "#5A5A66";
|
|
30
|
-
readonly text3: "#
|
|
30
|
+
readonly text3: "#6D6D76";
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
declare const accents: {
|
|
@@ -93,13 +93,35 @@ declare function TableOfContents({ items, rootMargin, className, ...rest }: Tabl
|
|
|
93
93
|
interface ReadingProgressProps extends ComponentPropsWithoutRef<'div'> {
|
|
94
94
|
/** Element whose scroll extent defines 100%. Defaults to the document. */
|
|
95
95
|
target?: HTMLElement | null;
|
|
96
|
+
/**
|
|
97
|
+
* Expose progress to assistive tech as a live `role="progressbar"`,
|
|
98
|
+
* updated in coarse 10% steps. Off by default: the bar is a visual aid for
|
|
99
|
+
* a value the user already has (their own scroll position), and a value
|
|
100
|
+
* that changes continuously during scroll would otherwise spam screen
|
|
101
|
+
* readers with `aria-valuenow` updates.
|
|
102
|
+
*/
|
|
103
|
+
announce?: boolean;
|
|
96
104
|
}
|
|
97
|
-
/**
|
|
98
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Fixed top progress bar. Motion is linear by spec. The fill is driven by
|
|
107
|
+
* the `--sv-reading-progress` CSS var (see style.css), not React state, so
|
|
108
|
+
* scrolling doesn't re-render this component on every frame.
|
|
109
|
+
*/
|
|
110
|
+
declare function ReadingProgress({ target, announce, className, ...rest }: ReadingProgressProps): react.JSX.Element;
|
|
99
111
|
|
|
100
112
|
/** Reports which heading id is currently active while scrolling. */
|
|
101
113
|
declare function useScrollSpy(ids: readonly string[], rootMargin?: string): string | null;
|
|
102
|
-
/**
|
|
103
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Reading progress of the page (or target element), in [0, 1].
|
|
116
|
+
*
|
|
117
|
+
* The visual bar is driven by the `--sv-reading-progress` CSS var (written on
|
|
118
|
+
* every rAF-throttled scroll tick regardless of this hook), so React state
|
|
119
|
+
* only needs to update when the *reported* value's bucket changes — not on
|
|
120
|
+
* every scroll frame. `step` sets the bucket size; the default (1, i.e. only
|
|
121
|
+
* the 0 and 1 buckets) keeps re-renders to a couple per page for consumers
|
|
122
|
+
* that don't need the numeric value, while `announce` on `<ReadingProgress>`
|
|
123
|
+
* passes 0.1 for a coarse 10%-step live value.
|
|
124
|
+
*/
|
|
125
|
+
declare function useReadingProgress(target?: HTMLElement | null, step?: number): number;
|
|
104
126
|
|
|
105
127
|
export { CopyButton, type CopyButtonProps, ReadingProgress, type ReadingProgressProps, TableOfContents, type TableOfContentsProps, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, useReadingProgress, useScrollSpy, useTheme };
|