Skip to content

Commit e28bc85

Browse files
committed
fix(storybook): dark background for docs component previews
In dark mode the docs component preview now uses a dark background to match the dark-rendered component, while the rest of the docs chrome stays light. Removes the custom DocsContainer, which threw a 'combining Storybook hooks with framework hooks' runtime error and themed the whole docs page (clashing with light prose and tables).
1 parent c202aff commit e28bc85

4 files changed

Lines changed: 18 additions & 23 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@repo/storybook": patch
3+
---
4+
5+
Fix docs dark mode. The component preview on a docs page now gets a dark
6+
background in dark mode (matching the dark-rendered component), while the rest
7+
of the docs chrome stays light. Removes the custom docs `DocsContainer`, which
8+
threw a "combining Storybook hooks with framework hooks" runtime error and
9+
themed the whole docs page (clashing with the light prose and tables).

apps/storybook/.storybook/preview.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Preview } from 'storybook-react-rsbuild'
22
import { ThemeProvider } from '@datum-cloud/datum-ui/theme'
33
import { useEffect } from 'react'
4-
import { ThemedDocsContainer } from './themed-docs-container'
54
import { datumViewports } from './viewport'
65
import '../stories/storybook.css'
76

@@ -47,9 +46,6 @@ const preview: Preview = {
4746
},
4847
],
4948
parameters: {
50-
docs: {
51-
container: ThemedDocsContainer,
52-
},
5349
viewport: {
5450
viewports: datumViewports,
5551
},

apps/storybook/.storybook/themed-docs-container.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

apps/storybook/stories/storybook.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@
3737
* --watch wipes dist before re-emitting hashed chunks. Storybook-only;
3838
* does not affect what's published to npm. */
3939
@source "../../../packages/datum-ui/src/**/*.{ts,tsx}";
40+
41+
/* Docs dark mode: the preview decorator sets the `dark` class on the docs root
42+
* when the `theme` global is dark, so the rendered component is dark. Give just
43+
* the component preview surface a matching dark background; the rest of the docs
44+
* chrome stays light. Colour matches datumDark appContentBg. */
45+
html.dark .sbdocs-preview,
46+
html.dark .docs-story {
47+
background-color: #0c1d31 !important;
48+
}

0 commit comments

Comments
 (0)