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

feat: add Vue support to @addons/background #3488

Merged
merged 9 commits into from
Apr 26, 2018

Conversation

wuweiweiwu
Copy link
Member

@wuweiweiwu wuweiweiwu commented Apr 25, 2018

Issue:
fixes #2845

What I did

added a new decorator export for @addons/background/vue

How to test

yarn test --core

Is this testable with Jest or Chromatic screenshots? y
Does this need a new example in the kitchen sink apps? y
Does this need an update to the documentation? y

If your answer is yes to any of these, please make sure to include it in your PR.

For maintainers only: Please tag your pull request with at least one of the following:
["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]


import addons from '@storybook/addons';
const Background = window.STORYBOOK_ENV === 'vue' ? VueBackground : ReactBackground;
Copy link
Member

Choose a reason for hiding this comment

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

The problem with this approach is that now you bring Vue to react storybook bundle when it's not actually needed. In knobs, we decided to have separate entry points for each framework:

import { withKnobs } from '@storybook/addon-knobs/react'

see #1832 for reference

Copy link
Member

@Hypnosphi Hypnosphi Apr 25, 2018

Choose a reason for hiding this comment

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

But actually, there's a chance we come up with a generic framework-agnostic solution for addons like this, which only add subscriptions but don't render anything inside preview iframe:

See #3475 (comment)

In this case, there will be no need in having different decorators in different frameworks

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 see. I will follow this up with a PR to update @addons/centered since this is what it is currently doing.

generic framework agnostic addons would awesome!

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I wait for subscriptionStore to be merged? or should I just do framework specific exports for now?

Copy link
Member

@Hypnosphi Hypnosphi Apr 25, 2018

Choose a reason for hiding this comment

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

I think you can add a temporary vue entry point without renaming index to react

@codecov
Copy link

codecov bot commented Apr 26, 2018

Codecov Report

Merging #3488 into master will increase coverage by <.01%.
The diff coverage is 62.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3488      +/-   ##
==========================================
+ Coverage   37.42%   37.43%   +<.01%     
==========================================
  Files         455      457       +2     
  Lines       10296    10304       +8     
  Branches      934      912      -22     
==========================================
+ Hits         3853     3857       +4     
- Misses       5860     5878      +18     
+ Partials      583      569      -14
Impacted Files Coverage Δ
addons/background/vue.js 100% <100%> (ø)
addons/background/src/vue.js 57.14% <57.14%> (ø)
addons/knobs/vue.js 0% <0%> (-100%) ⬇️
lib/codemod/src/transforms/move-buildin-addons.js 46.87% <0%> (ø) ⬆️
...i/src/modules/ui/components/stories_panel/index.js 20.63% <0%> (ø) ⬆️
...tions/src/lib/types/function/createFunctionEval.js 77.77% <0%> (ø) ⬆️
addons/knobs/src/components/types/Text.js 8.77% <0%> (ø) ⬆️
addons/storysource/src/loader/traverse-helpers.js 60.86% <0%> (ø) ⬆️
...dons/actions/src/lib/types/object/getObjectName.js 62.5% <0%> (ø) ⬆️
lib/ui/src/modules/ui/components/layout/index.js 29.33% <0%> (ø) ⬆️
... and 68 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9f890f...a24fc42. Read the comment docs.

@wuweiweiwu
Copy link
Member Author

@Hypnosphi fixed! :)

@@ -30,6 +30,9 @@
"prop-types": "^15.6.1",
"react-lifecycles-compat": "^3.0.2"
},
"devDependencies": {
"vue": "^2.5.16"
},
"peerDependencies": {
"react": "*"
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 we should remove this peerDependency now (and suppress corresponding ESLint warnings)

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean the react or the vue dependency? or should I just remove both?

Copy link
Member Author

Choose a reason for hiding this comment

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

or should I move the react dep into devDependencies

Copy link
Member

Choose a reason for hiding this comment

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

I mean react. In devDependencies, you can have anything that's used in tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good! Thanks for clarifying

@ndelangen ndelangen merged commit d6b49ec into storybookjs:master Apr 26, 2018
@dietergeerts
Copy link

I can't find these changes in v3.4.6. Is this not released yet?

@Keraito
Copy link
Contributor

Keraito commented Jun 7, 2018

@dietergeerts, these changes were released on the alpha version, specifically at v4.0.0-alpha.4.

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.

5 participants