lion/packages/switch/stories/index.stories.js
Thomas Allmer 396deb2e3b feat: finalize validation and adopt it everywhere
Co-authored-by: Alex Ghiu <alex.ghiu@ing.com>
Co-authored-by: Gerjan van Geest <Gerjan.van.Geest@ing.com>
Co-authored-by: Thijs Louisse <Thijs.Louisse@ing.com>
Co-authored-by: Joren Broekema <joren.broekema@ing.com>
Co-authored-by: Erik Kroes <erik.kroes@ing.com>
2019-11-18 15:30:08 +01:00

49 lines
1.1 KiB
JavaScript

import { storiesOf, html } from '@open-wc/demoing-storybook';
import { Validator } from '@lion/validate';
import '../lion-switch.js';
import '../lion-switch-button.js';
storiesOf('Buttons|Switch', module)
.add(
'Default',
() => html`
<lion-switch label="Label" help-text="Help text"></lion-switch>
`,
)
.add(
'Disabeld',
() => html`
<lion-switch label="Label" disabled></lion-switch>
`,
)
.add('Validation', () => {
class IsTrue extends Validator {
constructor() {
super();
this.name = 'IsTrue';
}
execute(value) {
return !value.checked;
}
static async getMessage() {
return "You won't get the latest news!";
}
}
return html`
<lion-switch
id="newsletterCheck"
name="newsletterCheck"
label="Subscribe to newsletter"
.validators="${[new IsTrue(null, { type: 'info' })]}"
></lion-switch>
`;
})
.add(
'Button',
() => html`
<lion-switch-button aria-label="Toggle button"></lion-switch-button>
`,
);