Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updated storybook to v7 #509

Merged
merged 4 commits into from
Nov 22, 2023
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
5 changes: 5 additions & 0 deletions .changeset/purple-bobcats-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'storybook-manifest': minor
---

Upgraded storybook to v7
11 changes: 5 additions & 6 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"**/*.{ts,tsx,js,jsx}": [
"prettier --write",
"eslint --fix --max-warnings 0"
],
"**/*.{md,mdx,yml,json}": [
"**/*.{ts,tsx,js,jsx,md,mdx,yml,json}": [
"prettier --write"
],
"**/*.{ts,tsx,js,jsx} !(**/.storybook/*.js)": [
"eslint --fix --max-warnings 0"
]
}
}
26 changes: 21 additions & 5 deletions apps/storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
module.exports = {
import { dirname, join } from 'path';
const config = {
stories: ['../../../packages/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-a11y'],
framework: '@storybook/react',
core: {
builder: 'webpack5',
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-a11y'),
],

framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},

docs: {
autodocs: true,
},
};

export default config;

function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}
9 changes: 7 additions & 2 deletions apps/storybook/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export const decorators = [
),
];

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
const parameters = {
decorators: decorators,
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
},
};

export default parameters;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to avoid default exports to enforce naming during imports - but if this is the only thing it exports its OK

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah @dmorton-p44 i agree named import is nice thing to have, but with new version storybook expects these to be default exported.
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#70-breaking-changes.

18 changes: 18 additions & 0 deletions apps/storybook/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100,
"safari": 15,
"firefox": 91
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": []
}
23 changes: 14 additions & 9 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "storybook",
"name": "storybook-manifest",
"version": "0.0.10",
"private": true,
"scripts": {
"build": "build-storybook -c .storybook -o ./build",
"dev": "start-storybook -p 8000 --quiet"
"build": "storybook build -c .storybook -o ./build",
"dev": "storybook dev -p 8000 --quiet"
},
"dependencies": {
"@project44-manifest/react": "^3.18.1",
"@project44-manifest/react-icons": "^2.0.0",
"@storybook/addon-a11y": "^6.5.16",
"@storybook/addon-essentials": "^6.5.16",
"@storybook/addon-links": "^6.5.16",
"@storybook/builder-webpack5": "^6.5.16",
"@storybook/manager-webpack5": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/addon-a11y": "^7.5.3",
"@storybook/addon-essentials": "^7.5.3",
"@storybook/addon-links": "^7.5.3",
"@storybook/react": "^7.5.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/preset-env": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@storybook/react-webpack5": "^7.5.3",
"storybook": "next"
}
}
13 changes: 10 additions & 3 deletions packages/react/stories/Calendar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ export const Range = Template.bind({});

Range.decorators = [
() => (
<Box css={{ width: 324 }}>
<CalendarRange />
<Box css={{ width: 450 }}>
<CalendarRange
showCalendar
showRanges
value={{
start: new CalendarDate(2022, 7, 2),
end: new CalendarDate(2022, 7, 12),
}}
/>
</Box>
),
];
Expand Down Expand Up @@ -97,7 +104,7 @@ ControlledRange.decorators = [

return (
<Box css={{ width: 324 }}>
<CalendarRange value={value} onChange={setValue} />
<CalendarRange showCalendar value={value} onChange={setValue} />
</Box>
);
},
Expand Down
Loading