(null)
const [seams] = useState(() => ({
persistence: inMemoryPersistence(),
resolver: makeFakeResolver("dark"),
}))
return (
{
panelRef.current?.setAttribute(
"data-scheme",
resolvedScheme,
)
}}
icons={ICONS}
persistence={seams.persistence}
resolver={seams.resolver}
/>
This panel follows the switcher.
)
}
const meta = {
title: "Utilities/ColorSchemeSwitcher",
component: ColorSchemeSwitcher,
parameters: { layout: "padded" },
// The three injected seams are functions/objects, not values a
// Controls panel can render — `react-docgen` sees them as opaque
// names from `@charcuterie/logic`. Disabled explicitly rather than
// left to fall through to the object control.
argTypes: {
apply: { control: false },
persistence: { control: false },
resolver: { control: false },
},
args: {
icons: ICONS,
},
} satisfies Meta
export default meta
type Story = StoryObj
/**
* Connected: the switcher builds its own state through
* `useColorScheme` and applies the resolved scheme. Here the OS
* resolver and persistence are injected fakes and the applier is
* scoped to the demo panel, which is exactly how a non-browser host
* (Electron `nativeTheme`) wires it — by replacing those seams.
*/
export const Playground: Story = {
parameters: playgroundParameters,
render: () => ,
}