-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme from ThemeProvider is not passed down to component from module #9939
Comments
I use the following workaround: File: import React from 'react'
import { addDecorator } from '@storybook/react'
import { ThemeProvider } from 'styled-components'
import theme from '../src/themes/light'
addDecorator((story) => (
<ThemeProvider theme={theme}>
{story()}
</ThemeProvider>
)) |
@danielbayerlein starting in 6.0 this will be the recommended way to do things: #10028 |
This method doesn't work for stories of components that are related through "yarn link...." |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
Describe the bug
The components are styled using styled-component.
I am using
@storybook/addon-contexts/
to control the theme of the components and generally it works well. However when I write a story of a component the lives in other project (related by symlink) the theme is undefined.To Reproduce
Steps to reproduce the behavior:
Create a storybook project
link it to a react project (yarn link...)
write story of a component from the linked project that is styled with style-component
(i.e
background-color: ${p => p.theme.palette.white};
is applied on the component).Expected behavior
The theme should be present in the component rendered from the story.
Screenshots
Code snippets
webpack.config.js
.storybook/main.js
.storybook/preview.js
.storybook/config.contexts.js
System:
Environment Info: System: OS: macOS 10.15.3 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Binaries: Node: 12.15.0 - /usr/local/bin/node Yarn: 1.22.0 - /usr/local/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Browsers: Chrome: 80.0.3987.87 Safari: 13.0.5 npmPackages: @storybook/addon-actions: ^5.3.13 => 5.3.13 @storybook/addon-backgrounds: ^5.3.13 => 5.3.13 @storybook/addon-contexts: ^5.3.13 => 5.3.13 @storybook/addon-knobs: ^5.3.13 => 5.3.13 @storybook/addon-links: ^5.3.13 => 5.3.13 @storybook/addon-options: ^5.3.13 => 5.3.13 @storybook/addon-viewport: ^5.3.13 => 5.3.13 @storybook/addons: ^5.3.13 => 5.3.13 @storybook/react: ^5.3.13 => 5.3.13
The text was updated successfully, but these errors were encountered: