CLI templates: HTML => module format

This commit is contained in:
Michael Shilman 2019-07-20 17:03:18 +08:00
parent f44959a445
commit fa662da49d
2 changed files with 15 additions and 17 deletions

View File

@ -1,9 +1,4 @@
import { configure } from '@storybook/html';
import { load } from '@storybook/html';
// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /\.stories\.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);
load(require.context('../stories', true, /\.stories\.js$/), module);

View File

@ -1,12 +1,15 @@
import { document, console } from 'global';
import { storiesOf } from '@storybook/html';
storiesOf('Demo', module)
.add('heading', () => '<h1>Hello World</h1>')
.add('button', () => {
const button = document.createElement('button');
button.type = 'button';
button.innerText = 'Hello Button';
button.addEventListener('click', e => console.log(e));
return button;
});
export default {
title: 'Demo',
};
export const heading = () => '<h1>Hello World</h1>';
export const button = () => {
const btn = document.createElement('button');
btn.type = 'button';
btn.innerText = 'Hello Button';
btn.addEventListener('click', e => console.log(e));
return btn;
};