11import '@fontsource/ibm-plex-mono'
22import 'inter-ui/inter.css'
33
4- import { ErrorBoundary } from 'react-error-boundary'
54import { 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'
76import mockdate from 'mockdate'
7+ import { ErrorBoundary } from 'react-error-boundary'
88
99import { ThemeProvider } from '@opengovsg/design-system-react'
1010import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
@@ -16,19 +16,19 @@ import { type AppRouter } from '~/server/modules/_app'
1616import { theme } from '~/theme'
1717
1818import { 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'
2219import { format } from 'date-fns/format'
20+ import { merge } from 'lodash'
21+ import { initialize , mswLoader } from 'msw-storybook-addon'
22+ import { z } from 'zod'
2323import {
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'
3130import { env } from '~/env.mjs'
31+ import { LoginStateContext } from '~/features/auth'
3232
3333// Initialize MSW
3434initialize ( {
@@ -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
106106export 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 : / ( b a c k g r o u n d | c o l o r ) $ / i,
206- date : / D a t e $ / ,
207- } ,
208- } ,
209- } ,
210- }
198+ export const tags = [ 'autodocs' ] ;
211199
212- export default preview
200+ export const loaders : Loader [ ] = [ mswLoader ]
0 commit comments