import { useEffect, type ReactNode } from 'react' import { applyPalette } from '../src/theme/applyPalette' import type { PaletteName } from '../src/theme/palettes' /** * Applies the toolbar's palette and light/dark mode to . * * It has to be the root element, not a wrapper: Base UI renders popups (menus, * selects, dialogs, toasts) into a portal on document.body, and they must pick * up the same tokens as the story. */ export function ThemeSurface({ palette, mode, padded, children, }: { palette: PaletteName mode: 'light' | 'dark' padded: boolean children: ReactNode }) { useEffect(() => { const root = document.documentElement applyPalette(root, palette) root.classList.toggle('dark', mode === 'dark') root.dataset.palette = palette document.body.style.background = 'var(--color-background)' document.body.style.color = 'var(--color-fg)' }, [palette, mode]) return
{children}
}