Skip to content

Commit b72b551

Browse files
authored
Merge branch 'npmx-dev:main' into feat-i18n/adding-dutch
2 parents 0fb1991 + a54def4 commit b72b551

File tree

241 files changed

+15570
-4860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+15570
-4860
lines changed

.github/workflows/chromatic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: pnpm install
3838

3939
- name: 🧪 Run Chromatic Visual and Accessibility Tests
40-
uses: chromaui/action@0794e6939fe40ce46a88963f818092afc427da5b # v15.3.0
40+
uses: chromaui/action@f191a0224b10e1a38b2091cefb7b7a2337009116 # v16.0.0
4141
env:
4242
CHROMATIC_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
4343
CHROMATIC_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ jobs:
111111
run: pnpm vp test --project nuxt --coverage --reporter=default --reporter=junit --outputFile=test-report.junit.xml
112112

113113
- name: ⬆︎ Upload coverage reports to Codecov
114-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
114+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
115115
with:
116116
report_type: test_results
117117
env:
118118
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
119119

120120
- name: ⬆︎ Upload coverage reports to Codecov
121-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
121+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6
122122
env:
123123
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
124124

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: welcome
1+
name: Claim Contributor Message
22

33
on:
44
pull_request_target:

.github/workflows/welcome-open.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Welcome Message
2+
3+
on:
4+
pull_request_target:
5+
branches: [main]
6+
types: [opened]
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
greeting:
13+
name: Greet First-Time Contributors
14+
if: github.repository == 'npmx-dev/npmx.dev'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: zephyrproject-rtos/action-first-interaction@58853996b1ac504b8e0f6964301f369d2bb22e5c
18+
with:
19+
repo-token: ${{ secrets.GITHUB_TOKEN }}
20+
pr-opened-message: |
21+
Hello! Thank you for opening your **first PR** to npmx, @${{ github.event.pull_request.user.login }}! 🚀
22+
23+
Here’s what will happen next:
24+
25+
1. Our GitHub bots will run to check your changes.
26+
If they spot any issues you will see some error messages on this PR.
27+
Don’t hesitate to ask any questions if you’re not sure what these mean!
28+
29+
2. In a few minutes, you’ll be able to see a preview of your changes on Vercel
30+
31+
3. One or more of our maintainers will take a look and may ask you to make changes.
32+
We try to be responsive, but don’t worry if this takes a few days.

.storybook/main.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
11
import type { StorybookConfig } from '@storybook-vue/nuxt'
22

