integrating theme-ui with storybook in a gatsby project
See original GitHub issueHi,
I have a gatsby project where I have integrated theme-ui. Now i am trying to incorporate storybook in the project so I can develop a component library for my project.
I want my components to rely on theme-ui and the sx prop for styling but when i write stories, they render in the storybook UI without the style applied.
I am a bit lost on how to debug this.
this is what the relevant portion of my .storybook/config.js file looks like
import { configure, addDecorator } from '@storybook/react';
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import theme from '../src/gatsby-plugin-theme-ui/index'
// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /\.stories\.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
addDecorator((story) => (
<ThemeProvider theme={theme}>
{story()}
</ThemeProvider>
))
configure(loadStories, module);
Any help on where to start debugging this are appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (7 by maintainers)
Top Results From Across the Web
Visual Testing with Storybook | Gatsby
With it, you can visualize different states of your UI components and develop them interactively.
Read more >Integrating React Storybook into a Gatsby site - YouTube
Broadcasted live on Twitch -- Watch live at https://www.twitch.tv/irreverentmike.
Read more >Integrating Gatsby, Tailwind, and Storybook - Roman Sorin
A guide to the quick and easy setup of Storybook/Tailwind within Gatsby – two tools that are super helpful and valuable to development...
Read more >Integrations | Storybook: Frontend workshop for UI development
Integrate your tools with Storybook to connect workflows and unlock advanced ... Link stories together to build demos and prototypes with your UI...
Read more >Getting Started with Gatsby - Theme UI
To use Theme UI with Gatsby, install and use gatsby-plugin-theme-ui . ... Add the plugin to your gatsby-config.js . ... Create a theme...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to fix this with the below
main.js
storybook config. As @hasparus says you can force storybook to use emotion 11. Everything seems chill from what I can see!Such a sneaky issue
@theomjones There are two Emotion contexts. Emotion 11 and Emotion 10. You need to either downgrade Theme UI to 0.3.5, enforce Emotion version with Yarn resolutions and webpack aliases in Storybook’s config or upgrade Storybook to a version that depends on Emotion 11 if it exists (PR here: https://github.com/storybookjs/storybook/pull/13300)