mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
CLI templates: HTML => module format
This commit is contained in:
parent
f44959a445
commit
fa662da49d
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user