Skip to content

Commit 268a298

Browse files
authored
Merge pull request #1103 from primer/storybook-themeprovider
Wrap Storybook stories in ThemeProvider
2 parents a253410 + 591193b commit 268a298

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/stories/Button.stories.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
22
import React from 'react'
33
import {Meta} from '@storybook/react'
4+
import {ThemeProvider} from 'styled-components'
45

56
import {
67
BaseStyles,
@@ -11,7 +12,8 @@ import {
1112
ButtonInvisible,
1213
ButtonOutline,
1314
ButtonPrimary,
14-
ButtonTableList
15+
ButtonTableList,
16+
theme
1517
} from '..'
1618
import {ButtonStyleProps} from 'styled-system'
1719
import {ButtonBaseProps} from '../Button/ButtonBase'
@@ -23,9 +25,11 @@ export default {
2325
decorators: [
2426
Story => {
2527
return (
26-
<BaseStyles>
27-
<Story />
28-
</BaseStyles>
28+
<ThemeProvider theme={theme}>
29+
<BaseStyles>
30+
<Story />
31+
</BaseStyles>
32+
</ThemeProvider>
2933
)
3034
}
3135
],

src/stories/Portal.stories.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
22
import React from 'react'
33
import {Meta} from '@storybook/react'
4+
import {ThemeProvider} from 'styled-components'
45

5-
import {BaseStyles, Box} from '..'
6+
import {BaseStyles, Box, theme} from '..'
67
import Portal, {registerPortalRoot} from '../Portal'
78

89
export default {
@@ -14,9 +15,11 @@ export default {
1415
// story works in isolation.
1516
registerPortalRoot(undefined)
1617
return (
17-
<BaseStyles>
18-
<Story />
19-
</BaseStyles>
18+
<ThemeProvider theme={theme}>
19+
<BaseStyles>
20+
<Story />
21+
</BaseStyles>
22+
</ThemeProvider>
2023
)
2124
}
2225
]

src/stories/useAnchoredPosition.stories.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import React from 'react'
33
import {Meta} from '@storybook/react'
44

5-
import {BaseStyles, Box, ButtonPrimary, Position} from '..'
5+
import {BaseStyles, Box, ButtonPrimary, Position, theme} from '..'
66
import {useAnchoredPosition} from '../hooks/useAnchoredPosition'
7-
import styled from 'styled-components'
7+
import styled, {ThemeProvider} from 'styled-components'
88
import {get} from '../constants'
99
import {AnchorSide} from '../behaviors/anchoredPosition'
1010
import Portal, {registerPortalRoot} from '../Portal'
@@ -15,7 +15,11 @@ export default {
1515
// Note: For some reason, if you use <BaseStyles><Story /></BaseStyles>,
1616
// the component gets unmounted from the root every time a control changes!
1717
Story => {
18-
return <BaseStyles>{Story()}</BaseStyles>
18+
return (
19+
<ThemeProvider theme={theme}>
20+
<BaseStyles>{Story()}</BaseStyles>
21+
</ThemeProvider>
22+
)
1923
}
2024
],
2125
argTypes: {
@@ -229,7 +233,7 @@ export const WithPortal = () => {
229233
left={position?.left ?? 0}
230234
width={250}
231235
height={400}
232-
sx={{visibility: position ? "visible" : "hidden"}}
236+
sx={{visibility: position ? 'visible' : 'hidden'}}
233237
>
234238
An un-constrained overlay!
235239
</Float>
@@ -239,7 +243,9 @@ export const WithPortal = () => {
239243
</Nav>
240244
<Box sx={{flexGrow: 1}} p={3}>
241245
<h1>The body!</h1>
242-
<p><em>Note: The controls below have no effect in this story.</em></p>
246+
<p>
247+
<em>Note: The controls below have no effect in this story.</em>
248+
</p>
243249
</Box>
244250
</Main>
245251
)

0 commit comments

Comments
 (0)