Skip to content

Commit 987b41d

Browse files
authored
chore(storybook): setting up AlphaAppProvider (#1796)
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English** and added an appropriate **label** to the PR. - [x] I wrote the commit message in **English** and to follow [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] I [added the **changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) about the changes that needed to be released. (or didn't have to) - [x] I wrote or updated **documentation** related to the changes. (or didn't have to) - [x] I wrote or updated **tests** related to the changes. (or didn't have to) - [x] I tested the changes in various browsers. (or didn't have to) - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox ## Summary <!-- Please brief explanation of the changes made --> 스토리북에 `AlphaAppProvider` 를 적용합니다. ## Details <!-- Please elaborate description of the changes --> - CSS variable 테스트를 할 수 있도록 환경을 구축합니다. #1733 마이그레이션이 완료되면, BezierProvider를 제거할 수 있습니다. - 중복되거나 불필요한 글로벌 스타일, Provider를 제거했습니다. <img width="926" alt="image" src="https://github.com/channel-io/bezier-react/assets/58209009/d52ff885-768b-4e0e-a861-f58d1ce14a37"> 적용된 모습 ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No
1 parent 920c18b commit 987b41d

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

packages/bezier-react/.storybook/WithFoundationProvider.jsx

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import React from 'react'
33
import {
44
LightFoundation,
55
DarkFoundation,
6-
createGlobalStyle,
76
} from '~/src/foundation'
8-
import {
9-
FeatureProvider,
10-
SmoothCornersFeature,
11-
} from '~/src/features'
7+
import { SmoothCornersFeature } from '~/src/features'
128
import BezierProvider from '~/src/providers/BezierProvider'
9+
import { AlphaAppProvider } from '~/src/providers/AlphaAppProvider'
10+
import { InvertedThemeProvider } from '~/src/providers/ThemeProvider'
1311
import { Text } from '~/src/components/Text'
1412

1513
import '~/src/styles/index.scss'
@@ -28,12 +26,6 @@ function getFoundation(keyword) {
2826
}
2927
}
3028

31-
const GlobalStyle = createGlobalStyle`
32-
:root {
33-
font-family: Inter, sans-serif;
34-
}
35-
`
36-
3729
const wrapperStyle = {
3830
display: 'flex',
3931
flexDirection: 'row',
@@ -60,6 +52,7 @@ const innerWrapperStyle = {
6052
borderRadius: 20,
6153
}
6254

55+
// TODO: Migrate to AlphaAppProvider
6356
export function WithFoundationProvider(Story, context) {
6457
const {
6558
isDarkFoundation,
@@ -79,40 +72,41 @@ export function WithFoundationProvider(Story, context) {
7972
})()
8073

8174
return (
82-
<FeatureProvider features={[SmoothCornersFeature]}>
83-
<GlobalStyle />
84-
85-
<BezierProvider foundation={foundation}>
75+
<AlphaAppProvider
76+
themeName={isDarkFoundation ? "dark" : "light"}
77+
features={[SmoothCornersFeature]}
78+
>
79+
<BezierProvider
80+
foundation={foundation}
81+
themeVarsScope=".theme"
82+
>
8683
<div style={wrapperStyle}>
87-
<BezierProvider
88-
foundation={foundation}
89-
themeVarsScope=".theme"
90-
>
91-
<div className="theme" style={storyWrapperStyle}>
92-
<div style={{ ...innerWrapperStyle, backgroundColor }}>
93-
{ Story(context) }
94-
</div>
95-
<Text bold color="bgtxt-absolute-black-light">
96-
{ themeName }
97-
</Text>
84+
<div className="theme" style={storyWrapperStyle}>
85+
<div style={{ ...innerWrapperStyle, backgroundColor }}>
86+
{ Story(context) }
9887
</div>
99-
</BezierProvider>
88+
<Text bold color="bgtxt-absolute-black-light">
89+
{ themeName }
90+
</Text>
91+
</div>
10092

10193
<BezierProvider
10294
foundation={invertedFoundation}
10395
themeVarsScope=".inverted-theme"
10496
>
105-
<div className="inverted-theme" style={storyWrapperStyle}>
106-
<div style={{ ...innerWrapperStyle, backgroundColor: invertedBackgroundColor }}>
107-
{ Story(context) }
97+
<InvertedThemeProvider>
98+
<div className="inverted-theme" style={storyWrapperStyle}>
99+
<div style={{ ...innerWrapperStyle, backgroundColor: invertedBackgroundColor }}>
100+
{ Story(context) }
101+
</div>
102+
<Text bold color="bgtxt-absolute-black-light">
103+
{ invertedThemeName }
104+
</Text>
108105
</div>
109-
<Text bold color="bgtxt-absolute-black-light">
110-
{ invertedThemeName }
111-
</Text>
112-
</div>
106+
</InvertedThemeProvider>
113107
</BezierProvider>
114108
</div>
115109
</BezierProvider>
116-
</FeatureProvider>
110+
</AlphaAppProvider>
117111
)
118112
}

packages/bezier-react/src/providers/BezierProvider.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ interface BezierProviderProps {
2222
externalWindow?: Window
2323
}
2424

25+
/**
26+
* @deprecated Migration to `AlphaAppProvider` is in progress.
27+
*/
2528
function BezierProvider({
2629
foundation,
2730
children,

0 commit comments

Comments
 (0)