Skip to content

Commit e1dab8e

Browse files
authored
feat: update storybook and msw packages (#343)
* feat: update storybook and msw packages * fix: remove pnpm packageManager config in package.json * fix: remove unnecessary lint ignore
1 parent b842c9a commit e1dab8e

File tree

11 files changed

+5313
-16629
lines changed

11 files changed

+5313
-16629
lines changed

.storybook/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const config: StorybookConfig = {
1212
name: '@storybook/nextjs',
1313
options: {},
1414
},
15-
docs: {
16-
autodocs: 'tag',
17-
},
15+
docs: {},
1816
staticDirs: ['../public'],
1917
core: {
2018
disableTelemetry: true,

.storybook/preview.tsx

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import '@fontsource/ibm-plex-mono'
22
import 'inter-ui/inter.css'
33

4-
import { ErrorBoundary } from 'react-error-boundary'
54
import { withThemeFromJSXProvider } from '@storybook/addon-themes'
6-
import { type ReactRenderer, type Args, type Decorator, type Preview } from '@storybook/react'
5+
import { Loader, type Args, type Decorator, type ReactRenderer } from '@storybook/react'
76
import mockdate from 'mockdate'
7+
import { ErrorBoundary } from 'react-error-boundary'
88

99
import { ThemeProvider } from '@opengovsg/design-system-react'
1010
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
@@ -16,19 +16,19 @@ import { type AppRouter } from '~/server/modules/_app'
1616
import { theme } from '~/theme'
1717

1818
import { Box, Skeleton } from '@chakra-ui/react'
19-
import { initialize, mswDecorator } from 'msw-storybook-addon'
20-
import { DefaultFallback } from '~/components/ErrorBoundary'
21-
import Suspense from '~/components/Suspense'
2219
import { format } from 'date-fns/format'
20+
import { merge } from 'lodash'
21+
import { initialize, mswLoader } from 'msw-storybook-addon'
22+
import { z } from 'zod'
2323
import {
24-
type EnvContextReturn,
2524
EnvProvider,
2625
FeatureContext,
26+
type EnvContextReturn,
2727
} from '~/components/AppProviders'
28-
import { z } from 'zod'
29-
import { LoginStateContext } from '~/features/auth'
30-
import { merge } from 'lodash'
28+
import { DefaultFallback } from '~/components/ErrorBoundary'
29+
import Suspense from '~/components/Suspense'
3130
import { env } from '~/env.mjs'
31+
import { LoginStateContext } from '~/features/auth'
3232

3333
// Initialize MSW
3434
initialize({
@@ -95,13 +95,13 @@ const SetupDecorator: Decorator = (story) => {
9595
}
9696
```
9797
*/
98-
const WithLayoutDecorator: Decorator = (Story, { parameters }) => {
99-
if (!parameters.getLayout) {
100-
return Story()
101-
}
102-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
103-
return <>{parameters.getLayout(<Story />)}</>
98+
const WithLayoutDecorator: Decorator = (Story, { parameters }) => {
99+
if (!parameters.getLayout) {
100+
return Story()
104101
}
102+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
103+
return <>{parameters.getLayout(<Story />)}</>
104+
}
105105

106106
export const MockFeatureFlagsDecorator: Decorator<Args> = (
107107
story,
@@ -180,7 +180,7 @@ export const MockDateDecorator: Decorator<Args> = (story, { parameters }) => {
180180
)
181181
}
182182

183-
const decorators: Decorator[] = [
183+
export const decorators: Decorator[] = [
184184
WithLayoutDecorator,
185185
StorybookEnvDecorator,
186186
MockFeatureFlagsDecorator,
@@ -193,20 +193,8 @@ const decorators: Decorator[] = [
193193
Provider: ThemeProvider,
194194
}),
195195
MockDateDecorator,
196-
mswDecorator,
197196
]
198197

199-
const preview: Preview = {
200-
decorators,
201-
parameters: {
202-
actions: { argTypesRegex: '^on[A-Z].*' },
203-
controls: {
204-
matchers: {
205-
color: /(background|color)$/i,
206-
date: /Date$/,
207-
},
208-
},
209-
},
210-
}
198+
export const tags = ['autodocs'];
211199

212-
export default preview
200+
export const loaders: Loader[] = [mswLoader]

0 commit comments

Comments
 (0)