Skip to content

Commit

Permalink
Merge pull request #73 from kahirokunn/feature/storybook-page-more
Browse files Browse the repository at this point in the history
storybookに全ページマウントする
  • Loading branch information
kahirokunn authored Jul 25, 2019
2 parents 5466f40 + 76323c0 commit d24f1d2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 40 deletions.
8 changes: 8 additions & 0 deletions config/storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ import {
createStore,
ClassBasedStoreOption
} from '@/store/root'
import {
userLogin,
} from '@/store/middleware/auth/action'
import {
createVueProvider
} from '@/provider/createVueProvider'

addDecorator(() => {
const container = new Container()
resolveStubProviders(container)
storeModuleProvider(container)
const store = createStore(container.get(ClassBasedStoreOption))
store.dispatch(userLogin())

return {
template: "<v-app><story/></v-app>",
provide: createVueProvider(container),
store,
router: new Router()
}
Expand Down
2 changes: 0 additions & 2 deletions src/layouts/loggedInLayout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<v-app key="loggedInLayout" id="scroll-target" dark>

<template v-if="isLoggedIn">
<Navigation />
<LoggedInHeader />
Expand All @@ -11,7 +10,6 @@
<slot />
</v-content>
</template>

</v-app>
</template>

Expand Down
49 changes: 11 additions & 38 deletions src/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,18 @@ import {
action
} from '@storybook/addon-actions'
import MyButton from '../components/MyButton.vue'
import LoginPage from '@/pages/user/login.vue'


storiesOf('Button', module)
.add('with text', () => ({
components: {
MyButton
},
template: '<my-button @click="action">Hello Button</my-button>',
methods: {
action: action('clicked')
}
}))
.add('with text2', () => ({
components: {
MyButton
},
template: '<my-button @click="action">Hello Button 2</my-button>',
methods: {
action: action('clicked')
}
}))
.add('with some emoji', () => ({
components: {
MyButton
},
template: '<my-button @click="action">😀 😎 👍 💯</my-button>',
methods: {
action: action('clicked')
}
}))

storiesOf('Page', module)
.add('LoginPage', () => ({
// page一覧をauto loadする
const pageStory = storiesOf('Pages', module)
const req = require.context('../pages', true, /.vue$/)
req.keys().forEach(vueFileName => {
const tmp = vueFileName.split('/')
const componentNameBase = tmp[tmp.length - 1]
const componentName = componentNameBase.slice(0, componentNameBase.length - '.vue'.length)
pageStory.add(vueFileName, () => ({
components: {
LoginPage,
},
template: '<LoginPage/>',
methods: {
action: action('clicked')
[componentName]: req(vueFileName).default
},
template: `<${componentName}/>`
}))
})
4 changes: 4 additions & 0 deletions src/testConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// tslint:disable-next-line ordered-imports
import { Upload } from 'element-ui'
import 'reflect-metadata'
import Vue from 'vue'
import ProxyComponent from 'vue-proxy-component'
import Router from 'vue-router'
import Vuetify from 'vuetify'
import Vuex from 'vuex'
Expand All @@ -19,3 +21,5 @@ Vue.use(Vuetify, {
success: '#4caf50',
},
})
Vue.use(ProxyComponent)
Vue.use(Upload)

0 comments on commit d24f1d2

Please sign in to comment.