Update migration guide and refactor portable stories to use initialGlobals for locale configuration instead of globalTypes defaultValue.

This commit is contained in:
Valentin Palkovic 2025-03-26 13:56:28 +01:00
parent 3dcc104933
commit 1750457a1e
3 changed files with 25 additions and 3 deletions

View File

@ -470,7 +470,27 @@ export const preview = {
};
```
Additionally loading `globals` from globalTypes isn't supported in portable stories anymore. Use `initialGlobals` instead.
Additionally loading the defaultValue from `globalTypes` isn't supported anymore. Use `initialGlobals` instead to define the defaultValue.
```diff
// .storybook/preview.js
export default {
+ initialGlobals: {
+ locale: 'en'
+ },
globalTypes: {
locale: {
description: 'Locale for components',
- defaultValue: 'en',
toolbar: {
title: 'Locale',
icon: 'circlehollow',
items: ['es', 'en'],
},
},
},
}
```
### Icon System Updates

View File

@ -12,10 +12,12 @@ const preview: Preview = {
</div>
),
],
initialGlobals: {
locale: 'en',
},
globalTypes: {
locale: {
description: 'Locale for components',
defaultValue: 'en',
toolbar: {
title: 'Locale',
icon: 'circlehollow',

View File

@ -55,7 +55,7 @@ describe('projectAnnotations', () => {
it('renders with custom projectAnnotations via composeStory params', () => {
const WithPortugueseText = composeStory(stories.CSF2StoryWithLocale, stories.default, {
globalTypes: { locale: { defaultValue: 'pt' } },
initialGlobals: { locale: 'pt' },
});
const { getByText } = render(<WithPortugueseText />);
const buttonElement = getByText('Olá!');