diff --git a/website/AGENTS.md b/website/AGENTS.md index 5b80aa45..1cb75809 100644 --- a/website/AGENTS.md +++ b/website/AGENTS.md @@ -55,7 +55,7 @@ In `src/styles/global.css`, keep this setup: Do not import `tailwindcss` in that file. That import adds Preflight. Preflight overrides Starlight styles. -Docs colors are the unlayered `--sl-color-*` block in `src/styles/global.css`. The `--color-gray-*` and `--color-accent-*` scales do not change those colors. +Docs colors are the unlayered `--sl-color-*` block in `src/styles/global.css`, mapped directly to the shared OKLCH tokens. Theme state uses `html[data-theme]` (and `html[data-theme-pref]` for the 3-state toggle); do not reintroduce `.dark`. Astro 7 sets the default of `compressHTML` to `'jsx'`. This config sets `compressHTML` to `true`. That value keeps one space between inline elements. Do not remove it. diff --git a/website/astro.config.mjs b/website/astro.config.mjs index b454de35..8330f89b 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -43,7 +43,16 @@ export default defineConfig({ weights: ['100 900'], styles: ['normal'], subsets: ['latin', 'latin-ext'], - fallbacks: ['system-ui', 'sans-serif'], + fallbacks: [ + '-apple-system', + 'BlinkMacSystemFont', + 'Segoe UI', + 'Roboto', + 'Helvetica Neue', + 'Noto Sans', + 'Arial', + 'sans-serif', + ], }, { provider: fontProviders.fontsource(), @@ -91,37 +100,6 @@ export default defineConfig({ title: 'Bub', description: 'Build an agent in Python or customize the Bub application.', favicon: '/favicon.ico', - head: [ - { - tag: 'link', - attrs: { - rel: 'icon', - type: 'image/png', - href: '/favicon-light.png', - sizes: '64x64', - media: '(prefers-color-scheme: light)', - 'data-favicon-theme': 'light', - }, - }, - { - tag: 'link', - attrs: { - rel: 'icon', - type: 'image/png', - href: '/favicon-dark.png', - sizes: '64x64', - media: '(prefers-color-scheme: dark)', - 'data-favicon-theme': 'dark', - }, - }, - { - tag: 'script', - attrs: { - src: '/favicon-theme.js', - defer: true, - }, - }, - ], logo: { light: './src/assets/bub-logo.png', dark: './src/assets/bub-logo-dark.png', @@ -129,6 +107,7 @@ export default defineConfig({ }, components: { Head: './src/components/StarlightHead.astro', + ThemeSelect: './src/components/ui/ThemeToggle.astro', }, // Use the resolved file URL so Vite's module graph reliably // includes global.css on every Starlight docs page in dev mode. diff --git a/website/public/favicon-theme.js b/website/public/favicon-theme.js index 61421b67..73b613ca 100644 --- a/website/public/favicon-theme.js +++ b/website/public/favicon-theme.js @@ -1,6 +1,10 @@ (() => { const root = document.documentElement; - const systemTheme = window.matchMedia('(prefers-color-scheme: dark)'); + const systemLight = window.matchMedia('(prefers-color-scheme: light)'); + const themeColors = { + light: '#ffffff', + dark: '#0a0a0a', + }; const getTheme = () => { const documentTheme = root.dataset.theme; @@ -17,20 +21,30 @@ // Storage can be unavailable in privacy-restricted browser contexts. } - return systemTheme.matches ? 'dark' : 'light'; + return systemLight.matches ? 'light' : 'dark'; }; - const updateFavicon = () => { + const syncThemeChrome = () => { const theme = getTheme(); for (const icon of document.querySelectorAll('[data-favicon-theme]')) { icon.media = icon.dataset.faviconTheme === theme ? 'all' : 'not all'; } + + const themeColorMetas = document.querySelectorAll('meta[name="theme-color"]'); + if (themeColorMetas.length > 0) { + const primary = themeColorMetas[0]; + primary.removeAttribute('media'); + primary.setAttribute('content', themeColors[theme]); + for (let i = 1; i < themeColorMetas.length; i += 1) { + themeColorMetas[i].remove(); + } + } }; - updateFavicon(); - new MutationObserver(updateFavicon).observe(root, { + syncThemeChrome(); + new MutationObserver(syncThemeChrome).observe(root, { attributes: true, - attributeFilter: ['class', 'data-theme'], + attributeFilter: ['data-theme'], }); - systemTheme.addEventListener('change', updateFavicon); + systemLight.addEventListener('change', syncThemeChrome); })(); diff --git a/website/src/components/Hero.astro b/website/src/components/Hero.astro index b702b420..1bb75247 100644 --- a/website/src/components/Hero.astro +++ b/website/src/components/Hero.astro @@ -86,7 +86,7 @@ class MyPlugin:
- - diff --git a/website/src/components/HookIntro.astro b/website/src/components/HookIntro.astro index ed759793..c69bc342 100644 --- a/website/src/components/HookIntro.astro +++ b/website/src/components/HookIntro.astro @@ -53,10 +53,13 @@ const straightPathD = `M ${CX} ${-44} L ${CX} ${VB_H + 44}`;
- + - + - + -
- {stage.name}() - {stage.note} +
+ + {stage.name}() + + + {stage.note} +
; })} @@ -158,13 +171,9 @@ const straightPathD = `M ${CX} ${-44} L ${CX} ${VB_H + 44}`; diff --git a/website/src/components/SiteHeadAssets.astro b/website/src/components/SiteHeadAssets.astro new file mode 100644 index 00000000..7ddcaea3 --- /dev/null +++ b/website/src/components/SiteHeadAssets.astro @@ -0,0 +1,45 @@ +--- +/** Shared head assets (fonts, theme-color, adaptive favicons, and theme init) for both site pages and Starlight docs. */ +import { Font } from 'astro:assets'; +--- + + + + + + + + + diff --git a/website/src/components/StarlightHead.astro b/website/src/components/StarlightHead.astro index 2bb11a32..b82d85f4 100644 --- a/website/src/components/StarlightHead.astro +++ b/website/src/components/StarlightHead.astro @@ -1,8 +1,7 @@ --- import DefaultHead from '@astrojs/starlight/components/Head.astro'; -import { Font } from 'astro:assets'; +import SiteHeadAssets from '@/components/SiteHeadAssets.astro'; --- - - + diff --git a/website/src/components/TapeModel.astro b/website/src/components/TapeModel.astro index a1d5cbdb..7c47c2e6 100644 --- a/website/src/components/TapeModel.astro +++ b/website/src/components/TapeModel.astro @@ -55,7 +55,16 @@ const tapeEntries: TapeEntry[] = [ const entryCount = tapeEntries.filter((e) => e.kind === 'event').length; const anchorCount = tapeEntries.filter((e) => e.kind === 'anchor').length; -const COL_COUNT = 5; +const tapeColumns = [ + { label: 'time', hideOnMobile: true }, + { label: '', ariaLabel: 'kind', hideOnMobile: false }, + { label: 'op', hideOnMobile: false }, + { label: 'key', hideOnMobile: true }, + { label: 'payload', hideOnMobile: false }, +] as const; +const COL_COUNT = tapeColumns.length; +const thBaseClass = + 'border-b border-border px-[0.65rem] py-2 text-left text-[0.5rem] font-medium tracking-[0.1em] whitespace-nowrap text-muted-foreground uppercase opacity-40'; ---
@@ -78,7 +87,8 @@ const COL_COUNT = 5; class="tape-live-dot inline-block h-[6px] w-[6px] rounded-full bg-[var(--site-accent-live)] shadow-[0_0_6px_var(--site-accent-live-shadow)]" aria-hidden="true" > - live
@@ -106,35 +116,13 @@ const COL_COUNT = 5; - - time - - - - op - - - key - - - payload - + {col.label} + )} @@ -313,19 +301,12 @@ const COL_COUNT = 5; .tape-cursor-line { animation-play-state: paused; } - .tape-live-dot { - box-shadow: 0 0 6px var(--site-accent-live-shadow); - } [data-tape-running] .tape-live-dot { animation: live-pulse 2s ease-in-out infinite; } [data-tape-running] .tape-cursor-line { animation: cursor-blink 1s ease-in-out infinite; } - .tape-live-label { - color: var(--site-accent-live); - opacity: 0.8; - } @keyframes live-pulse { 0%, @@ -368,214 +349,214 @@ const COL_COUNT = 5; diff --git a/website/src/components/Testimonials.astro b/website/src/components/Testimonials.astro index 8ca35f26..ea7480af 100644 --- a/website/src/components/Testimonials.astro +++ b/website/src/components/Testimonials.astro @@ -18,14 +18,18 @@ const { eyebrow, heading, testimonials }: Props = Astro.props; const accentSequence = [1, 3, 5, 2, 4, 3] as const; const columnConfigs: ColumnConfig[] = [ - { className: 'testimonial-col min-w-0', directionClass: 'testimonial-col-up', offset: 0 }, { - className: 'testimonial-col hidden sm:block', + className: 'testimonial-col min-w-0 overflow-hidden', + directionClass: 'testimonial-col-up', + offset: 0, + }, + { + className: 'testimonial-col hidden overflow-hidden sm:block', directionClass: 'testimonial-col-down', offset: 2, }, { - className: 'testimonial-col hidden lg:block', + className: 'testimonial-col hidden overflow-hidden lg:block', directionClass: 'testimonial-col-up-slow', offset: 4, }, @@ -68,9 +72,6 @@ const columns = columnConfigs.map((config, columnIndex) => ({ -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent); } - .testimonial-col { - overflow: hidden; - } .testimonial-col > div { animation-timing-function: linear; animation-iteration-count: infinite; @@ -119,72 +120,13 @@ const columns = columnConfigs.map((config, columnIndex) => ({ diff --git a/website/src/components/ui/FeatureCard.astro b/website/src/components/ui/FeatureCard.astro index 8298802b..0d56b1d8 100644 --- a/website/src/components/ui/FeatureCard.astro +++ b/website/src/components/ui/FeatureCard.astro @@ -13,7 +13,7 @@ const { feature, wide = false, iconSize = wide ? 120 : 96 } = Astro.props;
@@ -33,14 +33,3 @@ const { feature, wide = false, iconSize = wide ? 120 : 96 } = Astro.props;

{feature.description}

- - diff --git a/website/src/components/ui/Icon.astro b/website/src/components/ui/Icon.astro index fbe57fb1..62896a28 100644 --- a/website/src/components/ui/Icon.astro +++ b/website/src/components/ui/Icon.astro @@ -12,6 +12,7 @@ import Ellipsis from '@lucide/astro/icons/ellipsis'; import Languages from '@lucide/astro/icons/languages'; import Layers from '@lucide/astro/icons/layers'; import Menu from '@lucide/astro/icons/menu'; +import Monitor from '@lucide/astro/icons/monitor'; import Moon from '@lucide/astro/icons/moon'; import Newspaper from '@lucide/astro/icons/newspaper'; import Package from '@lucide/astro/icons/package'; @@ -38,6 +39,7 @@ const lucideIcons = { languages: Languages, layers: Layers, menu: Menu, + monitor: Monitor, moon: Moon, newspaper: Newspaper, package: Package, diff --git a/website/src/components/ui/ThemeToggle.astro b/website/src/components/ui/ThemeToggle.astro index b6a7e685..68165344 100644 --- a/website/src/components/ui/ThemeToggle.astro +++ b/website/src/components/ui/ThemeToggle.astro @@ -1,19 +1,50 @@ --- import Icon from '@/components/ui/Icon.astro'; +import { getLangFromUrl } from '@/i18n/utils'; + +const locale = getLangFromUrl(Astro.url); +const labels = + locale === 'zh-cn' + ? { + auto: '主题:自动(点击切换浅色)', + light: '主题:浅色(点击切换深色)', + dark: '主题:深色(点击切换自动)', + } + : { + auto: 'Theme: Auto (click for Light)', + light: 'Theme: Light (click for Dark)', + dark: 'Theme: Dark (click for Auto)', + }; --- diff --git a/website/src/layouts/BaseLayout.astro b/website/src/layouts/BaseLayout.astro index ac13d7f2..b1ff348d 100644 --- a/website/src/layouts/BaseLayout.astro +++ b/website/src/layouts/BaseLayout.astro @@ -3,10 +3,10 @@ import '@/styles/site.css'; import Footer from '@/components/Footer.astro'; import NavBar from '@/components/NavBar.astro'; +import SiteHeadAssets from '@/components/SiteHeadAssets.astro'; import Icon from '@/components/ui/Icon.astro'; import { getLangFromUrl, getHtmlLang, getNavProps, useTranslations } from '@/i18n/utils'; import { getRepoStats } from '@/lib/github'; -import { Font } from 'astro:assets'; import { SITE_URL } from 'astro:env/client'; interface Props { @@ -57,29 +57,10 @@ const ogImageUrl = new URL(ogImage, siteOrigin).href; - - + + {title} - - - - - {resolvedCanonicalUrl && } {robots && } @@ -95,17 +76,6 @@ const ogImageUrl = new URL(ogImage, siteOrigin).href; - - diff --git a/website/src/layouts/PostLayout.astro b/website/src/layouts/PostLayout.astro index b18a6ade..c7ed7ade 100644 --- a/website/src/layouts/PostLayout.astro +++ b/website/src/layouts/PostLayout.astro @@ -84,7 +84,7 @@ const ogImage = `/og/posts/${postId}.png`; } .post-content p { margin-bottom: 1.25rem; - color: var(--muted-foreground); + color: var(--sl-color-text); } .post-content a { color: var(--foreground); @@ -99,7 +99,7 @@ const ogImage = `/og/posts/${postId}.png`; .post-content ol { margin-bottom: 1.25rem; padding-left: 1.5rem; - color: var(--muted-foreground); + color: var(--sl-color-text); } .post-content ul { list-style-type: disc; @@ -118,7 +118,7 @@ const ogImage = `/og/posts/${postId}.png`; font-style: italic; } .post-content code:not(:where(.not-content *)) { - font-family: 'JetBrains Mono Variable', ui-monospace, monospace; + font-family: var(--font-mono); font-size: 0.875em; padding: 0.125rem 0.375rem; background: var(--secondary); @@ -130,7 +130,7 @@ const ogImage = `/og/posts/${postId}.png`; overflow-x: auto; background: var(--secondary); border: 1px solid var(--border); - font-family: 'JetBrains Mono Variable', ui-monospace, monospace; + font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.7; } diff --git a/website/src/lib/viewport-loop.ts b/website/src/lib/viewport-loop.ts new file mode 100644 index 00000000..ecf9524b --- /dev/null +++ b/website/src/lib/viewport-loop.ts @@ -0,0 +1,96 @@ +import { inView } from 'motion'; + +type InViewOptions = Parameters[2]; + +export interface ViewportLoopController { + start: () => void; + stop: () => void; + /** Render a static fallback when `prefers-reduced-motion: reduce` is active. */ + showStatic?: () => void; + /** Tear down extra listeners owned by the caller. */ + destroy?: () => void; +} + +export interface ViewportLoopOptions { + margin?: NonNullable['margin']; + setup: (element: HTMLElement) => ViewportLoopController | void; +} + +const cleanups = new Map void>(); +const bound = new Set(); + +/** + * Mounts an in-view animation loop with automatic pause/resume on + * `prefers-reduced-motion`, tab visibility changes, and Astro page loads. + */ +export function mountViewportLoop(selector: string, options: ViewportLoopOptions): void { + const init = () => { + cleanups.get(selector)?.(); + cleanups.delete(selector); + + const element = document.querySelector(selector); + if (!element) return; + + const controller = options.setup(element); + if (!controller) return; + + const reduceMotionMql = window.matchMedia('(prefers-reduced-motion: reduce)'); + let isInView = false; + let isRunning = false; + + const sync = () => { + if (reduceMotionMql.matches) { + if (isRunning) { + controller.stop(); + isRunning = false; + } + controller.showStatic?.(); + return; + } + + const shouldRun = isInView && document.visibilityState !== 'hidden'; + if (shouldRun && !isRunning) { + isRunning = true; + controller.start(); + } else if (!shouldRun && isRunning) { + isRunning = false; + controller.stop(); + } + }; + + const stopInView = inView( + element, + () => { + isInView = true; + sync(); + return () => { + isInView = false; + sync(); + }; + }, + options.margin ? { margin: options.margin } : undefined, + ); + + reduceMotionMql.addEventListener('change', sync); + document.addEventListener('visibilitychange', sync); + if (reduceMotionMql.matches) controller.showStatic?.(); + + cleanups.set(selector, () => { + stopInView(); + reduceMotionMql.removeEventListener('change', sync); + document.removeEventListener('visibilitychange', sync); + isInView = false; + if (isRunning) { + isRunning = false; + controller.stop(); + } + controller.destroy?.(); + }); + }; + + init(); + if (!bound.has(selector)) { + document.addEventListener('astro:page-load', init); + bound.add(selector); + } +} diff --git a/website/src/styles/global.css b/website/src/styles/global.css index d0826bdb..57809b1f 100644 --- a/website/src/styles/global.css +++ b/website/src/styles/global.css @@ -15,31 +15,6 @@ --font-mono: var(--font-jetbrains-mono); --font-heading: var(--font-sans); - /* starlight-tailwind maps these scales into --sl-color-*; keep chroma 0 for monochrome. */ - --color-accent-50: oklch(0.985 0 0); - --color-accent-100: oklch(0.97 0 0); - --color-accent-200: oklch(0.922 0 0); - --color-accent-300: oklch(0.87 0 0); - --color-accent-400: oklch(0.708 0 0); - --color-accent-500: oklch(0.556 0 0); - --color-accent-600: oklch(0.47 0 0); - --color-accent-700: oklch(0.35 0 0); - --color-accent-800: oklch(0.269 0 0); - --color-accent-900: oklch(0.205 0 0); - --color-accent-950: oklch(0.145 0 0); - - --color-gray-50: oklch(0.985 0 0); - --color-gray-100: oklch(0.97 0 0); - --color-gray-200: oklch(0.922 0 0); - --color-gray-300: oklch(0.87 0 0); - --color-gray-400: oklch(0.708 0 0); - --color-gray-500: oklch(0.556 0 0); - --color-gray-600: oklch(0.47 0 0); - --color-gray-700: oklch(0.35 0 0); - --color-gray-800: oklch(0.269 0 0); - --color-gray-900: oklch(0.205 0 0); - --color-gray-950: oklch(0.145 0 0); - --color-background: var(--background); --color-foreground: var(--foreground); --color-card: var(--card); @@ -81,7 +56,8 @@ --radius-4xl: calc(var(--radius) * 2.6); } -:root { +:root, +::backdrop { --radius: 0.625rem; --background: oklch(1 0 0); --foreground: oklch(0.145 0 0); @@ -114,49 +90,11 @@ --sidebar-accent-foreground: oklch(0.205 0 0); --sidebar-border: oklch(0.922 0 0); --sidebar-ring: oklch(0.708 0 0); - - --site-shadow-elevated: 0 8px 30px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04); - --site-shadow-card: 0 1px 2px rgb(0 0 0 / 0.04), 0 2px 8px rgb(0 0 0 / 0.03); - --site-shadow-card-strong: 0 2px 10px rgb(0 0 0 / 0.04); - --site-grid-dot: #999; - --site-accent-live: oklch(0.72 0.17 155); - --site-accent-live-shadow: oklch(0.72 0.17 155 / 0.5); - --site-accent-live-shadow-dim: oklch(0.72 0.17 155 / 0.15); - --site-accent-signal: oklch(0.7 0.15 250); - --site-accent-signal-soft: oklch(0.7 0.15 250 / 0.5); - --site-accent-signal-emphasis: oklch(0.7 0.15 250 / 0.4); - --site-accent-signal-rule: oklch(0.7 0.15 250 / 0.2); - --site-accent-signal-border: oklch(0.7 0.15 250 / 0.3); - --site-accent-signal-dashed: oklch(0.7 0.15 250 / 0.35); - --site-accent-signal-dashed-border: oklch(0.7 0.15 250 / 0.15); - --site-accent-signal-bg: oklch(0.7 0.15 250 / 0.06); - --site-accent-signal-bg-subtle: oklch(0.7 0.15 250 / 0.03); - --site-accent-signal-bg-strong: oklch(0.7 0.15 250 / 0.1); - --site-accent-signal-shadow: oklch(0.7 0.15 250 / 0.25); - --site-accent-warm: oklch(0.72 0.17 78); - --site-accent-warm-shadow: rgb(255 196 82 / 0.35); - --site-accent-warm-shadow-idle: rgb(255 196 82 / 0); - --site-hook-ping-ring: oklch(0.55 0.06 260 / 0.2); - --site-hook-ping-ring-soft: oklch(0.55 0.06 260 / 0.06); - --site-hook-ping-ring-idle: oklch(0.55 0.06 260 / 0); - --site-hook-ping-glow: oklch(0.55 0.06 260 / 0.15); - --site-hook-ping-glow-soft: oklch(0.55 0.06 260 / 0.06); - --site-hook-ping-glow-idle: oklch(0.55 0.06 260 / 0); - - --site-testimonial-1: oklch(0.62 0.04 40); - --site-testimonial-2: oklch(0.58 0.03 185); - --site-testimonial-3: oklch(0.48 0.025 227); - --site-testimonial-4: oklch(0.7 0.04 84); - --site-testimonial-5: oklch(0.66 0.04 70); - - --site-ambient-1: oklch(0.88 0.025 250 / 0.5); - --site-ambient-2: oklch(0.9 0.02 78 / 0.4); - --site-ambient-3: oklch(0.87 0.018 155 / 0.35); } -/* Landing uses .dark; Starlight docs use [data-theme="dark"]. ThemeToggle sets both. */ -.dark, -[data-theme='dark'] { +/* Single dark-mode source of truth shared by site pages and Starlight docs. */ +[data-theme='dark'], +[data-theme='dark'] ::backdrop { --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); --card: oklch(0.205 0 0); @@ -188,64 +126,72 @@ --sidebar-accent-foreground: oklch(0.985 0 0); --sidebar-border: oklch(1 0 0 / 10%); --sidebar-ring: oklch(0.556 0 0); - - --site-shadow-elevated: - 0 8px 30px rgb(0 0 0 / 0.35), 0 2px 8px rgb(0 0 0 / 0.25), 0 0 0 1px rgb(255 255 255 / 0.04); - --site-shadow-card: 0 1px 2px rgb(0 0 0 / 0.25), 0 2px 8px rgb(0 0 0 / 0.18); - --site-shadow-card-strong: 0 2px 10px rgb(0 0 0 / 0.3); - --site-grid-dot: #555; - - --site-testimonial-1: oklch(0.55 0.04 40); - --site-testimonial-2: oklch(0.52 0.03 185); - --site-testimonial-3: oklch(0.42 0.025 227); - --site-testimonial-4: oklch(0.6 0.04 84); - --site-testimonial-5: oklch(0.58 0.04 70); - - --site-ambient-1: oklch(0.22 0.03 250 / 0.5); - --site-ambient-2: oklch(0.25 0.025 78 / 0.4); - --site-ambient-3: oklch(0.2 0.02 155 / 0.35); } /* - * Unlayered Starlight overrides — bridge auto-map is too dark for monochrome - * link text (e.g. accent-600 → oklch(0.47)). + * Unlayered Starlight overrides — map directly onto the shared OKLCH tokens so + * site pages and Starlight docs share one monochrome palette and content width. */ -:root { +:root, +::backdrop { --sl-font: var(--font-outfit); --sl-font-mono: var(--font-jetbrains-mono); + --sl-content-width: 52rem; - --sl-color-white: hsl(0, 0%, 100%); - --sl-color-gray-1: hsl(0, 0%, 96%); - --sl-color-gray-2: hsl(0, 0%, 64%); - --sl-color-gray-3: hsl(0, 0%, 47%); - --sl-color-gray-4: hsl(0, 0%, 35%); - --sl-color-gray-5: hsl(0, 0%, 25%); - --sl-color-gray-6: hsl(0, 0%, 18%); - --sl-color-black: hsl(0, 0%, 11%); - - --sl-color-accent-low: hsl(0, 0%, 25%); - --sl-color-accent: hsl(0, 0%, 64%); - --sl-color-accent-high: hsl(0, 0%, 96%); + --sl-color-white: var(--foreground); + --sl-color-gray-1: var(--primary); + --sl-color-gray-2: var(--muted-foreground); + --sl-color-gray-3: var(--ring); + --sl-color-gray-4: oklch(0.38 0 0); + --sl-color-gray-5: var(--secondary); + --sl-color-gray-6: var(--card); + --sl-color-black: var(--background); + + --sl-color-accent-low: var(--secondary); + --sl-color-accent: var(--muted-foreground); + --sl-color-accent-high: var(--foreground); + --sl-color-text-invert: var(--primary-foreground); + --sl-color-hairline-shade: var(--border); } :root[data-theme='light'], [data-theme='light'] ::backdrop { - --sl-color-white: hsl(0, 0%, 11%); - --sl-color-gray-1: hsl(0, 0%, 18%); - --sl-color-gray-2: hsl(0, 0%, 25%); - --sl-color-gray-3: hsl(0, 0%, 35%); - --sl-color-gray-4: hsl(0, 0%, 47%); - --sl-color-gray-5: hsl(0, 0%, 80%); - --sl-color-gray-6: hsl(0, 0%, 93%); - --sl-color-gray-7: hsl(0, 0%, 98%); - --sl-color-black: hsl(0, 0%, 100%); - - --sl-color-accent-high: hsl(0, 0%, 11%); - --sl-color-accent: hsl(0, 0%, 18%); - --sl-color-accent-low: hsl(0, 0%, 93%); + --sl-color-white: var(--foreground); + --sl-color-gray-1: var(--primary); + --sl-color-gray-2: oklch(0.32 0 0); + --sl-color-gray-3: var(--muted-foreground); + --sl-color-gray-4: var(--ring); + --sl-color-gray-5: var(--border); + --sl-color-gray-6: var(--secondary); + --sl-color-gray-7: var(--sidebar); + --sl-color-black: var(--background); + + --sl-color-accent-high: var(--foreground); + --sl-color-accent: var(--primary); + --sl-color-accent-low: var(--secondary); + --sl-color-text-invert: var(--primary-foreground); + --sl-color-hairline-shade: var(--border); } @layer base { + /* + * Fallbacks for Starlight/Expressive Code variables on non-Starlight pages + * (landing, blog) where Starlight's `props.css` is not loaded. Because + * `@layer base` precedes `@layer starlight`, `props.css` still wins on docs. + */ + :root { + --__sl-font: var(--font-sans); + --__sl-font-mono: var(--font-mono); + --sl-text-code: 0.875rem; + --sl-line-height: 1.75; + --sl-line-height-headings: 1.2; + --sl-outline-offset-inside: -0.1875rem; + --sl-color-text: var(--sl-color-gray-2); + --sl-color-text-accent: var(--sl-color-accent-high); + } + :root[data-theme='light'] { + --sl-color-text-accent: var(--sl-color-accent); + } * { @apply border-border outline-ring/50; } @@ -255,9 +201,25 @@ } html { @apply bg-background; + color-scheme: dark; scroll-behavior: smooth; overflow-x: clip; } + html[data-theme='light'] { + color-scheme: light; + } + [lang]:where(:lang(zh), :lang(ja)) { + text-autospace: normal; + } + [lang]:where(:not(:lang(zh), :lang(ja))) { + text-autospace: initial; + } + pre, + code, + samp, + kbd { + text-autospace: no-autospace; + } ::selection { background-color: var(--primary); color: var(--primary-foreground); @@ -266,10 +228,6 @@ outline: 2px solid var(--ring); outline-offset: 2px; } - a:focus-visible { - outline: 2px solid var(--ring); - outline-offset: 2px; - } } @media (prefers-reduced-motion: reduce) { @@ -284,20 +242,6 @@ } } -/* Widen body past Starlight's 45rem default so wide screens don't look right-biased. */ -.content-panel > .sl-container { - --sl-content-width: 52rem; -} - -@media (min-width: 72rem) { - .content-panel > .sl-container { - margin-inline: auto; - } - .right-sidebar-container { - width: var(--sl-sidebar-width); - } -} - /* * Keep Starlight's display:block + overflow-x:auto — switching to display:table * lets nowrap code inflate the table past the container and break page scroll. @@ -324,112 +268,6 @@ } } -/* Shared Expressive Code presentation. */ -.site-code-block { - --ec-brdWd: 0px; - --ec-brdRad: 0px; - --ec-codeBg: var(--card); - --ec-frm-edBg: var(--card); - --ec-frm-edTabBarBg: var(--secondary); - --ec-frm-edTabBarBrdCol: var(--border); - --ec-frm-edTabBarBrdBtmCol: var(--border); - --ec-frm-edActTabBg: var(--card); - --ec-frm-edActTabFg: var(--muted-foreground); - --ec-frm-edActTabIndTopCol: transparent; - --ec-frm-edActTabIndBtmCol: transparent; - --ec-frm-inlBtnFg: var(--muted-foreground); - --ec-frm-inlBtnBg: var(--ec-frm-inlBtnFg); - --ec-frm-inlBtnBrd: var(--ec-frm-inlBtnFg); - --ec-codeFontFml: var(--font-mono); - --ec-codeFontSize: 0.78rem; - --ec-codeLineHt: 1.7; - --ec-codePadBlk: 1rem; - --ec-codePadInl: 1.25rem; - --ec-uiFontFml: var(--font-mono); - --ec-uiFontSize: 0.78rem; - --ec-uiPadBlk: 0.4rem; - --ec-uiPadInl: 1rem; - margin: 0; -} - -.site-code-block pre > code { - padding: var(--ec-codePadBlk) 0; - font-size: var(--ec-codeFontSize); - line-height: var(--ec-codeLineHt); -} - -.site-code-block .ec-line .code { - padding-inline-start: calc(var(--ecIndent, 0ch) + var(--ec-codePadInl) - var(--ecGtrBrdWd)); - padding-inline-end: var(--ec-codePadInl); -} - -.site-code-block .frame.has-title:not(.is-terminal) .title { - padding: calc(var(--ec-uiPadBlk) + var(--ec-frm-edActTabIndHt)) var(--ec-uiPadInl); -} - -.site-code-block .copy button { - border-radius: 0.2rem; - background: var(--ec-codeBg); - opacity: 0.75; -} - -.site-code-block .copy button > div { - background: var(--ec-frm-inlBtnBg); -} - -.site-code-block .copy button::before { - border: var(--ec-brdWd) solid var(--ec-frm-inlBtnBrd); -} - -.site-code-block .copy button::after { - margin: 0.475rem; -} - -@media (hover: hover) { - .site-code-block .copy button { - opacity: 0; - } - - .site-code-block .frame:hover .copy button:not(:hover), - .site-code-block .frame:focus-within :focus-visible ~ .copy button:not(:hover), - .site-code-block .frame .copy .feedback.show ~ button:not(:hover) { - opacity: 0.75; - } -} - -.site-code-block .copy button:hover, -.site-code-block .copy button:focus-visible { - opacity: 1; -} - -.site-code-block--no-copy .copy { - display: none; -} - -.install-tabs [role='tablist'] { - border-bottom: 1px solid var(--border); -} - -.install-tabs .tab > [role='tab'] { - padding: 0.5rem 1.25rem; - color: var(--muted-foreground); - font-family: var(--font-mono); - font-size: 0.78rem; - box-shadow: 0 1px 0 var(--border); -} - -.install-tabs .tab > [role='tab'][aria-selected='true'] { - color: var(--foreground); - box-shadow: 0 1px 0 var(--foreground); -} - -.install-tabs .site-code-block { - --ec-brdWd: 1px; - --ec-brdCol: var(--border); - --ec-codePadBlk: 0.75rem; - --ec-codePadInl: 1rem; -} - .pele-diagram { --pele-bg: var(--background); --pele-fg: var(--foreground); diff --git a/website/src/styles/site.css b/website/src/styles/site.css index 0102e44a..bdbee096 100644 --- a/website/src/styles/site.css +++ b/website/src/styles/site.css @@ -2,8 +2,168 @@ * Landing/blog Tailwind entry. Full Preflight lives here (not in global.css) * so Starlight markdown styles are not reset: * https://starlight.astro.build/guides/css-and-tailwind/#use-multiple-tailwind-configurations + * + * Site-only tokens (`--site-*`) and landing code/tab presentation live here so + * Starlight docs pages do not load unused site styles. */ @layer base, starlight, theme, components, utilities; @import 'tailwindcss/preflight.css' layer(base); @import './global.css'; + +:root { + --site-shadow-elevated: 0 8px 30px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04); + --site-shadow-card: 0 1px 2px rgb(0 0 0 / 0.04), 0 2px 8px rgb(0 0 0 / 0.03); + --site-grid-dot: #999; + --site-accent-live: oklch(0.72 0.17 155); + --site-accent-live-shadow: oklch(0.72 0.17 155 / 0.5); + --site-accent-signal: oklch(0.7 0.15 250); + --site-accent-signal-soft: oklch(0.7 0.15 250 / 0.5); + --site-accent-signal-emphasis: oklch(0.7 0.15 250 / 0.4); + --site-accent-signal-rule: oklch(0.7 0.15 250 / 0.2); + --site-accent-signal-border: oklch(0.7 0.15 250 / 0.3); + --site-accent-signal-dashed: oklch(0.7 0.15 250 / 0.35); + --site-accent-signal-dashed-border: oklch(0.7 0.15 250 / 0.15); + --site-accent-signal-bg: oklch(0.7 0.15 250 / 0.06); + --site-accent-signal-bg-subtle: oklch(0.7 0.15 250 / 0.03); + --site-accent-signal-bg-strong: oklch(0.7 0.15 250 / 0.1); + --site-accent-signal-shadow: oklch(0.7 0.15 250 / 0.25); + --site-accent-warm: oklch(0.72 0.17 78); + --site-accent-warm-shadow: rgb(255 196 82 / 0.35); + --site-accent-warm-shadow-idle: rgb(255 196 82 / 0); + --site-hook-ping-ring: oklch(0.55 0.06 260 / 0.2); + --site-hook-ping-glow: oklch(0.55 0.06 260 / 0.15); + + --site-testimonial-1: oklch(0.62 0.04 40); + --site-testimonial-2: oklch(0.58 0.03 185); + --site-testimonial-3: oklch(0.48 0.025 227); + --site-testimonial-4: oklch(0.7 0.04 84); + --site-testimonial-5: oklch(0.66 0.04 70); + + --site-ambient-1: oklch(0.88 0.025 250 / 0.5); + --site-ambient-2: oklch(0.9 0.02 78 / 0.4); + --site-ambient-3: oklch(0.87 0.018 155 / 0.35); +} + +[data-theme='dark'] { + --site-shadow-elevated: + 0 8px 30px rgb(0 0 0 / 0.35), 0 2px 8px rgb(0 0 0 / 0.25), 0 0 0 1px rgb(255 255 255 / 0.04); + --site-shadow-card: 0 1px 2px rgb(0 0 0 / 0.25), 0 2px 8px rgb(0 0 0 / 0.18); + --site-grid-dot: #555; + + --site-testimonial-1: oklch(0.55 0.04 40); + --site-testimonial-2: oklch(0.52 0.03 185); + --site-testimonial-3: oklch(0.42 0.025 227); + --site-testimonial-4: oklch(0.6 0.04 84); + --site-testimonial-5: oklch(0.58 0.04 70); + + --site-ambient-1: oklch(0.22 0.03 250 / 0.5); + --site-ambient-2: oklch(0.25 0.025 78 / 0.4); + --site-ambient-3: oklch(0.2 0.02 155 / 0.35); +} + +/* Landing Expressive Code presentation. */ +.site-code-block { + --ec-brdWd: 0px; + --ec-brdRad: 0px; + --ec-codeBg: var(--card); + --ec-frm-edBg: var(--card); + --ec-frm-edTabBarBg: var(--secondary); + --ec-frm-edTabBarBrdCol: var(--border); + --ec-frm-edTabBarBrdBtmCol: var(--border); + --ec-frm-edActTabBg: var(--card); + --ec-frm-edActTabFg: var(--muted-foreground); + --ec-frm-edActTabIndTopCol: transparent; + --ec-frm-edActTabIndBtmCol: transparent; + --ec-frm-inlBtnFg: var(--muted-foreground); + --ec-frm-inlBtnBg: var(--ec-frm-inlBtnFg); + --ec-frm-inlBtnBrd: var(--ec-frm-inlBtnFg); + --ec-codeFontFml: var(--font-mono); + --ec-codeFontSize: 0.78rem; + --ec-codeLineHt: 1.7; + --ec-codePadBlk: 1rem; + --ec-codePadInl: 1.25rem; + --ec-uiFontFml: var(--font-mono); + --ec-uiFontSize: 0.78rem; + --ec-uiPadBlk: 0.4rem; + --ec-uiPadInl: 1rem; + margin: 0; +} + +.site-code-block pre > code { + padding: var(--ec-codePadBlk) 0; + font-size: var(--ec-codeFontSize); + line-height: var(--ec-codeLineHt); +} + +.site-code-block .ec-line .code { + padding-inline-start: calc(var(--ecIndent, 0ch) + var(--ec-codePadInl) - var(--ecGtrBrdWd)); + padding-inline-end: var(--ec-codePadInl); +} + +.site-code-block .frame.has-title:not(.is-terminal) .title { + padding: calc(var(--ec-uiPadBlk) + var(--ec-frm-edActTabIndHt)) var(--ec-uiPadInl); +} + +.site-code-block .copy button { + border-radius: 0.2rem; + background: var(--ec-codeBg); + opacity: 0.75; +} + +.site-code-block .copy button > div { + background: var(--ec-frm-inlBtnBg); +} + +.site-code-block .copy button::before { + border: var(--ec-brdWd) solid var(--ec-frm-inlBtnBrd); +} + +.site-code-block .copy button::after { + margin: 0.475rem; +} + +@media (hover: hover) { + .site-code-block .copy button { + opacity: 0; + } + + .site-code-block .frame:hover .copy button:not(:hover), + .site-code-block .frame:focus-within :focus-visible ~ .copy button:not(:hover), + .site-code-block .frame .copy .feedback.show ~ button:not(:hover) { + opacity: 0.75; + } +} + +.site-code-block .copy button:hover, +.site-code-block .copy button:focus-visible { + opacity: 1; +} + +.site-code-block--no-copy .copy { + display: none; +} + +.install-tabs [role='tablist'] { + border-bottom: 1px solid var(--border); +} + +.install-tabs .tab > [role='tab'] { + padding: 0.5rem 1.25rem; + color: var(--muted-foreground); + font-family: var(--font-mono); + font-size: 0.78rem; + box-shadow: 0 1px 0 var(--border); +} + +.install-tabs .tab > [role='tab'][aria-selected='true'] { + color: var(--foreground); + box-shadow: 0 1px 0 var(--foreground); +} + +.install-tabs .site-code-block { + --ec-brdWd: 1px; + --ec-brdCol: var(--border); + --ec-codePadBlk: 0.75rem; + --ec-codePadInl: 1rem; +}