Skip to content
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

Storybook (with addon-info) + Styled Components #1384

Closed
michaltaberski opened this issue Jun 29, 2017 · 2 comments
Closed

Storybook (with addon-info) + Styled Components #1384

michaltaberski opened this issue Jun 29, 2017 · 2 comments

Comments

@michaltaberski
Copy link
Contributor

Hey,

I am using storybook (with info addon) at web React app. At the same app I am using styled components (https://www.styled-components.com/).

Here is simple case how I am doing this:

LayoutHeader.js

import styled from 'styled-components';

const LayoutHeader = styled.div`
  color: #fff;
  background-color: #000;
`;

export default LayoutHeader;

LayoutHeader.story.js

import { storiesOf } from '@storybook/react';
import React from 'react';

import LayoutHeader from './LayoutHeader';

storiesOf('LayoutHeader', module)
.addWithInfo('with text', () => (
  <LayoutHeader>Simple text</LayoutHeader>
));

The problem is the storybook info output looks like this:

download

Can I somehow process the story so it renders story content as <LayoutHeader /> instead of <styled.div />?

@michaltaberski
Copy link
Contributor Author

michaltaberski commented Jun 29, 2017

I am sorry, my question was too hasty.

The solution is:

LayoutHeader.js

import styled from 'styled-components';

const LayoutHeader = styled.div`
  color: #fff;
  background-color: #000;
`;

LayoutHeader.displayName = 'LayoutHeader';
export default LayoutHeader;

@usulpro
Copy link
Member

usulpro commented Jun 29, 2017

@michaltaberski Thank you for sharing your case!
Perhaps it'd be useful for someone!
I guess we can close it.

@usulpro usulpro closed this as completed Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants