Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 4d74dd5

Browse files
author
Steffan
committed
move example to storybook
1 parent 44f79d7 commit 4d74dd5

File tree

9 files changed

+95
-157
lines changed

9 files changed

+95
-157
lines changed

.storybook/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@storybook/addon-actions/register';

.storybook/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {configure} from '@storybook/vue';
2+
3+
configure(() => {
4+
5+
require('../stories');
6+
7+
}, module);

.storybook/webpack.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const path = require('path');
2+
const VueLoaderPlugin = require('vue-loader/lib/plugin')
3+
4+
module.exports = (baseConfig, configType, config) => {
5+
6+
// remove babel-loader
7+
config.module.rules.shift();
8+
9+
// add buble-loader
10+
config.module.rules.unshift({
11+
test: /\.js$/,
12+
exclude: /node_modules/,
13+
use: 'buble-loader'
14+
});
15+
16+
// add alias
17+
config.resolve.alias['vue-event-manager'] = path.resolve(__dirname, '../src')
18+
19+
// https://github.com/storybooks/storybook/issues/3267
20+
config.plugins.push(new VueLoaderPlugin());
21+
22+
return config;
23+
};

examples/demo/demo.details

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/demo/demo.html

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/demo/demo.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

examples/index.html

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<template>
2+
3+
<div class="container">
4+
5+
<h1>Event Manager</h1>
6+
7+
<hr>
8+
9+
<button class="btn btn-primary" type="button" @click="$trigger('test', 'this.$trigger')">Trigger 'test' event using instance method</button>
10+
<button class="btn btn-primary" type="button" @click="trigger('test', 'Vue.events.trigger')">Trigger 'test' event using global method</button>
11+
12+
</div>
13+
14+
</template>
15+
16+
<script>
17+
18+
import Vue from 'vue';
19+
20+
export default {
21+
22+
methods: {
23+
24+
trigger(event, params) {
25+
Vue.events.trigger(event, params);
26+
}
27+
28+
},
29+
30+
events: {
31+
32+
test(...args) {
33+
console.log(...args);
34+
}
35+
36+
}
37+
38+
};
39+
40+
</script>
41+
42+
<style>
43+
44+
@import url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css');
45+
46+
</style>

stories/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Vue from 'vue';
2+
import VueEventManager from 'vue-event-manager';
3+
import DefaultStory from './components/DefaultStory.vue';
4+
import {storiesOf} from '@storybook/vue';
5+
import {action} from '@storybook/addon-actions';
6+
7+
// load plugin
8+
Vue.use(VueEventManager, {
9+
10+
// log event action
11+
log({name, params}) {
12+
action(name)(...params);
13+
}
14+
15+
});
16+
17+
storiesOf('Event Manager', module)
18+
.add('Default', () => ({extends: DefaultStory}));

0 commit comments

Comments
 (0)