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

Renderer React: first example of multiframework support using decorators #6826

Closed
wants to merge 27 commits into from

Conversation

Hypnosphi
Copy link
Member

@Hypnosphi Hypnosphi commented May 19, 2019

Issue: #3889

TODO:

  • Create an addon for rendering React stories in @storybook/html
  • Copy some of the stories from offitial storybook to HTML examples
  • Add docs
  • Move more stuff from @storybook/react to @storybook/renderer-react

Includes changes from #7791

@vercel
Copy link

vercel bot commented May 19, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/g9ijbqng0
🌍 Preview: https://monorepo-git-addon-react.storybook.now.sh

@Hypnosphi Hypnosphi changed the title [WIP] Addon React: POC of multiframework support using decorators [WIP] Addon React: POC for multiframework support using decorators May 19, 2019
@vercel vercel bot requested a deployment to staging May 19, 2019 21:05 Abandoned
@vercel vercel bot requested a deployment to staging May 19, 2019 21:09 Abandoned
Copy link
Member

@igor-dv igor-dv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a POC I am not sure how deep we need to go with comments, but anyway =)

  1. If we already moving presets out (here in react, but after there will be others), it's better to move them into their own packages, that's how it will be easier to customise them after (maybe even to the sb/presets repo)

  2. in the babelrc we have an overrides for the server code to transpile for node 8, so we need to add there frameworks as well (if there will be a server code there)

@@ -3,8 +3,8 @@ import packageJson from '../../package.json';
export default {
packageJson,
frameworkPresets: [
require.resolve('./framework-preset-react.js'),
require.resolve('@storybook/addon-react/dist/server/framework-preset-react.js'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to have the presets more accessible, something like:

import { presets } from '@storybook/addon-react';

/* blah blah blah */

frameworkPresets: [
  presets.react,
  require.resolve('./framework-preset-cra.js'),
  presets.reactDocgen,
]

also it will be more formatted way for frameworks to expose their presets.

Another option will be hide the particular presets, for example:

import { createPresets } from '@storybook/addon-react';

/* blah blah blah */

frameworkPresets: [
  ...createPresets({
     afterReact: [require.resolve('./framework-preset-cra.js')],
  });
]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can mix preview and server code in one endpoint, so it probably can't be just @storybook/addon-react.

I think I'll make it just @storybook/addon-react/preset after we merge #6828

examples/html-kitchen-sink/.storybook/config.js Outdated Show resolved Hide resolved
@Hypnosphi
Copy link
Member Author

If we already moving presets out (here in react, but after there will be others), it's better to move them into their own packages, that's how it will be easier to customise them after (maybe even to the sb/presets repo)

Creating a separate package makes sense to me, but can we leave the presets that we use internally in monorepo for easier syncing?

in the babelrc we have an overrides for the server code to transpile for node 8, so we need to add there frameworks as well (if there will be a server code there)

It's already under src/server, isn't it enough?

@Hypnosphi
Copy link
Member Author

Hypnosphi commented May 20, 2019

@igor-dv BTW it's not only about presets. I want stuff like globals.js and element_check to be shared between app/react and addons/frameworks/react as well. Where should they live, in your opinion?

Honestly, I think it's no harm to have the app depend on the add-on. Maybe at some point we can even make the app just a wrapper for addon + @storybook/html (the latter should probably be aliased as @storybook/app)

@Hypnosphi Hypnosphi closed this May 20, 2019
@igor-dv
Copy link
Member

igor-dv commented May 20, 2019

@Hypnosphi

Creating a separate package makes sense to me, but can we leave the presets that we use internally in monorepo for easier syncing?

makes sense.

It's already under src/server, isn't it enough?

That what I see now in the babelrc.

       './lib/core/src/server',
        './lib/node-logger',
        './lib/codemod',
        './addons/storyshots',
        './addons/storysource/src/loader',
        './app/**/src/server/**',
        './app/**/src/bin/**',

BTW it's not only about presets. I want stuff like globals.js and element_check to be shared between app/react and addons/frameworks/react as well. Where should they live, in your opinion?

I think those kind of pkgs we can put under the lib.

Honestly, I think it's no harm to have the app depend on the add-on. Maybe at some point we can even make the app just a wrapper for addon + @storybook/html (the latter should probably be aliased as @storybook/app)

Agree with that

@Hypnosphi Hypnosphi reopened this May 20, 2019
@shilman shilman added this to the 5.2.0 milestone May 20, 2019
Hypnosphi added 3 commits May 28, 2019 22:38
# Conflicts:
#	.teamcity/OpenSourceProjects_Storybook/buildTypes/OpenSourceProjects_Storybook_Bootstrap.kt
#	app/react/package.json
#	examples/html-kitchen-sink/package.json
@vercel vercel bot temporarily deployed to staging May 28, 2019 20:54 Inactive
Hypnosphi added 2 commits June 1, 2019 17:30
# Conflicts:
#	app/react/package.json
#	examples/html-kitchen-sink/package.json
# Conflicts:
#	.babelrc.js
#	app/react/package.json
#	examples/html-kitchen-sink/.storybook/presets.js
#	examples/html-kitchen-sink/package.json
@Hypnosphi
Copy link
Member Author

@shilman what's the easiest way to migrate our own examples to module format? I'm talking about https://github.com/storybookjs/storybook/tree/addon-react/examples/html-kitchen-sink/stories/react

@devinus
Copy link

devinus commented Sep 27, 2019

I'm so excited about this. My team will benefit from this exact scenario. We have a storybook for HTML "components" and React components right now, but we're forced to render the React components now.

@shilman shilman modified the milestones: 5.3.0, 5.4.0 Nov 13, 2019
@shilman shilman modified the milestones: 5.4.0, 6.0.0 Dec 16, 2019
@ndelangen ndelangen closed this Feb 14, 2020
@stof stof deleted the addon-react branch May 25, 2022 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants