An open source design system that's fully customizable and agent ready
TypeScript
fix(docsite): inherit site theme mode in ExampleBlock and InteractivePreview (#2392)
Kenton Quatman054fc1676cca
diff --git a/apps/docsite/src/components/component-detail/ExampleBlock.tsx b/apps/docsite/src/components/component-detail/ExampleBlock.tsxindex a6ad29a183..c2ae5d5748 100644--- a/apps/docsite/src/components/component-detail/ExampleBlock.tsx+++ b/apps/docsite/src/components/component-detail/ExampleBlock.tsx@@ -14,10 +14,12 @@ import {XDSButton} from '@xds/core/Button';import {XDSHStack} from '@xds/core/Layout';import {XDSTheme} from '@xds/core/theme';import {neutralTheme} from '@xds/theme-neutral/built';+import {useThemeMode} from '../../app/providers';import type {ExampleEntry} from '../../generated/exampleRegistry';import {buildPlaygroundHref} from '../playgroundLink';function LivePreview({entry}: {entry: ExampleEntry}) {+ const {mode} = useThemeMode();const [Component, setComponent] = useState<ComponentType | null>(null);const [error, setError] = useState(false);@@ -47,7 +49,7 @@ function LivePreview({entry}: {entry: ExampleEntry}) {}return (- <XDSTheme theme={neutralTheme}>+ <XDSTheme theme={neutralTheme} mode={mode}><divstyle={{width: '100%',diff --git a/apps/docsite/src/components/component-detail/InteractivePreview.tsx b/apps/docsite/src/components/component-detail/InteractivePreview.tsxindex 70879fab12..d7d1f97c12 100644--- a/apps/docsite/src/components/component-detail/InteractivePreview.tsx+++ b/apps/docsite/src/components/component-detail/InteractivePreview.tsx@@ -20,6 +20,7 @@ import {XDSVStack} from '@xds/core/Layout';import {XDSText} from '@xds/core/Text';import {XDSTheme} from '@xds/core/theme';import {neutralTheme} from '@xds/theme-neutral/built';+import {useThemeMode} from '../../app/providers';import {CodeBracketIcon} from '@heroicons/react/24/outline';import {coerceDefault,@@ -233,6 +234,7 @@ export function InteractivePreviewStage({name: string;state: Record<string, unknown>;}) {+ const {mode} = useThemeMode();const [showCode, setShowCode] = useState(false);const Component = getXDSComponent(name);@@ -293,7 +295,7 @@ export function InteractivePreviewStage({<XDSCodeBlock code={code} language="tsx" hasCopyButton /></div>) : (- <XDSTheme theme={neutralTheme}>+ <XDSTheme theme={neutralTheme} mode={mode}><XDSCenterstyle={{minHeight: 200,