Skip to content

Commit b4cfb3d

Browse files
committed
docs(ui): add dark theme for storybook docs
1 parent 5d8fcf5 commit b4cfb3d

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

.storybook/manager.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { addons } from 'storybook/manager-api'
2-
import { create } from 'storybook/theming'
32

4-
const npmxTheme = create({
5-
brandTitle: 'npmx Storybook',
6-
brandImage: '/npmx-storybook.svg',
7-
})
3+
import npmxDark from './theme'
84

95
addons.setConfig({
10-
theme: npmxTheme,
6+
theme: npmxDark,
117
})

.storybook/preview-head.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<style>
2+
/* Override docs story canvas background to match npmx theme */
3+
.docs-story {
4+
background-color: var(--bg, oklch(0.171 0 0)) !important;
5+
}
6+
</style>

.storybook/preview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { currentLocales } from '../config/i18n'
44
import { fn } from 'storybook/test'
55
import { ACCENT_COLORS } from '../shared/utils/constants'
66

7+
import npmxDark from './theme'
8+
79
// related: https://github.com/npmx-dev/npmx.dev/blob/1431d24be555bca5e1ae6264434d49ca15173c43/test/nuxt/setup.ts#L12-L26
810
// Stub Nuxt specific globals
911
// @ts-expect-error - dynamic global name
@@ -25,6 +27,9 @@ const preview: Preview = {
2527
date: /Date$/i,
2628
},
2729
},
30+
docs: {
31+
theme: npmxDark,
32+
},
2833
},
2934
// Provides toolbars to switch things like theming and language
3035
globalTypes: {

.storybook/theme.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { create } from 'storybook/theming'
2+
3+
const npmxDark = create({
4+
base: 'dark',
5+
6+
brandTitle: 'npmx Storybook',
7+
brandImage: '/npmx-storybook.svg',
8+
9+
// UI
10+
appContentBg: '#101010', // oklch(0.171 0 0)
11+
})
12+
13+
export default npmxDark

0 commit comments

Comments
 (0)