An open source design system that's fully customizable and agent ready
TypeScript
feat(docsite): restyle home hero theme carousel + mobile polish (#3135)
rubyycheung34038a736f6a
diff --git a/apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx b/apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsxindex 95d4374228..d793f79446 100644--- a/apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx+++ b/apps/docsite/src/app/(site)/_landing/FeaturesShowcase.tsx@@ -58,7 +58,11 @@ const styles = stylex.create({width: '100%',maxWidth: layout.contentMaxWidth,display: 'grid',- gap: spacingVars['--spacing-8'],+ // Tighter stacking gap on mobile; roomier --spacing-8 at the ≥1024px bento.+ gap: {+ default: spacingVars['--spacing-5'],+ '@media (min-width: 1024px)': spacingVars['--spacing-8'],+ },// minmax(0, 1fr) (not 1fr) so a card with wide content — e.g. the Themes// preview's left-bleed — can't blow out its column; all three stay equal.gridTemplateColumns: {diff --git a/apps/docsite/src/app/(site)/_landing/hero/HeroFloatingCards.tsx b/apps/docsite/src/app/(site)/_landing/hero/HeroFloatingCards.tsxindex b5c98e54ff..5e6cb95698 100644--- a/apps/docsite/src/app/(site)/_landing/hero/HeroFloatingCards.tsx+++ b/apps/docsite/src/app/(site)/_landing/hero/HeroFloatingCards.tsx@@ -59,6 +59,13 @@ const styles = stylex.create({default: 'grid','@media (min-width: 1024px)': 'none',},+ // Scale the collage down on mobile. `zoom` (not transform:scale) so the+ // laid-out box shrinks too — no reserved empty space below.+ zoom: {+ default: 0.8,+ '@media (min-width: 768px)': 0.9,+ '@media (min-width: 1024px)': 1,+ },gridTemplateColumns: {default: '1fr 1fr','@media (min-width: 768px)': '1fr 1fr minmax(0, 240px)',@@ -93,7 +100,11 @@ const styles = stylex.create({},width: '100vw',marginInline: 'calc(50% - 50vw)',- marginBlockStart: 'var(--hero-gap)',+ // --hero-gap (96px) is too cavernous on phones; full gap returns at ≥768px.+ marginBlockStart: {+ default: 'var(--spacing-10)',+ '@media (min-width: 768px)': 'var(--hero-gap)',+ },},gaProduct: {gridArea: 'product',diff --git a/apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx b/apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsxindex f53dc5639f..c96aaf7007 100644--- a/apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx+++ b/apps/docsite/src/app/(site)/_landing/hero/HeroThemeReel.tsx@@ -20,8 +20,10 @@ import {useContext,useEffect,useMemo,+ useRef,useState,type ReactNode,+ type TouchEvent as ReactTouchEvent,} from 'react';import * as stylex from '@stylexjs/stylex';import {Theme} from '@astryxdesign/core/theme';@@ -201,6 +203,10 @@ const styles = stylex.create({whiteSpace: 'nowrap',borderWidth: 0,},+ // pan-y so a horizontal swipe goes to our handler, not page side-pan.+ swipeArea: {+ touchAction: 'pan-y',+ },});// Dynamic per-theme values via stylex.create functions (no inline styles).@@ -236,6 +242,45 @@ export function HeroReelProvider({children}: {children: ReactNode}) {[slides.length],);+ // Touch swipe (mobile): swipe left → next theme, right → previous.+ const touchStart = useRef<{x: number; y: number} | null>(null);+ const SWIPE_THRESHOLD_PX = 45;+ const onTouchStart = useCallback((e: ReactTouchEvent) => {+ const t = e.touches[0];+ if (!t) {+ return;+ }+ touchStart.current = {x: t.clientX, y: t.clientY};+ // Touch devices have no hover, so pause auto-advance while the finger is down.+ setPaused(true);+ }, []);+ const onTouchEnd = useCallback(+ (e: ReactTouchEvent) => {+ setPaused(false);+ const start = touchStart.current;+ touchStart.current = null;+ if (!start || slides.length <= 1) {+ return;+ }+ const t = e.changedTouches[0];+ if (!t) {+ return;+ }+ const dx = t.clientX - start.x;+ const dy = t.clientY - start.y;+ // Only a mostly-horizontal gesture counts, so vertical scroll isn't a swipe.+ if (Math.abs(dx) < SWIPE_THRESHOLD_PX || Math.abs(dx) <= Math.abs(dy)) {+ return;+ }+ setIndex(i => {+ const count = slides.length;+ const next = dx < 0 ? i + 1 : i - 1;+ return ((next % count) + count) % count;+ });+ },+ [slides.length],+ );+useEffect(() => {if (!AUTOPLAY_ENABLED || reduceMotion || paused || slides.length <= 1) {return;@@ -301,10 +346,13 @@ export function HeroReelProvider({children}: {children: ReactNode}) {return (<HeroReelContext value={value}><div+ {...stylex.props(styles.swipeArea)}onMouseEnter={() => setPaused(true)}onMouseLeave={() => setPaused(false)}onFocusCapture={() => setPaused(true)}- onBlurCapture={() => setPaused(false)}>+ onBlurCapture={() => setPaused(false)}+ onTouchStart={onTouchStart}+ onTouchEnd={onTouchEnd}>{children}</div></HeroReelContext>diff --git a/apps/docsite/src/app/(site)/page.tsx b/apps/docsite/src/app/(site)/page.tsxindex 433c2c7f01..5439aec99a 100644--- a/apps/docsite/src/app/(site)/page.tsx+++ b/apps/docsite/src/app/(site)/page.tsx@@ -27,11 +27,7 @@ import {FeaturesShowcase} from './_landing/FeaturesShowcase';import {AboutShowcase} from './_landing/AboutShowcase';import {DiscoverShowcase} from './_landing/DiscoverShowcase';-// Hero band height (reserved by heroSpacer). Desktop is fixed; narrow screens-// fall back to these per-tier values until the measured height is applied.const HERO_BAND_HEIGHT = 760;-const HERO_BAND_HEIGHT_NARROW = 940; // 768–1024px: 3-column collage-const HERO_BAND_HEIGHT_2COL = 1200; // <768px: 2-column collageconst styles = stylex.create({// Wraps hero + showcase so the pin-and-cover stays bounded to this container@@ -42,12 +38,19 @@ const styles = stylex.create({// Shared by the nav→wordmark gap and the text→cards gap so they match.'--hero-gap': 'calc(var(--spacing-12) * 2)',},- // Hero content column. position:fixed (like the aurora glow) so it stays put- // while the showcase scrolls up and covers it (pin-and-cover). Pulled out of- // flow; heroSpacer reserves its height. Capped at 800 (reading measure).+ // Desktop: fixed for pin-and-cover (heroSpacer reserves its height). Narrow:+ // in flow — the mobile hero is taller than the viewport, so pinning stranded+ // the lower collage below the fold.heroContent: {- position: 'fixed',- top: 'var(--appshell-header-height, 0px)',+ position: {+ default: 'relative',+ '@media (min-width: 1024px)': 'fixed',+ },+ // top offset only matters when fixed; in flow it would leave a gap.+ top: {+ default: 0,+ '@media (min-width: 1024px)': 'var(--appshell-header-height, 0px)',+ },left: 0,right: 0,// Desktop: fixed band, centered (cards are a separate overlap layer).@@ -63,10 +66,12 @@ const styles = stylex.create({default: 'flex-start','@media (min-width: 1024px)': 'center',},- // Narrow: --hero-gap below the nav (matches the text→cards gap). Desktop- // centers, so no top padding.+ // Narrow: in flow under the transparent nav, so pad by nav height to clear+ // it. Desktop is fixed + centered, so none.paddingBlockStart: {- default: 'var(--hero-gap)',+ default: 'calc(var(--appshell-header-height, 0px) + var(--spacing-8))',+ '@media (min-width: 768px)':+ 'calc(var(--appshell-header-height, 0px) + var(--hero-gap))','@media (min-width: 1024px)': 0,},paddingBlockEnd: spacingVars['--spacing-12'],@@ -79,14 +84,10 @@ const styles = stylex.create({// content (the buttons/links re-enable pointer events on themselves).zIndex: 0,},- // Reserves the hero's height in flow (heroContent is fixed/out of flow).- // Narrow: the measured --hero-content-height (per-tier constants are the- // fallback), capped at 100lvh so the pinned band never reserves more than one- // viewport of scroll on phones/tablets. Desktop (≥1024px): the fixed band.+ // Reserves the fixed hero's height (desktop); 0 on narrow (hero is in flow).heroSpacer: {height: {- default: `min(var(--hero-content-height, ${HERO_BAND_HEIGHT_2COL}px), 100lvh)`,- '@media (min-width: 768px)': `min(var(--hero-content-height, ${HERO_BAND_HEIGHT_NARROW}px), 100lvh)`,+ default: 0,'@media (min-width: 1024px)': HERO_BAND_HEIGHT,},},@@ -117,10 +118,41 @@ const styles = stylex.create({borderTopRightRadius: 'var(--radius-page)',backgroundColor: 'var(--color-background-surface)',paddingBlockStart: 'var(--astryx-marketing-section-gap)',+ // Smaller than the section gap — the footer adds its own top spacing.paddingBlockEnd: spacingVars['--spacing-12'],paddingInline: spacingVars['--spacing-6'],gap: 'var(--astryx-marketing-section-gap)',},+ // Theme-switcher dots, low in the hero. Desktop: absolute so they don't+ // disturb the band's vertical centering (margin-top:auto would shift the+ // wordmark). Narrow: in flow after the collage.+ heroDots: {+ paddingBlockStart: {+ default: 0,+ '@media (min-width: 1024px)': spacingVars['--spacing-6'],+ },+ position: {+ default: 'static',+ '@media (min-width: 1024px)': 'absolute',+ },+ insetBlockEnd: {+ default: 'auto',+ // The fixed band's bottom sits a nav-height above the real seam, so+ // subtract it to land 32px above the features surface.+ '@media (min-width: 1024px)':+ 'calc(var(--spacing-8) - var(--appshell-header-height, 0px))',+ },+ insetInlineStart: {+ default: 'auto',+ '@media (min-width: 1024px)': 0,+ },+ insetInlineEnd: {+ default: 'auto',+ '@media (min-width: 1024px)': 0,+ },+ display: 'flex',+ justifyContent: 'center',+ },});// Renders hero controls (CTAs, dots) in the active slide's mode. Always renders@@ -204,16 +236,18 @@ function HeroContent({contentRef}: {contentRef: Ref<HTMLElement>}) {StyleX</Link></Text>- {/* Theme switcher dots — jump straight to any theme in the reel. */}- <DarkScope isDark={isDark}>- <HeroReelDots />- </DarkScope></VStack>{/* Narrow-screen collage — rendered inside the (fixed) hero content so it'spinned with the text and sits a consistent --hero-gap below it. Thedesktop overlap layer (HeroReelCards) hides below 1024px; thisself-hides at ≥1024px. */}<HeroReelStack />+ {/* DarkScope flips the dot ink to the active slide's light/dark mode. */}+ <DarkScope isDark={isDark}>+ <div data-home-page="true" {...stylex.props(styles.heroDots)}>+ <HeroReelDots />+ </div>+ </DarkScope></VStack>);}diff --git a/apps/docsite/src/app/globals.css b/apps/docsite/src/app/globals.cssindex b505260df1..524a114dac 100644--- a/apps/docsite/src/app/globals.css+++ b/apps/docsite/src/app/globals.css@@ -43,15 +43,17 @@ html {as a single related group. */--astryx-marketing-feature-card-bg: light-dark(#e6f0ff, #1a2333);- /* Marketing-section vertical rhythm. The XDS spacing scale tops out at- --spacing-12 = 48px, which is fine for in-app density but too tight- for a landing-page section break. Used for the gap between major- home-page sections (hero ↔ features ↔ about ↔ discover) and the- page's first paddingBlockStart so the rhythm reads as deliberate- marketing pacing rather than a maxed-out spacing step. */+ /* Spacing between major home-page sections (the XDS scale tops out at 48px,+ too tight for a section break). Shrinks on mobile (below). */--astryx-marketing-section-gap: 100px;}+@media (max-width: 767px) {+ :root {+ --astryx-marketing-section-gap: var(--spacing-12, 48px);+ }+}+/* AppShell sets a sticky top nav but its main content area sits at the sametop edge — so the first child of any page can end up covered by the nav.On every (docs)-group page (anything with a sticky AppShell header),diff --git a/apps/docsite/src/components/SiteFooter.tsx b/apps/docsite/src/components/SiteFooter.tsxindex 444ad04500..f6f5d41357 100644--- a/apps/docsite/src/components/SiteFooter.tsx+++ b/apps/docsite/src/components/SiteFooter.tsx@@ -32,7 +32,9 @@ import {const styles = stylex.create({siteFooter: {- paddingTop: 'calc(var(--spacing-12) * 2)',+ // Match the section rhythm above (responsive); fall back off the home page.+ paddingTop:+ 'var(--astryx-marketing-section-gap, calc(var(--spacing-12) * 2))',},astryxLogo: {height: 18,diff --git a/apps/docsite/src/themes/astryxTheme.ts b/apps/docsite/src/themes/astryxTheme.tsindex fe22244afc..760208b149 100644--- a/apps/docsite/src/themes/astryxTheme.ts+++ b/apps/docsite/src/themes/astryxTheme.ts@@ -49,6 +49,11 @@ const PRIMARY_MUTED =// to the UI here as the custom CSS variable --color-brand (see the token block// below), so consumers can reference the brand blue via var(--color-brand).+// Custom (non-core) token. Typed const, not an inline cast, per lint rule.+const customTokens: Record<string, TokenValue> = {+ '--color-brand': BRAND_BLUE,+};+export const astryxTheme = defineTheme({name: 'astryx',@@ -100,11 +105,7 @@ export const astryxTheme = defineTheme({'--radius-container': '16px','--radius-page': '32px',- // --- Custom brand color token ---- // Not a core XDS token, so it's spread in with a cast to allow the extra- // key while keeping the standard tokens above type-checked. Exposed to the- // UI as var(--color-brand).- ...({'--color-brand': BRAND_BLUE} as Record<string, TokenValue>),+ ...customTokens,},typography: {@@ -141,5 +142,38 @@ export const astryxTheme = defineTheme({},},},+ // Hero carousel dots: outlined rings + a filled active pill (overrides the+ // core `dots` solid circles). --color-accent flips to light ink on dark+ // slides, so the dots stay legible in both modes.+ 'pagination-dot': {+ base: {+ // 10px is off-scale on purpose (no token between 8px and 12px).+ width: '10px',+ height: '10px',+ backgroundColor: 'transparent',+ borderWidth: '2px',+ borderStyle: 'solid',+ // Translucent accent (not a static gray) so it tracks the theme ink.+ borderColor: 'color-mix(in srgb, var(--color-accent) 60%, transparent)',+ boxSizing: 'border-box',+ transitionProperty: 'width, background-color, border-color',+ transitionDuration: 'var(--duration-fast)',+ transitionTimingFunction: 'var(--ease-standard)',+ ':hover': {+ backgroundColor: 'var(--color-accent-muted)',+ },+ },+ active: {+ width: 'var(--spacing-7)',+ backgroundColor: 'var(--color-accent)',+ borderColor: 'var(--color-accent)',+ borderRadius: 'var(--radius-full)',+ // Re-assert the solid fill so the active pill ignores the base ring's+ // muted hover.+ ':hover': {+ backgroundColor: 'var(--color-accent)',+ },+ },+ },},});