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

Unable to render third party components? #930

Closed
natdm opened this issue Apr 22, 2017 · 8 comments
Closed

Unable to render third party components? #930

natdm opened this issue Apr 22, 2017 · 8 comments

Comments

@natdm
Copy link

natdm commented Apr 22, 2017

I'm using react semantic UI to design a frontend and wanted to test some of the components (like making a menu) with storybook. It looks like Storybook does not import any of the libraries used to make the menu. For example:

const NavBar = ({ selected, select, onLogin }: { selected: string, select: (x: string) => void, onLogin: () => void }) => (
    <Menu style={{ marginBottom: 0 }}>
        <Menu.Item name="about" active={selected === 'about'} onClick={() => select('about')}>
            About
        </Menu.Item>

        <Menu.Item name="other" active={selected === 'other'} onClick={() => select('other')}>
            Other
        </Menu.Item>
        <Menu.Menu position="right">
            <Menu.Item>
                <Button content="Login/Signup" icon="right arrow" labelPosition="right" onClick={() => onLogin()} />
            </Menu.Item>
        </Menu.Menu>
    </Menu>
);

And tested with:

import React from 'react';
import { storiesOf } from '@kadira/storybook';
import { NavBar } from '../navigation/navbar';

storiesOf('NavBar', module).add('with withAbout', () => <NavBar />);

Renders:

AboutOther

(just text).

@natdm
Copy link
Author

natdm commented Apr 25, 2017

Bump?

@xavxyz
Copy link
Member

xavxyz commented Apr 26, 2017

Hey @natdm! Thanks for filing an issue!

Looking at their docs, https://react.semantic-ui.com/usage#javascript:

You'll also need to include a stylesheet to provide the styling for your components.

Are you doing so in the config file (docs, see CSS section) or in a head.html file with a <link stylesheet> tag (docs)?

Esle, can you provide a simple reproduction please?

@agustif
Copy link

agustif commented Apr 29, 2017

I tried to use storybook in my boilerplate and didnt succeed too.

Is there anyway to use webpack.config from my main project, or do I need to do a proper config of stories using ../ for routes and such?

I will try and provide a branch with semantic working on homepage but not storybook.

@natdm
Copy link
Author

natdm commented May 5, 2017

@xavcz , I did not, must have missed that. I will have to try it this weekend. Thanks!

@agustif
Copy link

agustif commented May 7, 2017

@natdm, linking the stylesheet from a cdn, will give you semantic-ui vanilla,

If you want to be able to apply theming and such, I can recommend semantic-ui-less which I got to work OK with webpack2 and storybook

@natdm
Copy link
Author

natdm commented Jun 14, 2017

@agustif how/where did you have to link it? Example code snippet?

@natdm
Copy link
Author

natdm commented Jun 14, 2017

Got it.

import { configure } from '@kadira/storybook';
import 'semantic-ui-css/semantic.min.css';
import 'semantic-ui-react';

function loadStories() {
    require('../src/stories');
    require('../src/components/error_modal/story');
}

configure(loadStories, module);

@xavxyz
Copy link
Member

xavxyz commented Jun 14, 2017

Dope!

I believe we can close this issue 😌

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

4 participants