-
-
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.
Add support for addonKnobs, rename withX to addonX to avoid name coll…
…ision
- Loading branch information
1 parent
5784a79
commit bac1905
Showing
14 changed files
with
162 additions
and
106 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import WrapStory from './WrapStory'; | ||
|
||
/** | ||
* Handles a react story | ||
*/ | ||
export const reactHandler = (channel, knobStore) => getStory => context => { | ||
const initialContent = getStory(context); | ||
const props = { context, storyFn: getStory, channel, knobStore, initialContent }; | ||
return <WrapStory {...props} />; | ||
}; |
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,40 @@ | ||
export const vueHandler = (channel, knobStore) => getStory => context => ({ | ||
render(h) { | ||
const story = getStory(context); | ||
return h(typeof story === 'string' ? { template: story } : story); | ||
}, | ||
|
||
methods: { | ||
onKnobChange(change) { | ||
const { name, value } = change; | ||
// Update the related knob and it's value. | ||
const knobOptions = knobStore.get(name); | ||
knobOptions.value = value; | ||
this.$forceUpdate(); | ||
}, | ||
|
||
onKnobReset() { | ||
knobStore.reset(); | ||
this.setPaneKnobs(false); | ||
this.$forceUpdate(); | ||
}, | ||
|
||
setPaneKnobs(timestamp = +new Date()) { | ||
channel.emit('addon:knobs:setKnobs', { knobs: knobStore.getAll(), timestamp }); | ||
}, | ||
}, | ||
|
||
created() { | ||
channel.on('addon:knobs:reset', this.onKnobReset); | ||
channel.on('addon:knobs:knobChange', this.onKnobChange); | ||
knobStore.subscribe(this.setPaneKnobs); | ||
}, | ||
|
||
beforeDestroy(){ | ||
console.log('beforeDestroy'); | ||
channel.removeListener('addon:knobs:reset', this.onKnobReset); | ||
channel.removeListener('addon:knobs:knobChange', this.onKnobChange); | ||
knobStore.unsubscribe(this.setPaneKnobs); | ||
this.onKnobReset(); | ||
} | ||
}); |
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,3 +1,4 @@ | ||
/* globals window */ | ||
|
||
window.STORYBOOK_REACT_CLASSES = {}; | ||
window.STORYBOOK_ENV = 'react'; |
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
Oops, something went wrong.