Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(docsite): use app shell for playground (#2778)

Cindy Zhang5cb929bf31dc
diff --git a/apps/docsite/src/app/globals.css b/apps/docsite/src/app/globals.css
index 13849acdfd..3c5dc07613 100644
--- a/apps/docsite/src/app/globals.css
+++ b/apps/docsite/src/app/globals.css
@@ -48,7 +48,7 @@
it measures the rendered header (post-hydration). The 64px fallback
approximates the default XDS top-nav height so the layout reserves
space immediately on the first paint. */
-#xds-app-shell-main {
+body:not(:has([data-playground-page])) #xds-app-shell-main {
scroll-padding-top: var(--appshell-header-height, 64px);
padding-top: var(--appshell-header-height, 64px);
}
diff --git a/apps/docsite/src/app/playground/PlaygroundClient.tsx b/apps/docsite/src/app/playground/PlaygroundClient.tsx
index 7e5cf3a767..700b37336c 100644
--- a/apps/docsite/src/app/playground/PlaygroundClient.tsx
+++ b/apps/docsite/src/app/playground/PlaygroundClient.tsx
@@ -6,7 +6,8 @@
* @output Full-page two-panel playground (editor + live preview)
* @position app/playground — the interactive XDS code playground.
*
- * Sidebar: icon-only nav strip — back, Code view, Properties view.
+ * AppShell: side-nav-only shell; desktop nav is controlled collapsed to
+ * an icon rail while AppShell owns the mobile top bar and drawer.
* Left panel: Monaco editor (Code) or knobs (Properties).
* - Code: Monaco editor (controlled) with real XDS .d.ts typedefs.
* - Property: component selector + instance picker + knobs that edit the code.
@@ -30,11 +31,18 @@ import {
compressToEncodedURIComponent,
decompressFromEncodedURIComponent,
} from 'lz-string';
+import {XDSAppShell} from '@xds/core/AppShell';
import {XDSButton} from '@xds/core/Button';
-import {XDSPopover} from '@xds/core/Popover';
-import {XDSTextInput} from '@xds/core/TextInput';
import {XDSLink} from '@xds/core/Link';
import {XDSHStack, XDSVStack} from '@xds/core/Layout';
+import {XDSPopover} from '@xds/core/Popover';
+import {XDSTextInput} from '@xds/core/TextInput';
+import {
+ XDSSideNav,
+ XDSSideNavHeading,
+ XDSSideNavItem,
+ XDSSideNavSection,
+} from '@xds/core/SideNav';
import {XDSText, XDSHeading} from '@xds/core/Text';
import {XDSStatusDot} from '@xds/core/StatusDot';
import {XDSToolbar} from '@xds/core/Toolbar';
@@ -42,11 +50,18 @@ import {
XDSSegmentedControl,
XDSSegmentedControlItem,
} from '@xds/core/SegmentedControl';
+import {XDSTab, XDSTabList} from '@xds/core/TabList';
+import {XDSTopNav, XDSTopNavHeading} from '@xds/core/TopNav';
import {XDSDropdownMenu} from '@xds/core/DropdownMenu';
+import {useMediaQuery} from '@xds/core/hooks';
import {useXDSResizable, XDSResizeHandle} from '@xds/core/Resizable';
-import {XDSToggleButton, XDSToggleButtonGroup} from '@xds/core/ToggleButton';
+import {XDSToggleButton} from '@xds/core/ToggleButton';
import {
+ Check,
Code2,
+ Copy,
+ Download,
+ ExternalLink,
Moon,
Palette,
SlidersHorizontal,
@@ -56,10 +71,6 @@ import {
Maximize2,
RotateCw,
Crosshair,
- ExternalLink,
- Copy,
- Check,
- Download,
} from 'lucide-react';
import githubLight from './themes/github-light.json';
import githubDark from './themes/github-dark.json';
@@ -281,7 +292,9 @@ function configureMonaco(monaco: MonacoInstance) {
}
type LeftView = 'code' | 'property' | 'theme';
+type MobileTopTab = 'preview' | 'code' | 'property' | 'theme';
type BuildStatus = 'idle' | 'building' | 'finished' | 'error';
+const MOBILE_BREAKPOINT_QUERY = '(max-width: 768px)';
const BUILD_STATUS_META: Record<
Exclude<BuildStatus, 'idle'>,
@@ -302,27 +315,22 @@ const s = stylex.create({
popoverPadding: {
padding: 'var(--spacing-4)',
},
- navGroup: {
- gap: 'var(--spacing-2)',
- },
root: {
flex: 1,
minWidth: 0,
+ width: '100%',
+ maxWidth: '100%',
overflow: 'hidden',
backgroundColor: 'var(--color-background-surface)',
},
- sidebar: {
- flexShrink: 0,
- backgroundColor: 'var(--color-background-surface)',
- borderInlineEndWidth: '1px',
- borderInlineEndStyle: 'solid',
- borderInlineEndColor: 'var(--color-border)',
- padding: 'var(--spacing-3)',
- },
leftPanel: {
- flexShrink: 0,
+ flexShrink: {
+ default: 0,
+ '@media (max-width: 768px)': 1,
+ },
overflow: 'hidden',
minWidth: 0,
+ maxWidth: '100%',
},
leftPanelHeader: {
flexShrink: 0,
@@ -352,6 +360,8 @@ const s = stylex.create({
rightPanel: {
flex: 1,
minWidth: 0,
+ width: '100%',
+ maxWidth: '100%',
overflow: 'hidden',
backgroundColor: 'var(--color-background-muted)',
},
@@ -363,9 +373,26 @@ const s = stylex.create({
transitionDuration: '0.5s',
transitionTimingFunction: 'ease',
},
+ sideNavHeading: {
+ paddingInline: {
+ default: null,
+ '@media (min-width: 769px)': 'var(--spacing-1)',
+ },
+ },
+ desktopCollapsedSideNav: {
+ width: {
+ default: null,
+ '@media (min-width: 769px)': 'calc(var(--spacing-12) + var(--spacing-2))',
+ },
+ },
});
-export function PlaygroundClient() {
+interface PlaygroundClientProps {
+ defaultIsMobile?: boolean;
+}
+
+export function PlaygroundClient({defaultIsMobile}: PlaygroundClientProps) {
+ const isMobile = useMediaQuery(MOBILE_BREAKPOINT_QUERY, defaultIsMobile);
// The editor chrome follows the docsite's own light/dark mode, not the OS
// (operator) color-scheme preference.
const {mode: siteMode} = useThemeMode();
@@ -392,6 +419,7 @@ export function PlaygroundClient() {
const editorInitialTheme =
themeByValue[selectedTheme] ?? themeByValue[DEFAULT_PLAYGROUND_THEME];
const [activeView, setActiveView] = useState<LeftView>('code');
+ const [mobileTab, setMobileTab] = useState<MobileTopTab>('code');
const [viewport, setViewport] = useState<Viewport>('desktop');
const [isFullscreen, setIsFullscreen] = useState(false);
const [isResizing, setIsResizing] = useState(false);
@@ -867,80 +895,162 @@ export function PlaygroundClient() {
[],
);
- return (
- <XDSHStack align="stretch" height="100%" width="100%">
- {/* Playground navigation */}
- <XDSVStack align="center" xstyle={s.sidebar} gap={4}>
- <XDSLink href="/" label="Go to home">
- {BRAND_ICON}
- </XDSLink>
- <XDSToggleButtonGroup
- type="single"
- orientation="vertical"
- label="Playground view"
- value={activeView}
- // Single-select groups allow deselecting to null; guard against it so
- // one view is always active.
- onChange={v => v && setActiveView(v as LeftView)}
- size="md"
- xstyle={s.navGroup}>
- <XDSToggleButton
+ const handleMobileTabChange = useCallback((tab: MobileTopTab) => {
+ setMobileTab(tab);
+ if (tab === 'code' || tab === 'property' || tab === 'theme') {
+ setActiveView(tab);
+ }
+ }, []);
+
+ const togglePreviewMode = useCallback(() => {
+ setMode(m => (m === 'light' ? 'dark' : 'light'));
+ }, []);
+
+ const expandPreview = useCallback(() => {
+ setIsFullscreen(true);
+ }, []);
+
+ const mobileTopNav = isMobile ? (
+ <XDSTopNav
+ label="Playground navigation"
+ heading={<XDSTopNavHeading logo={BRAND_ICON} headingHref="/" />}
+ centerContent={
+ <XDSTabList
+ value={mobileTab}
+ onChange={value => handleMobileTabChange(value as MobileTopTab)}
+ size="sm">
+ <XDSTab
+ value="preview"
+ label="Preview"
+ icon={<Monitor size={14} />}
+ isLabelHidden
+ />
+ <XDSTab
value="code"
label="Code"
- tooltip="Code"
- isIconOnly
- icon={<Code2 size={20} />}
+ icon={<Code2 size={14} />}
+ isLabelHidden
/>
- <XDSToggleButton
+ <XDSTab
value="property"
label="Properties"
- tooltip="Properties"
- isIconOnly
- icon={<SlidersHorizontal size={20} />}
+ icon={<SlidersHorizontal size={14} />}
+ isLabelHidden
/>
- <XDSToggleButton
+ <XDSTab
value="theme"
label="Theme"
- tooltip="Theme"
- isIconOnly
- icon={<Palette size={20} />}
+ icon={<Palette size={14} />}
+ isLabelHidden
/>
- </XDSToggleButtonGroup>
- </XDSVStack>
+ </XDSTabList>
+ }
+ endContent={
+ <XDSButton
+ label={copied ? '✓ Copied' : 'Share'}
+ variant="primary"
+ size="md"
+ onClick={handleShare}
+ />
+ }
+ />
+ ) : undefined;
+ const playgroundSideNav = (
+ <XDSSideNav
+ header={
+ <XDSSideNavHeading
+ icon={BRAND_ICON}
+ heading="Playground"
+ headingHref="/"
+ xstyle={s.sideNavHeading}
+ />
+ }
+ collapsible={{isCollapsed: true, hasButton: false}}
+ xstyle={s.desktopCollapsedSideNav}>
+ <XDSSideNavSection title="Playground views" isHeaderHidden>
+ <XDSSideNavItem
+ label="Code"
+ icon={Code2}
+ isSelected={activeView === 'code'}
+ onClick={() => {
+ setActiveView('code');
+ setMobileTab('code');
+ }}
+ />
+ <XDSSideNavItem
+ label="Properties"
+ icon={SlidersHorizontal}
+ isSelected={activeView === 'property'}
+ onClick={() => {
+ setActiveView('property');
+ setMobileTab('property');
+ }}
+ />
+ <XDSSideNavItem
+ label="Theme"
+ icon={Palette}
+ isSelected={activeView === 'theme'}
+ onClick={() => {
+ setActiveView('theme');
+ setMobileTab('theme');
+ }}
+ />
+ </XDSSideNavSection>
+ </XDSSideNav>
+ );
+
+ const showEditorPanel = !isMobile || mobileTab !== 'preview';
+ const showPreviewPanel = !isMobile || mobileTab === 'preview';
+
+ return (
+ <XDSAppShell
+ variant="section"
+ height="fill"
+ contentPadding={0}
+ mobileNav={isMobile ? false : {defaultIsMobile}}
+ topNav={mobileTopNav}
+ sideNav={playgroundSideNav}>
{/* Playground content */}
<XDSHStack
+ data-playground-page="true"
+ align="stretch"
height="100%"
+ width="100%"
xstyle={s.root}
onPointerDownCapture={handleResizeProbe}>
{/* Left panel — editor */}
- <XDSVStack xstyle={s.leftPanel} width={editorPanel.size || 440}>
- <XDSHStack
- justify="between"
- align="center"
- xstyle={s.leftPanelHeader}>
- <XDSHeading level={3}>Playground</XDSHeading>
- <XDSHStack gap={2} align="center">
- <XDSDropdownMenu
- button={{
- label: 'Themes',
- variant: 'secondary',
- size: 'md',
- }}
- hasChevron
- items={themeMenuItems}
- />
- <XDSDropdownMenu
- button={{
- label: 'Templates',
- variant: 'secondary',
- size: 'md',
- }}
- hasChevron
- items={templateMenuItems}
- />
+ <XDSVStack
+ xstyle={[s.leftPanel, !showEditorPanel && s.hidden]}
+ width={isMobile ? '100%' : editorPanel.size || 440}>
+ {!isMobile && (
+ <XDSHStack
+ justify="between"
+ align="center"
+ xstyle={s.leftPanelHeader}>
+ <XDSHeading level={3}>Playground</XDSHeading>
+ <XDSHStack gap={2} align="center">
+ <XDSDropdownMenu
+ button={{
+ label: 'Themes',
+ variant: 'secondary',
+ size: 'md',
+ }}
+ hasChevron
+ items={themeMenuItems}
+ />
+ <XDSDropdownMenu
+ button={{
+ label: 'Templates',
+ variant: 'secondary',
+ size: 'md',
+ }}
+ hasChevron
+ items={templateMenuItems}
+ />
+ </XDSHStack>
</XDSHStack>
- </XDSHStack>
+ )}
<div {...stylex.props(s.tabBody)}>
{/* Code: Monaco stays mounted to preserve typedefs + editor state */}
<div
@@ -995,212 +1105,219 @@ export function PlaygroundClient() {
</div>
</XDSVStack>
- <XDSResizeHandle
- label="Resize editor panel"
- resizable={editorPanel.props}
- pillPlacement="center"
- hasDivider
- />
+ {!isMobile && (
+ <XDSResizeHandle
+ label="Resize editor panel"
+ resizable={editorPanel.props}
+ pillPlacement="center"
+ hasDivider
+ />
+ )}
{/* Right panel — preview */}
- <XDSVStack xstyle={s.rightPanel}>
- <XDSToolbar
- label="Preview controls"
- startContent={
- <XDSToggleButton
- label="Target element"
- tooltip={
- isTargeting
- ? 'Exit targeting (Esc)'
- : 'Click to select an element'
- }
- isPressed={isTargeting}
- onPressedChange={toggleTargeting}
- size="md"
- isIconOnly
- icon={<Crosshair size={20} />}
- />
- }
- centerContent={
- <XDSHStack gap={2} vAlign="center">
- <XDSButton
- label={
- mode === 'light' ? 'Switch to dark' : 'Switch to light'
+ <XDSVStack xstyle={[s.rightPanel, !showPreviewPanel && s.hidden]}>
+ {!isMobile && (
+ <XDSToolbar
+ label="Preview controls"
+ startContent={
+ <XDSToggleButton
+ label="Target element"
+ tooltip={
+ isTargeting
+ ? 'Exit targeting (Esc)'
+ : 'Click to select an element'
}
- tooltip={mode === 'light' ? 'Dark mode' : 'Light mode'}
- variant="ghost"
+ isPressed={isTargeting}
+ onPressedChange={toggleTargeting}
size="md"
isIconOnly
- icon={
- mode === 'light' ? <Moon size={20} /> : <Sun size={20} />
- }
- onClick={() =>
- setMode(m => (m === 'light' ? 'dark' : 'light'))
- }
+ icon={<Crosshair size={20} />}
/>
- <XDSSegmentedControl
- label="Viewport size"
- size="md"
- value={viewport}
- onChange={v => setViewport(v as Viewport)}>
- <XDSSegmentedControlItem
- value="desktop"
- label="Desktop"
- isLabelHidden
- icon={<Monitor size={20} />}
- />
- <XDSSegmentedControlItem
- value="phone"
- label="Phone"
- isLabelHidden
- icon={<Smartphone size={20} />}
+ }
+ centerContent={
+ <XDSHStack gap={2} vAlign="center">
+ <XDSButton
+ label={
+ mode === 'light' ? 'Switch to dark' : 'Switch to light'
+ }
+ tooltip={mode === 'light' ? 'Dark mode' : 'Light mode'}
+ variant="ghost"
+ size="md"
+ isIconOnly
+ icon={
+ mode === 'light' ? <Moon size={20} /> : <Sun size={20} />
+ }
+ onClick={togglePreviewMode}
/>
- </XDSSegmentedControl>
- <XDSButton
- label="Expand"
- tooltip="Fullscreen preview"
- variant="ghost"
- size="md"
- isIconOnly
- icon={<Maximize2 size={20} />}
- onClick={() => setIsFullscreen(true)}
- />
- </XDSHStack>
- }
- endContent={
- <XDSHStack gap={4} vAlign="center">
- {buildStatus !== 'idle' && (
- <div
- {...stylex.props(s.buildStatus)}
- style={{opacity: statusFading ? 0 : 1}}>
- <XDSStatusDot
- variant={BUILD_STATUS_META[buildStatus].variant}
- label={BUILD_STATUS_META[buildStatus].label}
- isPulsing={buildStatus === 'building'}
+ <XDSSegmentedControl
+ label="Viewport size"
+ size="md"
+ value={viewport}
+ onChange={v => setViewport(v as Viewport)}>
+ <XDSSegmentedControlItem
+ value="desktop"
+ label="Desktop"
+ isLabelHidden
+ icon={<Monitor size={20} />}
/>
- <XDSText type="supporting" color="secondary">
- {BUILD_STATUS_META[buildStatus].label}
- </XDSText>
- {buildStatus === 'error' && (
- <XDSButton
- label="Rebuild"
- tooltip="Rebuild"
- variant="ghost"
- size="sm"
- isIconOnly
- icon={<RotateCw size={16} />}
- onClick={handleRebuild}
- />
- )}
- </div>
- )}
- <XDSPopover
- label="Share template"
- placement="below"
- alignment="end"
- xstyle={s.popoverPadding}
- onOpenChange={open => {
- if (open) {
- setShareUrl(window.location.href);
- // Snapshot the live (ref-held) theme so the download
- // link below can derive its href from reactive state.
- setExportTheme(
- customThemeRef.current ?? editorInitialTheme,
- );
- }
- }}
- content={
- <XDSVStack gap={6}>
- <XDSVStack gap={2}>
- <XDSText type="label" weight="semibold">
- Share Playground
- </XDSText>
- <XDSHStack gap={2} vAlign="center" width="100%">
- <XDSTextInput
- label="Share URL"
- isLabelHidden
- isDisabled
- value={shareUrl}
- onChange={() => {}}
- xstyle={s.shareInput}
- />
- <XDSButton
- label={copied ? 'Copied' : 'Copy URL'}
- tooltip={copied ? 'Copied' : 'Copy URL'}
- variant="secondary"
- size="md"
- isIconOnly
- icon={
- copied ? <Check size={16} /> : <Copy size={16} />
- }
- onClick={handleShare}
- />
- </XDSHStack>
- </XDSVStack>
- <XDSVStack gap={2}>
- <XDSText type="label" weight="semibold">
- Export Theme File
- </XDSText>
- <XDSHStack gap={2} vAlign="center" width="100%">
- <XDSTextInput
- label="Theme name"
- isLabelHidden
- placeholder="Enter theme name"
- value={themeName}
- onChange={v =>
- setThemeName(v.replace(/[\s-]/g, ''))
- }
- xstyle={s.shareInput}
- />
- <XDSButton
- label="Download theme"
- tooltip="Download theme"
- variant="secondary"
- size="md"
- isIconOnly
- isDisabled={themeExport == null}
- icon={<Download size={16} />}
- onClick={() => downloadLinkRef.current?.click()}
- />
- {/* The real download target: a normally-rendered
- link whose href/download come from reactive
- state. The button above clicks it, so the
- browser performs a native download without us
- fabricating an <a> in the handler. */}
- {themeExport && (
- <a
- ref={downloadLinkRef}
- href={themeExport.href}
- download={themeExport.filename}
- {...stylex.props(s.hidden)}
- aria-hidden="true"
- tabIndex={-1}>
- Download theme file
- </a>
- )}
- </XDSHStack>
- <XDSLink href="/docs/theme" hasUnderline>
- Learn about using themes
- </XDSLink>
- </XDSVStack>
- </XDSVStack>
- }>
+ <XDSSegmentedControlItem
+ value="phone"
+ label="Phone"
+ isLabelHidden
+ icon={<Smartphone size={20} />}
+ />
+ </XDSSegmentedControl>
<XDSButton
- label="Export"
- variant="primary"
+ label="Expand"
+ tooltip="Fullscreen preview"
+ variant="ghost"
size="md"
- endContent={<ExternalLink size={16} />}
+ isIconOnly
+ icon={<Maximize2 size={20} />}
+ onClick={expandPreview}
/>
- </XDSPopover>
- </XDSHStack>
- }
- />
+ </XDSHStack>
+ }
+ endContent={
+ <XDSHStack gap={4} vAlign="center">
+ {buildStatus !== 'idle' && (
+ <div
+ {...stylex.props(s.buildStatus)}
+ style={{opacity: statusFading ? 0 : 1}}>
+ <XDSStatusDot
+ variant={BUILD_STATUS_META[buildStatus].variant}
+ label={BUILD_STATUS_META[buildStatus].label}
+ isPulsing={buildStatus === 'building'}
+ />
+ <XDSText type="supporting" color="secondary">
+ {BUILD_STATUS_META[buildStatus].label}
+ </XDSText>
+ {buildStatus === 'error' && (
+ <XDSButton
+ label="Rebuild"
+ tooltip="Rebuild"
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ icon={<RotateCw size={16} />}
+ onClick={handleRebuild}
+ />
+ )}
+ </div>
+ )}
+ <XDSPopover
+ label="Share template"
+ placement="below"
+ alignment="end"
+ xstyle={s.popoverPadding}
+ onOpenChange={open => {
+ if (open) {
+ setShareUrl(window.location.href);
+ // Snapshot the live (ref-held) theme so the download
+ // link below can derive its href from reactive state.
+ setExportTheme(
+ customThemeRef.current ?? editorInitialTheme,
+ );
+ }
+ }}
+ content={
+ <XDSVStack gap={6}>
+ <XDSVStack gap={2}>
+ <XDSText type="label" weight="semibold">
+ Share Playground
+ </XDSText>
+ <XDSHStack gap={2} vAlign="center" width="100%">
+ <XDSTextInput
+ label="Share URL"
+ isLabelHidden
+ isDisabled
+ value={shareUrl}
+ onChange={() => {}}
+ xstyle={s.shareInput}
+ />
+ <XDSButton
+ label={copied ? 'Copied' : 'Copy URL'}
+ tooltip={copied ? 'Copied' : 'Copy URL'}
+ variant="secondary"
+ size="md"
+ isIconOnly
+ icon={
+ copied ? (
+ <Check size={16} />
+ ) : (
+ <Copy size={16} />
+ )
+ }
+ onClick={handleShare}
+ />
+ </XDSHStack>
+ </XDSVStack>
+ <XDSVStack gap={2}>
+ <XDSText type="label" weight="semibold">
+ Export Theme File
+ </XDSText>
+ <XDSHStack gap={2} vAlign="center" width="100%">
+ <XDSTextInput
+ label="Theme name"
+ isLabelHidden
+ placeholder="Enter theme name"
+ value={themeName}
+ onChange={v =>
+ setThemeName(v.replace(/[\s-]/g, ''))
+ }
+ xstyle={s.shareInput}
+ />
+ <XDSButton
+ label="Download theme"
+ tooltip="Download theme"
+ variant="secondary"
+ size="md"
+ isIconOnly
+ isDisabled={themeExport == null}
+ icon={<Download size={16} />}
+ onClick={() => downloadLinkRef.current?.click()}
+ />
+ {/* The real download target: a normally-rendered
+ link whose href/download come from reactive
+ state. The button above clicks it, so the
+ browser performs a native download without us
+ fabricating an <a> in the handler. */}
+ {themeExport && (
+ <a
+ ref={downloadLinkRef}
+ href={themeExport.href}
+ download={themeExport.filename}
+ {...stylex.props(s.hidden)}
+ aria-hidden="true"
+ tabIndex={-1}>
+ Download theme file
+ </a>
+ )}
+ </XDSHStack>
+ <XDSLink href="/docs/theme" hasUnderline>
+ Learn about using themes
+ </XDSLink>
+ </XDSVStack>
+ </XDSVStack>
+ }>
+ <XDSButton
+ label="Export"
+ variant="primary"
+ size="md"
+ endContent={<ExternalLink size={16} />}
+ />
+ </XDSPopover>
+ </XDSHStack>
+ }
+ />
+ )}
<PreviewStage
- viewport={viewport}
+ viewport={isMobile ? 'phone' : viewport}
isFullscreen={isFullscreen}
onExitFullscreen={() => setIsFullscreen(false)}
iframeRef={iframeRef}
isInteractionDisabled={isResizing}
+ isFullBleed={isMobile}
/>
</XDSVStack>
</XDSHStack>
@@ -1230,6 +1347,6 @@ export function PlaygroundClient() {
setPendingTemplateSource(null);
}}
/>
- </XDSHStack>
+ </XDSAppShell>
);
}
diff --git a/apps/docsite/src/app/playground/PreviewStage.tsx b/apps/docsite/src/app/playground/PreviewStage.tsx
index b2734ca3c1..367a68efdf 100644
--- a/apps/docsite/src/app/playground/PreviewStage.tsx
+++ b/apps/docsite/src/app/playground/PreviewStage.tsx
@@ -38,6 +38,11 @@ const s = stylex.create({
paddingBlockEnd: 'var(--spacing-4)',
paddingBlockStart: 0,
},
+ areaFullBleed: {
+ paddingInline: 0,
+ paddingBlockEnd: 0,
+ paddingBlockStart: 0,
+ },
areaCenter: {
alignItems: 'center',
},
@@ -56,6 +61,12 @@ const s = stylex.create({
borderWidth: 0,
boxShadow: 'none',
},
+ cardFullBleed: {
+ flex: 1,
+ minHeight: 0,
+ width: '100%',
+ height: '100%',
+ },
card: {
maxWidth: '100%',
maxHeight: '100%',
@@ -95,6 +106,8 @@ interface PreviewStageProps {
iframeRef: React.RefObject<HTMLIFrameElement | null>;
/** Disable iframe pointer events (e.g. while the panel is being resized). */
isInteractionDisabled?: boolean;
+ /** Render the iframe directly, without the preview card/device frame. */
+ isFullBleed?: boolean;
}
export function PreviewStage({
@@ -103,8 +116,9 @@ export function PreviewStage({
onExitFullscreen,
iframeRef,
isInteractionDisabled = false,
+ isFullBleed = false,
}: PreviewStageProps) {
- const isPhone = !isFullscreen && viewport === 'phone';
+ const isPhone = !isFullscreen && !isFullBleed && viewport === 'phone';
const width = isPhone ? PHONE_WIDTH : '100%';
const height = isPhone ? PHONE_HEIGHT : '100%';
@@ -112,6 +126,7 @@ export function PreviewStage({
<div
{...stylex.props(
s.area,
+ isFullBleed && !isFullscreen && s.areaFullBleed,
isPhone && s.areaCenter,
isFullscreen && s.fullscreen,
)}>
@@ -130,7 +145,11 @@ export function PreviewStage({
)}
<XDSCard
padding={0}
- xstyle={[s.card, isFullscreen && s.cardFullscreen]}
+ xstyle={[
+ s.card,
+ (isFullscreen || isFullBleed) && s.cardFullscreen,
+ isFullBleed && !isFullscreen && s.cardFullBleed,
+ ]}
style={{width, height}}>
<iframe
ref={iframeRef}
diff --git a/apps/docsite/src/app/playground/layout.tsx b/apps/docsite/src/app/playground/layout.tsx
index b27549e2c7..e24d33c42c 100644
--- a/apps/docsite/src/app/playground/layout.tsx
+++ b/apps/docsite/src/app/playground/layout.tsx
@@ -2,14 +2,14 @@
/**
* Page type: playground (full-bleed tool)
- * Renders the interactive code playground full-screen with no marketing top
- * nav / footer chrome — a left editor panel and a right live-preview panel.
+ * The PlaygroundClient owns its XDSAppShell so its stateful side navigation
+ * can drive Code / Properties / Theme tabs and still get AppShell mobile nav.
* Theme context is provided by the root <Providers> (app/providers.tsx), so
- * this layout only needs to establish a full-viewport, overflow-hidden frame.
+ * this route layout intentionally adds no extra chrome or scroll container.
*
* @input children — the PlaygroundClient tree
- * @output Full-height surface container
- * @position app/playground layout wrapper
+ * @output Children unchanged; PlaygroundClient provides the full-height shell
+ * @position app/playground route layout
*/
export default function PlaygroundLayout({
@@ -17,14 +17,5 @@ export default function PlaygroundLayout({
}: {
children: React.ReactNode;
}) {
- return (
- <div
- style={{
- height: '100vh',
- overflow: 'hidden',
- backgroundColor: 'var(--color-background-surface)',
- }}>
- {children}
- </div>
- );
+ return children;
}
diff --git a/apps/docsite/src/app/playground/page.tsx b/apps/docsite/src/app/playground/page.tsx
index 845abd2b7b..247b65ad26 100644
--- a/apps/docsite/src/app/playground/page.tsx
+++ b/apps/docsite/src/app/playground/page.tsx
@@ -2,6 +2,7 @@
import type {Metadata} from 'next';
import {Suspense} from 'react';
+import {headers} from 'next/headers';
import {PlaygroundClient} from './PlaygroundClient';
export const metadata: Metadata = {
@@ -9,10 +10,14 @@ export const metadata: Metadata = {
description: 'Interactive code playground for Astryx components',
};
-export default function PlaygroundPage() {
+export default async function PlaygroundPage() {
+ const headersList = await headers();
+ const ua = headersList.get('user-agent') ?? '';
+ const defaultIsMobile = /mobile|android|iphone|ipad/i.test(ua);
+
return (
<Suspense fallback={null}>
- <PlaygroundClient />
+ <PlaygroundClient defaultIsMobile={defaultIsMobile} />
</Suspense>
);
}