-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#14: Extend the supported frameworks to Vue
- Loading branch information
Showing
16 changed files
with
125 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { withContexts } from './dist/preview/frameworks/react'; | ||
export { withContexts }; | ||
export default withContexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
import { makeDecorator } from '@storybook/addons'; | ||
import { ID, PARAM } from './constants'; | ||
import { wrapper } from './preview'; | ||
import { WithContexts } from './@types'; | ||
|
||
export const withContexts: WithContexts = makeDecorator({ | ||
name: ID, | ||
parameterName: PARAM, | ||
skipIfNoParametersOrOptions: true, | ||
allowDeprecatedUsage: false, | ||
wrapper, | ||
}); | ||
import { withContexts } from './preview/frameworks/react'; | ||
export { withContexts }; | ||
export default withContexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { getAddonDecorator } from '../index'; | ||
import { addonContextsAPI } from '../api'; | ||
import { Renderer } from '../../@types'; | ||
|
||
export const renderReact: Renderer = (...arg) => { | ||
const { getRenderFrom } = addonContextsAPI(); | ||
return getRenderFrom(React.createElement)(...arg); | ||
}; | ||
|
||
export const withContexts = getAddonDecorator(renderReact); | ||
|
||
export default withContexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Vue, { Component } from 'vue'; | ||
import { getAddonDecorator } from '../index'; | ||
import { addonContextsAPI } from '../api'; | ||
import { ID } from '../../constants'; | ||
import { Renderer } from '../../@types'; | ||
|
||
export const renderVue: Renderer = (nodes, props, next) => { | ||
const { getRenderFrom, updateReactiveSystem } = addonContextsAPI(); | ||
const reactiveProps = updateReactiveSystem(props); | ||
return Vue.extend({ | ||
name: ID, | ||
data: () => reactiveProps, | ||
render: (createElement) => | ||
getRenderFrom((component, props, children) => | ||
createElement(component, { props }, [children]) | ||
)(nodes, reactiveProps, () => createElement(next() as Component)), | ||
}); | ||
}; | ||
|
||
export const withContexts = getAddonDecorator(renderVue); | ||
|
||
export default withContexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
export { reactWrapper as wrapper } from './react'; | ||
import { makeDecorator } from '@storybook/addons'; | ||
import { addonContextsAPI } from './api'; | ||
import { ID, PARAM } from '../constants'; | ||
import { GetAddonDecorator, Wrapper } from '../@types'; | ||
|
||
export const getAddonDecorator: GetAddonDecorator = (render) => { | ||
const wrapper: Wrapper = (getStory, context, settings) => { | ||
const { getContextNodes, getSelectionState, getPropsMap } = addonContextsAPI(); | ||
const nodes = getContextNodes(settings); | ||
const state = getSelectionState(); | ||
const props = getPropsMap(nodes, state); | ||
return render(nodes, props, () => getStory(context)); | ||
}; | ||
|
||
return makeDecorator({ | ||
name: ID, | ||
parameterName: PARAM, | ||
skipIfNoParametersOrOptions: true, | ||
allowDeprecatedUsage: false, | ||
wrapper, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { withContexts } from './dist/preview/frameworks/vue'; | ||
export { withContexts }; | ||
export default withContexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1068,7 +1068,7 @@ | |
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b" | ||
integrity sha512-vTCdPp/T/Q3oSqwHmZ5Kpa9oI7iLtGl3RQaA/NyLHikvcrPxACkkKVr/XzkSPJWXHRhKGzVvb0urJsbMlRxi1Q== | ||
|
||
"@storybook/[email protected]", "@storybook/addons@^5.0.6": | ||
"@storybook/[email protected]", "@storybook/addons@^5.0.0": | ||
version "5.0.6" | ||
resolved "https://registry.yarnpkg.com/@storybook/addons/-/addons-5.0.6.tgz#3ecb7fd8421e6557b1abc71ebede905e8decfebc" | ||
integrity sha512-VZFYnckWRErkOTZG3a3y7jvnPUjOsTCbWSxvJVMM5SfPzlZbcUz16wJDCJ/pQWI0VzhHFEAVfae9DcuiF031Ow== | ||
|
@@ -1093,7 +1093,7 @@ | |
dependencies: | ||
core-js "^2.6.5" | ||
|
||
"@storybook/components@^5.0.6": | ||
"@storybook/components@^5.0.0": | ||
version "5.0.6" | ||
resolved "https://registry.yarnpkg.com/@storybook/components/-/components-5.0.6.tgz#de77af3443f771d94a692edb719bc0d8c0149daf" | ||
integrity sha512-C++A39n9O09PU2e4Y8x/zbZ+Tf0t/mfPw83Mkh8d8OHS4rHdVKEhq6QC8oDuqT9YBNhJOohtg5d9n+7s8sqZyQ== | ||
|
@@ -1218,6 +1218,11 @@ | |
dependencies: | ||
"@types/jest-diff" "*" | ||
|
||
"@types/node@^11.13.2": | ||
version "11.13.2" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.2.tgz#dc85dde46aa8740bb4aed54b8104250f8f849503" | ||
integrity sha512-HOtU5KqROKT7qX/itKHuTtt5fV0iXbheQvrgbLNXFJQBY/eh+VS5vmmTAVlo3qIGMsypm0G4N1t2AXjy1ZicaQ== | ||
|
||
"@types/prop-types@*": | ||
version "15.7.0" | ||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.0.tgz#4c48fed958d6dcf9487195a0ef6456d5f6e0163a" | ||
|
@@ -1236,6 +1241,13 @@ | |
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" | ||
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== | ||
|
||
"@types/vue@^2.0.0": | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/@types/vue/-/vue-2.0.0.tgz#ec77b3d89591deb9ca5cb052368aa9c32be088e7" | ||
integrity sha1-7Hez2JWR3rnKXLBSNoqpwyvgiOc= | ||
dependencies: | ||
vue "*" | ||
|
||
"@types/yargs@^12.0.2", "@types/yargs@^12.0.9": | ||
version "12.0.10" | ||
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.10.tgz#17a8ec65cd8e88f51b418ceb271af18d3137df67" | ||
|
@@ -5412,6 +5424,11 @@ [email protected]: | |
core-util-is "1.0.2" | ||
extsprintf "^1.2.0" | ||
|
||
vue@*, vue@^2.6.10: | ||
version "2.6.10" | ||
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.10.tgz#a72b1a42a4d82a721ea438d1b6bf55e66195c637" | ||
integrity sha512-ImThpeNU9HbdZL3utgMCq0oiMzAkt1mcgy3/E6zWC/G6AaQoeuFdsl9nDhTDU3X1R6FK7nsIUuRACVcjI+A2GQ== | ||
|
||
w3c-hr-time@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045" | ||
|