Skip to content

Commit cd7c389

Browse files
committed
refactor: address PR feedback - share CSS config and simplify providers
1 parent 51b4aaf commit cd7c389

File tree

7 files changed

+26
-38
lines changed

7 files changed

+26
-38
lines changed

.storybook/main.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { StorybookConfig } from '@storybook/react-vite'
22
import { mergeConfig } from 'vite'
33
import { resolve } from 'path'
4+
import { scssPreprocessorOptions } from '../vite.config'
45

56
const config: StorybookConfig = {
67
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
@@ -23,12 +24,7 @@ const config: StorybookConfig = {
2324
},
2425
},
2526
css: {
26-
preprocessorOptions: {
27-
scss: {
28-
api: 'modern-compiler',
29-
additionalData: `@use "@/styles/Helpers" as *; @use '@/styles/Responsive' as *;\n`,
30-
},
31-
},
27+
preprocessorOptions: scssPreprocessorOptions,
3228
},
3329
})
3430
},

.storybook/preview.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import type { Decorator, Preview } from '@storybook/react'
2-
import { I18nextProvider } from 'react-i18next'
3-
import { SDKI18next } from '@/contexts/GustoProvider/SDKI18next'
4-
import { LocaleProvider } from '@/contexts/LocaleProvider'
5-
import { ThemeProvider } from '@/contexts/ThemeProvider'
62
import { GustoProviderCustomUIAdapter } from '@/contexts'
73
import { defaultComponents } from '@/contexts/ComponentAdapter/adapters/defaultComponentAdapter'
84
import { PlainComponentAdapter } from './adapters/PlainComponentAdapter'
@@ -19,15 +15,14 @@ const withProviders: Decorator = (Story, context: StoryContext) => {
1915
const components = adapterMode === 'plain' ? PlainComponentAdapter : defaultComponents
2016

2117
return (
22-
<I18nextProvider i18n={SDKI18next}>
23-
<LocaleProvider locale="en-US" currency="USD">
24-
<ThemeProvider>
25-
<GustoProviderCustomUIAdapter config={{ baseUrl: '' }} components={components}>
26-
<Story />
27-
</GustoProviderCustomUIAdapter>
28-
</ThemeProvider>
29-
</LocaleProvider>
30-
</I18nextProvider>
18+
<GustoProviderCustomUIAdapter
19+
config={{ baseUrl: '' }}
20+
components={components}
21+
locale="en-US"
22+
currency="USD"
23+
>
24+
<Story />
25+
</GustoProviderCustomUIAdapter>
3126
)
3227
}
3328

src/components/Common/UI/Badge/Badge.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StoryObj, Meta } from '@storybook/react'
1+
import type { StoryObj } from '@storybook/react'
22
import type { BadgeProps } from './BadgeTypes'
33
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
44

@@ -7,11 +7,10 @@ const BadgeWrapper = (props: BadgeProps) => {
77
return <Components.Badge {...props} />
88
}
99

10-
const meta: Meta<typeof BadgeWrapper> = {
10+
export default {
1111
title: 'UI/Components/Badge',
1212
component: BadgeWrapper,
1313
}
14-
export default meta
1514

1615
type Story = StoryObj<typeof BadgeWrapper>
1716

src/components/Common/UI/Card/Card.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StoryObj, Meta } from '@storybook/react'
1+
import type { StoryObj } from '@storybook/react'
22
import type { CardProps } from './CardTypes'
33
import { Flex } from '@/components/Common/Flex/Flex'
44
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
@@ -56,11 +56,10 @@ const CardWrapper = (args: Omit<CardProps, 'children'>) => {
5656
)
5757
}
5858

59-
const meta: Meta<typeof CardWrapper> = {
59+
export default {
6060
title: 'UI/Components/Card',
6161
component: CardWrapper,
6262
}
63-
export default meta
6463

6564
type Story = StoryObj<typeof CardWrapper>
6665

src/components/Common/UI/LoadingSpinner/LoadingSpinner.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StoryObj, Meta } from '@storybook/react'
1+
import type { StoryObj } from '@storybook/react'
22
import type { LoadingSpinnerProps } from './LoadingSpinnerTypes'
33
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
44

@@ -7,11 +7,10 @@ const LoadingSpinnerWrapper = (props: LoadingSpinnerProps) => {
77
return <Components.LoadingSpinner {...props} />
88
}
99

10-
const meta: Meta<typeof LoadingSpinnerWrapper> = {
10+
export default {
1111
title: 'UI/Components/LoadingSpinner',
1212
component: LoadingSpinnerWrapper,
1313
}
14-
export default meta
1514

1615
type Story = StoryObj<typeof LoadingSpinnerWrapper>
1716

src/components/Common/UI/ProgressBar/ProgressBar.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StoryObj, Meta } from '@storybook/react'
1+
import type { StoryObj } from '@storybook/react'
22
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
33

44
interface ProgressBarStoryProps {
@@ -10,7 +10,7 @@ const ProgressBarWrapper = ({ currentStep }: ProgressBarStoryProps) => {
1010
return <ProgressBar totalSteps={10} currentStep={currentStep} label="Progress Bar" />
1111
}
1212

13-
const meta: Meta<typeof ProgressBarWrapper> = {
13+
export default {
1414
title: 'UI/Components/ProgressBar',
1515
component: ProgressBarWrapper,
1616
argTypes: {
@@ -19,7 +19,6 @@ const meta: Meta<typeof ProgressBarWrapper> = {
1919
},
2020
},
2121
}
22-
export default meta
2322

2423
type Story = StoryObj<typeof ProgressBarWrapper>
2524

vite.config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import circularDependencyDetector from 'vite-plugin-circular-dependency'
99
import checker from 'vite-plugin-checker'
1010
import { externalizeDeps } from 'vite-plugin-externalize-deps'
1111

12+
export const scssPreprocessorOptions = {
13+
scss: {
14+
api: 'modern-compiler',
15+
additionalData: `@use "@/styles/Helpers" as *; @use '@/styles/Responsive' as *;\n`,
16+
},
17+
} as const
18+
1219
/**
1320
* Current config is set to build sdk in library mode, retaining the original file structure and file names while also allowing for css modules and single css file output.
1421
* Development mode removes unnecessary plugins and configurations to speed up the build process.
@@ -63,13 +70,7 @@ export default defineConfig(({ mode }) => {
6370
},
6471
},
6572
css: {
66-
preprocessorOptions: {
67-
scss: {
68-
api: 'modern-compiler',
69-
additionalData: `@use "@/styles/Helpers" as *; @use '@/styles/Responsive' as *;
70-
`,
71-
},
72-
},
73+
preprocessorOptions: scssPreprocessorOptions,
7374
},
7475
build: {
7576
lib: {

0 commit comments

Comments
 (0)