Skip to content

Commit

Permalink
Upgrade to Storybook 8, Vite 5 and Vitest 1 (#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer authored Mar 13, 2024
1 parent f449df8 commit cec2468
Show file tree
Hide file tree
Showing 26 changed files with 41,594 additions and 39,775 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm run docs:build

- name: Publish to Chromatic
uses: chromaui/action@v1
uses: chromaui/action@latest
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
Expand Down
8 changes: 6 additions & 2 deletions .storybook/addons/versions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from 'react';
import {
Icons,
IconButton,
WithTooltip,
TooltipLinkList,
} from '@storybook/components';
import { ChevronSmallDownIcon } from '@storybook/icons';
import { useParameter } from '@storybook/manager-api';

type Version = {
Expand All @@ -25,6 +25,10 @@ export function Versions() {

const [isTooltipVisible, setIsTooltipVisible] = useState(false);

if (!config.current) {
return null;
}

return (
<WithTooltip
placement="top"
Expand All @@ -49,7 +53,7 @@ export function Versions() {
title="Switch to previous versions of the documentation"
active={isTooltipVisible}
>
{config.current} <Icons icon="arrowdown" />
{config.current} <ChevronSmallDownIcon aria-hidden="true" />
</IconButton>
</WithTooltip>
);
Expand Down
12 changes: 4 additions & 8 deletions .storybook/components/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
* limitations under the License.
*/

import { Canvas } from '@storybook/addon-docs';
import type { PropsWithChildren } from 'react';
import { ThemeProvider } from '@emotion/react';
import { light } from '@sumup/design-tokens';

const Preview = ({ children, ...props }) => (
<Canvas {...props}>
<ThemeProvider theme={light}>{children}</ThemeProvider>
</Canvas>
);

export default Preview;
export default function Preview({ children }: PropsWithChildren) {
return <ThemeProvider theme={light}>{children}</ThemeProvider>;
}
16 changes: 8 additions & 8 deletions .storybook/components/Story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* limitations under the License.
*/

import { Story as StorybookStory } from '@storybook/addon-docs';
import { Canvas } from '@storybook/addon-docs';

import Preview from './Preview';

const Story = ({ withToolbar = true, ...props }) => (
<Preview withToolbar={withToolbar}>
<StorybookStory {...props} />
</Preview>
);

export default Story;
export default function Story({ withToolbar = true, ...props }) {
return (
<Preview>
<Canvas withToolbar={withToolbar} {...props} />
</Preview>
);
}
4 changes: 1 addition & 3 deletions .storybook/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* limitations under the License.
*/

import { ArgsTable as Props, PRIMARY_STORY } from '@storybook/addon-docs';

Props.defaultProps = { ...Props.defaultProps, story: PRIMARY_STORY };
import { Controls as Props } from '@storybook/addon-docs';

export { Props };

Expand Down
8 changes: 3 additions & 5 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { StorybookConfig } from '@storybook/react-vite';
import path from 'path';
import remarkGfm from 'remark-gfm';
import { mergeConfig } from 'vite';
import turbosnap from 'vite-plugin-turbosnap';

const toPath = (_path: string) => path.join(process.cwd(), _path);

Expand Down Expand Up @@ -44,12 +43,11 @@ const config: StorybookConfig = {
define: {
'process.env.UNSAFE_DISABLE_ELEMENT_ERRORS': false,
},
plugins:
configType === 'PRODUCTION'
? [turbosnap({ rootDir: config.root ?? process.cwd() })]
: [],
});
},
typescript: {
reactDocgen: 'react-docgen-typescript',
},
};

export default config;
2 changes: 1 addition & 1 deletion .storybook/manager.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addons, types } from '@storybook/addons';
import { addons, types } from '@storybook/manager-api';

import { dark, light, listenToColorScheme } from './themes.js';
import { PARAM_KEY as VERSIONS_PARAM_KEY, Versions } from './addons/versions';
Expand Down
1 change: 0 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const parameters = {
},
},
previewTabs: { 'storybook/docs/panel': { index: -1 } },
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
options: {
storySort: {
Expand Down
5 changes: 4 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
comment:
layout: "reach, diff, flags, files"
layout: 'reach, diff, flags, files'
behavior: default
require_changes: false
require_base: no
require_head: no
branches: null
github_checks:
annotations: false
ignore:
- '**/index.*'
- '**/*.stories.*'
Loading

0 comments on commit cec2468

Please sign in to comment.