Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Commit bf75c1e

Browse files
committed
Fix react not defined
- by default, start-storybook use react-jsx 😦
1 parent b1aa9d4 commit bf75c1e

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

template/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
],
1010
"unpkg": "dist/{{name}}.min.js",
1111
"jsdelivr": "dist/{{name}}.min.js",
12-
"main": "dist/{{name}}.js",
13-
"module": "dist/{{name}}.es.js",
12+
"main": "dist/{{name}}.cjs.js",
13+
"module": "dist/{{name}}.m.js",
1414
"files": [
1515
"dist/",
16-
"umd/",
1716
"src/components/",
1817
"src/mixins/"
1918
],

template/src/mixins/useless-button.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@ export default {
77

88
watch: {
99
toggle: function (newVal, oldVal) {
10-
if (!newVal && oldVal) this.textMix = 'The button says: "I HATE REEED!!!"'
10+
if (!newVal && oldVal) {
11+
this.textMix = 'The button says: "I HATE REEED!!!"'
12+
this.revert()
13+
}
1114
if (newVal && !oldVal) this.textMix = 'this text is from mixins/useless-button.js'
1215
}
1316
},
1417

18+
mounted () {
19+
console.log('Any life-cycle function will be executed first')
20+
},
21+
1522
methods: {
16-
clicked () {
17-
this.$action('REVERT BACK!!!', [this.hello])
23+
// any defined methods can not be override with mixin
24+
revert () {
1825
const random = (min, max) => (Math.floor(Math.random() * max) + min)
19-
setTimeout(() => { this.toggle = !this.toggle }, random(700, 5000))
26+
setTimeout(() => {
27+
this.toggle = !this.toggle
28+
this.$emit('click', 'REVERT BACK!!!')
29+
}, random(500, 1000))
2030
}
2131
}
2232
}

template/src/stories/Story1/Scenario1.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default {
3232
methods: {
3333
clicked (helloText) {
3434
{{#isEnabled addons 'actions'}}
35-
this.$action('click', [this.hello])
35+
this.$action('click', helloText)
3636
{{else}}
37-
console.log('click', this.hello)
37+
console.log('click', helloText)
3838
{{/isEnabled}}
3939
}
4040
}

template/src/stories/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Vue from 'vue'
1010
Vue.mixin({
1111
methods: {
1212
$action (label, payload) {
13-
this.$emit('action', label, payload)
13+
if (payload !== undefined) this.$emit('action', label, payload)
14+
else this.$emit('action', label)
1415
}
1516
}
1617
})
@@ -48,9 +49,8 @@ require.context('.', true, /\.vue$/).keys()
4849

4950
const story = () => {
5051
return {
51-
render () {
52-
return <story {{#isEnabled addons 'actions'}}onAction={action(`${storyName}/${componentName}`)} {{/isEnabled}}/>
53-
},
52+
template: '<story @action="act" />',
53+
methods: { act: action(`${storyName}/${componentName}`) },
5454
components: {
5555
'story': Component
5656
}

0 commit comments

Comments
 (0)