33
const config = {
4-
stories: ['../app/**/*.stories.@(js|ts)'],
5-
addons: ['@storybook/addon-a11y', '@storybook/addon-docs', '@storybook/addon-themes'],
4+
stories: ['../.storybook/*.mdx', '../app/**/*.stories.@(js|ts)'],
5+
addons: [
6+
'@storybook/addon-a11y',
7+
'@storybook/addon-docs',
8+
'@storybook/addon-themes',
9+
'storybook-i18n',
10+
],
611
framework: '@storybook-vue/nuxt',
7-
staticDirs: ['./.public'],
12+
staticDirs: ['./.public', { from: '../public', to: '/' }],
813
features: {
914
backgrounds: false,
1015
},
1116
async viteFinal(newConfig) {
1217
newConfig.plugins ??= []
1318

19+
// Bridge compatibility between Storybook v10 core and v9 @storybook-vue/nuxt
20+
// v10 expects module federation globals that v9 doesn't provide
21+
newConfig.plugins.push({
22+
name: 'storybook-v10-compat',
23+
transformIndexHtml: {
24+
order: 'pre',
25+
handler(html) {
26+
const script = `
27+
<script>
28+
// Minimal shims for Storybook v10 module federation system
29+
// These will be replaced when Storybook runtime loads
30+
window.__STORYBOOK_MODULE_GLOBAL__ = { global: window };
31+
window.__STORYBOOK_MODULE_CLIENT_LOGGER__ = {
32+
deprecate: console.warn.bind(console, '[deprecated]'),
33+
once: console.log.bind(console),
34+
logger: console
35+
};
36+
window.__STORYBOOK_MODULE_CHANNELS__ = {
37+
Channel: class { on() {} off() {} emit() {} once() {} },
38+
createBrowserChannel: () => new window.__STORYBOOK_MODULE_CHANNELS__.Channel()
39+
};
40+
</script>`
41+
return html.replace(/<script>/, script + '<script>')
42+
},
43+
},
44+
})
45+
1446
newConfig.plugins.push({
1547
name: 'ignore-internals',
1648
transform(_, id) {

.storybook/manager.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
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,
7+
layoutCustomisations: {
8+
showToolbar: (state, defaultValue) => {
9+
if (state.viewMode === 'docs' && state.storyId) {
10+
const story = state.index?.[state.storyId]
11+
const tags = story?.tags || []
12+
if (tags.includes('hide-toolbar')) {
13+
return false
14+
}
15+
}
16+
return defaultValue
17+
},
18+
},
1119
})

.storybook/preview-head.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<style>
2+
/* Load Geist fonts to match the production app (normally handled by @nuxt/fonts,
3+
which is disabled in Storybook at this time) */
4+
@font-face {
5+
font-family: 'Geist';
6+
font-weight: 400;
7+
font-style: normal;
8+
font-display: swap;
9+
src: url('/fonts/Geist-Regular.ttf') format('truetype');
10+
}
11+
@font-face {
12+
font-family: 'Geist';
13+
font-weight: 500;
14+
font-style: normal;
15+
font-display: swap;
16+
src: url('/fonts/Geist-Medium.ttf') format('truetype');
17+
}
18+
@font-face {
19+
font-family: 'Geist';
20+
font-weight: 600;
21+
font-style: normal;
22+
font-display: swap;
23+
src: url('/fonts/Geist-SemiBold.ttf') format('truetype');
24+
}
25+
@font-face {
26+
font-family: 'Geist';
27+
font-weight: 700;
28+
font-style: normal;
29+
font-display: swap;
30+
src: url('/fonts/Geist-Bold.ttf') format('truetype');
31+
}
32+
@font-face {
33+
font-family: 'Geist Mono';
34+
font-weight: 400;
35+
font-style: normal;
36+
font-display: swap;
37+
src: url('/fonts/GeistMono-Regular.ttf') format('truetype');
38+
}
39+
@font-face {
40+
font-family: 'Geist Mono';
41+
font-weight: 500;
42+
font-style: normal;
43+
font-display: swap;
44+
src: url('/fonts/GeistMono-Medium.ttf') format('truetype');
45+
}
46+
@font-face {
47+
font-family: 'Geist Mono';
48+
font-weight: 700;
49+
font-style: normal;
50+
font-display: swap;
51+
src: url('/fonts/GeistMono-Bold.ttf') format('truetype');
52+
}
53+
html {
54+
-webkit-font-smoothing: antialiased;
55+
-moz-osx-font-smoothing: grayscale;
56+
text-rendering: optimizeLegibility;
57+
}
58+
59+
/* Override docs story canvas background to match npmx theme */
60+
.docs-story {
61+
background-color: var(--bg, oklch(0.171 0 0)) !important;
62+
}
63+
</style>

.storybook/preview.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { Preview } from '@storybook-vue/nuxt'
22
import { withThemeByDataAttribute } from '@storybook/addon-themes'
3+
import { addons } from 'storybook/preview-api'
34
import { currentLocales } from '../config/i18n'
45
import { fn } from 'storybook/test'
56
import { ACCENT_COLORS } from '../shared/utils/constants'
67

8+
import npmxDark from './theme'
9+
710
// related: https://github.com/npmx-dev/npmx.dev/blob/1431d24be555bca5e1ae6264434d49ca15173c43/test/nuxt/setup.ts#L12-L26
811
// Stub Nuxt specific globals
912
// @ts-expect-error - dynamic global name
@@ -17,6 +20,12 @@ globalThis['__NUXT_COLOR_MODE__'] ??= {
1720
// @ts-expect-error - dynamic global name
1821
globalThis.defineOgImageComponent = fn()
1922

23+
// Subscribe to locale changes from storybook-i18n addon (once, outside decorator)
24+
let currentI18nInstance: any = null
25+
addons.getChannel().on('LOCALE_CHANGED', (newLocale: string) => {
26+
currentI18nInstance?.setLocale(newLocale)
27+
})
28+
2029
const preview: Preview = {
2130
parameters: {
2231
controls: {
@@ -25,25 +34,22 @@ const preview: Preview = {
2534
date: /Date$/i,
2635
},
2736
},
37+
docs: {
38+
theme: npmxDark,
39+
},
40+
},
41+
initialGlobals: {
42+
locale: 'en-US',
43+
locales: currentLocales.reduce(
44+
(acc, locale) => {
45+
acc[locale.code] = locale.name
46+
return acc
47+
},
48+
{} as Record<string, string>,
49+
),
2850
},
2951
// Provides toolbars to switch things like theming and language
3052
globalTypes: {
31-
locale: {
32-
name: 'Locale',
33-
description: 'UI language',
34-
defaultValue: 'en-US',
35-
toolbar: {
36-
icon: 'globe',
37-
dynamicTitle: true,
38-
items: [
39-
// English is at the top so it's easier to reset to it
40-
{ value: 'en-US', title: 'English (US)' },
41-
...currentLocales
42-
.filter(locale => locale.code !== 'en-US')
43-
.map(locale => ({ value: locale.code, title: locale.name })),
44-
],
45-
},
46-
},
4753
accentColor: {
4854
name: 'Accent Color',
4955
description: 'Accent color',
@@ -70,9 +76,9 @@ const preview: Preview = {
7076
attributeName: 'data-theme',
7177
}),
7278
(story, context) => {
73-
const { locale, accentColor } = context.globals as {
74-
locale: string
79+
const { accentColor, locale } = context.globals as {
7580
accentColor?: string
81+
locale?: string
7682
}
7783

7884
// Set accent color from globals
@@ -84,14 +90,12 @@ const preview: Preview = {
8490

8591
return {
8692
template: '<story />',
87-
// Set locale from globals
8893
created() {
89-
if (this.$i18n) {
90-
this.$i18n.setLocale(locale)
91-
}
92-
},
93-
updated() {
94-
if (this.$i18n) {
94+
// Store i18n instance for LOCALE_CHANGED events
95+
currentI18nInstance = this.$i18n
96+
97+
// Set initial locale when component is created
98+
if (locale && this.$i18n) {
9599
this.$i18n.setLocale(locale)
96100
}
97101
},

.storybook/storybook-welcome.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Meta } from '@storybook/addon-docs/blocks';
2+
3+
<Meta title="Welcome" tags={['hide-toolbar']}/>
4+
5+
# Welcome
6+
7+
Welcome to the npmx Storybook.

.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)