Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook-vue/nuxt'

const config = {
stories: ['../app/**/*.stories.@(js|ts)'],
stories: ['../.storybook/*.mdx', '../app/**/*.stories.@(js|ts)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-docs', '@storybook/addon-themes'],
framework: '@storybook-vue/nuxt',
staticDirs: ['./.public'],
Expand All @@ -11,6 +11,33 @@ const config = {
async viteFinal(newConfig) {
newConfig.plugins ??= []

// Bridge compatibility between Storybook v10 core and v9 @storybook-vue/nuxt
// v10 expects module federation globals that v9 doesn't provide
newConfig.plugins.push({
name: 'storybook-v10-compat',
transformIndexHtml: {
order: 'pre',
handler(html) {
const script = `
<script>
// Minimal shims for Storybook v10 module federation system
// These will be replaced when Storybook runtime loads
window.__STORYBOOK_MODULE_GLOBAL__ = { global: window };
window.__STORYBOOK_MODULE_CLIENT_LOGGER__ = {
deprecate: console.warn.bind(console, '[deprecated]'),
once: console.log.bind(console),
logger: console
};
window.__STORYBOOK_MODULE_CHANNELS__ = {
Channel: class { on() {} off() {} emit() {} once() {} },
createBrowserChannel: () => new window.__STORYBOOK_MODULE_CHANNELS__.Channel()
};
</script>`
return html.replace(/<script>/, script + '<script>')
},
},
})

newConfig.plugins.push({
name: 'ignore-internals',
transform(_, id) {
Expand Down
20 changes: 14 additions & 6 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { addons } from 'storybook/manager-api'
import { create } from 'storybook/theming'

const npmxTheme = create({
brandTitle: 'npmx Storybook',
brandImage: '/npmx-storybook.svg',
})
import npmxDark from './theme'

addons.setConfig({
theme: npmxTheme,
theme: npmxDark,
layoutCustomisations: {
showToolbar: (state, defaultValue) => {
if (state.viewMode === 'docs' && state.storyId) {
const story = state.index?.[state.storyId]
const tags = story?.tags || []
if (tags.includes('hide-toolbar')) {
return false
}
}
return defaultValue
},
},
})
6 changes: 6 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style>
/* Override docs story canvas background to match npmx theme */
.docs-story {
background-color: var(--bg, oklch(0.171 0 0)) !important;
}
</style>
5 changes: 5 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { currentLocales } from '../config/i18n'
import { fn } from 'storybook/test'
import { ACCENT_COLORS } from '../shared/utils/constants'

import npmxDark from './theme'

// related: https://github.com/npmx-dev/npmx.dev/blob/1431d24be555bca5e1ae6264434d49ca15173c43/test/nuxt/setup.ts#L12-L26
// Stub Nuxt specific globals
// @ts-expect-error - dynamic global name
Expand All @@ -25,6 +27,9 @@ const preview: Preview = {
date: /Date$/i,
},
},
docs: {
theme: npmxDark,
},
},
// Provides toolbars to switch things like theming and language
globalTypes: {
Expand Down
7 changes: 7 additions & 0 deletions .storybook/storybook-welcome.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Meta } from '@storybook/addon-docs/blocks';

<Meta title="Welcome" tags={['hide-toolbar']}/>

# Welcome

Welcome to the npmx Storybook.
13 changes: 13 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { create } from 'storybook/theming'

const npmxDark = create({
base: 'dark',

brandTitle: 'npmx Storybook',
brandImage: '/npmx-storybook.svg',

// UI
appContentBg: '#101010', // oklch(0.171 0 0)
})

export default npmxDark
128 changes: 64 additions & 64 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ overrides:
sharp: 0.34.5
vite: npm:@voidzero-dev/vite-plus-core@0.1.12
vitest: npm:@voidzero-dev/vite-plus-test@0.1.12
storybook: ^10.2.7
storybook: ^10.3.1

packageExtensions:
'@nuxt/scripts':
Expand All @@ -43,7 +43,7 @@ shellEmulator: true
catalogs:
storybook:
'@storybook-vue/nuxt': '9.0.1'
'@storybook/addon-a11y': '^10.2.7'
'@storybook/addon-docs': '^10.2.7'
'@storybook/addon-themes': '^10.2.7'
'storybook': '^10.2.7'
'@storybook/addon-a11y': '^10.3.1'
'@storybook/addon-docs': '^10.3.1'
'@storybook/addon-themes': '^10.3.1'
'storybook': '^10.3.1'
Loading