storybook-handlebars
v4.1.3-beta.1
Published
Storybook for Handlebars.
Downloads
21
Readme
Storybook for Handlebars
Storybook for Handlebars is a UI development environment for your Handlebars snippets. With it, you can visualize different states of your UI components and develop them interactively.
Storybook runs outside of your app. So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
Getting Started
cd my-app
npx -p @storybook/cli sb init -t html
For more information visit: storybook.js.org
Storybook also comes with a lot of addons and a great API to customize as you wish. You can also build a static version of your storybook and deploy it anywhere you want.
Examples
/* global document */
import { storiesOf } from 'storybook-handlebars';
storiesOf('Demo', module)
.add('heading', () => '<h1>Hello World</h1>')
.add('button', () => {
let component = {
template: "<h1>Hello World</h1>",
styles: "h1 { color:red; }",
scripts: "console.info('hello world');"
}
return component;
});
Decorator
You can also expose this functionality as a Storybook decorator and use it like this.
import { storiesOf, withData, withHelpers, withPartials, withStyles, withScripts } from 'storybook-handlebars';
storiesOf('Demo', module)
.addDecorator(withHelpers( {
test: function () {
console.log('helper')
}
}))
.addDecorator(withPartials({ hello:'{{name}}' }))
// Withdata needs to be after by withHelpers and withHelpers
.addDecorator(withData({
msg: 'withData test',
name: "storybook-handlebars"
}))
.addDecorator(withStyles("h1 { color: red }"))
.addDecorator(withScripts({
script: `console.log("withScripts");`
}))
You can also add a decorator globally for all stories like this.
import { withHelpers } from 'storybook-handlebars';
addDecorator(withHelpers( {
test: function () {
console.log('globally helper')
}
}))
build
npm run build
or
npm pack