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

Use multiple Frameworks on Storybook #3889

Closed
fabianmieller opened this issue Jul 17, 2018 · 37 comments
Closed

Use multiple Frameworks on Storybook #3889

fabianmieller opened this issue Jul 17, 2018 · 37 comments

Comments

@fabianmieller
Copy link

Hello,
are any updates to the Issue: #1704 ?

I would like to use the React and Vue Framework on the Storybook.

Thanks.
Fabian

@tmeasday
Copy link
Member

I think this is basically the same ask as using the one manager for multiple preview iframes also (even if they are all using the same framework), which is useful for users using a monorepo too.

@ndelangen and I spoke briefly about this; I suspect it might come out in the wash with the changes made to support documentation mode, but I am not sure.

@ndelangen
Copy link
Member

More likely after, but I might do it in between too if an easy implementation comes to me in the shower.

Splitting Manager from Preview webpack would be step 1
Splitting previews from each other is step 2

@stale stale bot added the inactive label Aug 16, 2018
@ndelangen
Copy link
Member

@Hypnosphi
Copy link
Member

Hypnosphi commented Apr 24, 2019

What if we implement frameworks support as decorators for @storybook/html? For example, here's how @storybook/addon-react could look like:
https://github.com/JetBrains/ring-ui/blob/develop-storybook/.storybook/react-decorator.js

@ndelangen
Copy link
Member

That's a really good insight @Hypnosphi

@Downchuck
Copy link

@Hypnosphi I ended up in the same spot -- I've just got a wrapper returning React elements as DOM to the HTML DOM framework. The react plugin spits some warnings to console but it's otherwise working. I've mixed angular1 and react, and used angular2react to show components working across a single storybook.

@btecu
Copy link

btecu commented Oct 1, 2019

Is this part of 5.2.0? I couldn't find anything about it in the release notes.

@shilman shilman modified the milestones: 5.2.x, 5.3.0 Oct 1, 2019
@shilman
Copy link
Member

shilman commented Oct 1, 2019

@btecu Nope, the issue is still work in progress

@TheEvilDev
Copy link

Same, this would be very useful, we have a design system where we vend out support for React and basic HTML via CSS, and having source code and preview widgets support that would be awesome.

Any suggestions where a change like this would need to take place? I may be able to take a stab at it.

@krankur
Copy link

krankur commented Apr 27, 2020

Does #9210 address this issue? If yes, then it looks like this feature has already been added. Correct me if I am wrong.

@shilman
Copy link
Member

shilman commented Apr 27, 2020

@krankur yeah #9210 should support this. however, until there are good examples of multi-framework storybooks and the workflows are well-documented, i'd like to leave this open.

@krankur
Copy link

krankur commented Apr 27, 2020

@shilman thanks. I am working on a project that is using both angularjs and angular as we are in process of migrating. I was considering storybook for this project. A documentation for this would be very helpful.

@shilman shilman modified the milestones: 6.0, 6.0 composition May 8, 2020
@jakobsen9
Copy link

Is there any status update on examples and/or docs for this feature?

@adamchenwei
Copy link

@shilman link broken

@shilman
Copy link
Member

shilman commented Aug 14, 2020

@shilman
Copy link
Member

shilman commented Oct 12, 2020

Until we come up with something better, composition is the officially supported way to do multi-framework Storybook. Moving this to 7.0 unless somebody wants to work on it earlier.

@kairos2109
Copy link

@littlefengers shared a (probably easier) custom implementation of multiple Source tabs:

multiple source tabs

Perhaps in the roadmap too? @shilman

@fenilli
Copy link

fenilli commented Jan 20, 2022

@littlefengers shared a (probably easier) custom implementation of multiple Source tabs:

multiple source tabs

Perhaps in the roadmap too? @shilman

With this approach they used the controls still stays as react props, how about an option to disable/enable top level roots so we can use the toolbars & globals to toggle between certain frameworks when using composition?

@fenilli
Copy link

fenilli commented Jan 20, 2022

Would it be possible for 7.0 instead of using composition to get other running instances of storybook, to instead also be able to use a top level storybook that compiles other storybooks used in refs and embedding them in a single running instance?

If there are multiple frameworks, it could detected automatically based on the root of the config file being used and the package.json, or It could be something similar on how builders are being implemented { framework: 'react' }, and It would embed to the main storybook how to handle react components, when you use a story that is made using react ( it could know because the main.js from that file is using stories only for react ), it would use those framework handlers to show those specific addons for react, if other framework, same idea, use handlers for vue3/svelte and so on.

@vic1707
Copy link

vic1707 commented Jul 8, 2022

Any updates ? I'd like to get React and SolidJs (I know it's not officially supported yet) on the same storybook

@shilman
Copy link
Member

shilman commented Jul 9, 2022

At this time, composition is still the way to go.

https://storybook.js.org/docs/react/sharing/storybook-composition/

The reason we're not investing more in getting multiple frameworks running in a single instance is because we get an insane number of support requests about webpack/babel configuration, and supporting multiple frameworks will increase configuration complexity.

Once we've fixed the performance and configuration issues with single-framework storybook, we might have an appetite to try to tackle this again. In the meantime, we'll continue to make composition better.

pwolfert added a commit to CMSgov/design-system that referenced this issue Feb 7, 2023
Unfortunately I'd need to change the `framework` config for storybook, and you [can't currently mix frameworks](storybookjs/storybook#3889). Going to revert this but wanted a record of the journey
@oranmis
Copy link

oranmis commented Sep 10, 2023

@shilman Is there any update or example for how to do multiple FE frameworks with storybook and tabs like shown above?

I'm creating a design system that should support vue2 and vue3.
I'm using a lerna monorepo with two components packages. one for vue2 and the other for vue3.
Thanks

@herrKlein
Copy link

herrKlein commented Oct 24, 2023

If you want to develop react within a storybook setup for webcomponents. You can use this decorator to render stories.

const meta = {
  title: 'react-in-wc-storybook',
  decorators: [(Story) => {
    const domNode = document.createElement('div');
    createRoot(domNode).render(<Story />);
    return domNode;
  }],
};

We have a storybook with webcomponents and react wrappers around those webcomponents. To test these wrappers we can now just render the react components within the storybook webcomponent instance.

@babipal
Copy link

babipal commented Mar 4, 2024

const meta = {
  title: 'react-in-wc-storybook',
  decorators: [(Story) => {
    const domNode = document.createElement('div');
    createRoot(domNode).render(<Story />);
    return domNode;
  }],
};

Hi, I'm trying to do exactly this. Building components in web components, and have React wrappers of them, and want to demo them in Storybook. Do you have a full example of a story like that? For example, where is document declared? And createRoot?

@bildungsroman
Copy link

Now that version 8 is out, is there an update one this? I have a React app that is the wrapper for a Pixi canvas app, and I'd like to use Storybook with both the React app and the individual Pixi components via the pixijs/storybook framework.

@Hanawa02
Copy link

I'm also wondering if there are any updates for this. I have an Astro project where we have both Vue and React components, and would like to have both in the same storybook setup.

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