Skip to content
This repository was archived by the owner on Jun 9, 2019. It is now read-only.

Commit d6482af

Browse files
committed
only deliver necessary component options
1 parent d1708ad commit d6482af

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

play/MyButton.play.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import Vue from 'vue'
2+
import Vuex from 'vuex'
23
import {play} from '../src/play'
34
import MyButton from './MyButton.vue'
45

56
Vue.component('my-button', MyButton)
67

78
play('Button')
89
.add('with text', {
9-
template: `<my-button :handle-click="log">text</my-button>`,
10+
template: `<my-button :handle-click="log">{{ $store.state.count }}</my-button>`,
11+
store: new Vuex.Store({
12+
state: {count: 0}
13+
}),
1014
methods: {
1115
log() {
12-
this.$log(new Date())
16+
this.$store.state.count++
1317
}
1418
}
1519
})

play/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import MyButton from './MyButton.vue'
22
import Box from './Box.vue'
33

4+
import Vuex from 'vuex'
5+
import Vue from 'vue'
6+
7+
Vue.use(Vuex)
8+
49
const load = requireContext => {
510
return requireContext.keys().map(requireContext)
611
}

src/preview.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,25 @@ export default function () {
4444
}
4545
parent.postMessage({
4646
type: 'SET_SPOTS',
47-
payload: JSON.stringify(spots)
47+
payload: JSON.stringify(purify(spots))
4848
}, location.origin)
4949
},
5050
render(h) {
5151
return h('div', {attrs: {id: 'app'}}, [h(this.current)])
5252
}
5353
})
5454
}
55+
56+
function purify(spots) {
57+
const result = {}
58+
for (const name in spots) {
59+
result[name] = spots[name].map(spot => ({
60+
scenario: spot.scenario,
61+
component: {
62+
example: spot.component.example,
63+
template: spot.component.template
64+
}
65+
}))
66+
}
67+
return result
68+
}

0 commit comments

Comments
 (0)