Skip to content

Commit

Permalink
Upgrade to storybook 7 (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
xcv58 authored Dec 4, 2023
1 parent b6d88a7 commit 388540f
Show file tree
Hide file tree
Showing 8 changed files with 3,473 additions and 3,774 deletions.
6 changes: 4 additions & 2 deletions packages/extension/src/js/components/CloseButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { Story, Meta } from '@storybook/react'

import CloseButton, { CloseButtonProps } from './CloseButton'

export default {
const meta: Meta<typeof CloseButton> = {
title: 'UI Components/CloseButton',
component: CloseButton,
argTypes: { disabled: { control: 'boolean' } },
} as Meta
}

export default meta

const Template: Story<CloseButtonProps> = (args) => <CloseButton {...args} />

Expand Down
6 changes: 4 additions & 2 deletions packages/extension/src/js/components/Tab/Url.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Story, Meta } from '@storybook/react/types-6-0'

import Url, { UrlProps } from './Url'

export default {
const meta: Meta<typeof Url> = {
title: 'UI Components/Url',
component: Url,
argTypes: {
Expand All @@ -14,7 +14,9 @@ export default {
},
duplicated: { control: 'boolean' },
},
} as Meta
}

export default meta

const getHighlightNode = (url: string) => url

Expand Down
32 changes: 0 additions & 32 deletions packages/storybook/.storybook/main.js

This file was deleted.

54 changes: 54 additions & 0 deletions packages/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { StorybookConfig } from '@storybook/react-webpack5'
import fs from 'fs'
import path from 'path'

import { join, dirname } from 'path'

const alias = {}
const jsEntry = '../../extension/src/js'
Object.assign(
alias,
...fs
.readdirSync(path.join(__dirname, jsEntry), { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
.map((entry) => ({ [entry]: path.join(__dirname, jsEntry, entry) })),
)

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')))
}
const config: StorybookConfig = {
stories: [
'../../extension/src/**/*.mdx',
'../../extension/src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-onboarding'),
getAbsolutePath('@storybook/addon-interactions'),
],
webpackFinal: (config) => {
if (config.resolve && config.resolve.alias) {
Object.assign(config.resolve.alias, alias)
}
return config
},
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {
builder: {
useSWC: true,
},
},
},
docs: {
autodocs: 'tag',
},
}
export default config
14 changes: 0 additions & 14 deletions packages/storybook/.storybook/preview.js

This file was deleted.

21 changes: 21 additions & 0 deletions packages/storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Preview } from '@storybook/react'

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
options: {
isToolshown: true,
storySort: {
order: ['Introduction', 'Changelog', 'UI Components'],
},
},
},
}

export default preview
18 changes: 14 additions & 4 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
"version": "1.0.0",
"private": true,
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"devDependencies": {
"@babel/preset-env": "^7.23.5",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@storybook/addon-a11y": "7.6.3",
"@storybook/addon-actions": "7.6.3",
"@storybook/addon-essentials": "7.6.3",
"@storybook/addon-links": "7.6.3",
"@storybook/builder-webpack5": "7.6.3",
"@storybook/manager-webpack5": "6.5.16",
"@storybook/addon-mdx-gfm": "7.6.3",
"@storybook/react": "7.6.3",
"@storybook/react-webpack5": "7.6.3",
"@storybook/addon-interactions": "7.6.3",
"@storybook/addon-onboarding": "1.0.9",
"@storybook/blocks": "7.6.3",
"@storybook/test": "7.6.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"storybook": "7.6.3",
"storybook-addon-performance": "0.17.1"
}
}
Loading

1 comment on commit 388540f

@vercel
Copy link

@vercel vercel bot commented on 388540f Dec 4, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.