lion/packages/fieldset/stories/index.stories.js
Thomas Allmer ec8da8f12c feat: release inital public lion version
Co-authored-by: Mikhail Bashkirov <mikhail.bashkirov@ing.com>
Co-authored-by: Thijs Louisse <thijs.louisse@ing.com>
Co-authored-by: Joren Broekema <joren.broekema@ing.com>
Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com>
Co-authored-by: Erik Kroes <erik.kroes@ing.com>
Co-authored-by: Lars den Bakker <lars.den.bakker@ing.com>
2019-04-26 10:37:57 +02:00

59 lines
2.2 KiB
JavaScript

import { storiesOf, html, action } from '@open-wc/storybook';
import '../lion-fieldset.js';
storiesOf('Forms|<lion-fieldset>', module)
.add(
'Default',
() => html`
<p>
A native fieldset element should always have a legend-element for a11y purposes. Our
fieldset element is not native and should not have a legend-element. Our fieldset instead
has a label attribute or you can add a label with a div- or heading-element using the
slot="label". Please don't use the the label-element because that is reserved for
input-elements.
</p>
<lion-fieldset name="nameGroup" label="Name">
<lion-input name="FirstName" label="First Name"></lion-input>
<lion-input name="LastName" label="Last Name"></lion-input>
</lion-fieldset>
`,
)
.add(
'Data',
() => html`
<lion-fieldset name="nameGroup" label="Name">
<lion-input name="FirstName" label="First Name" .modelValue=${'Foo'}></lion-input>
<lion-input name="LastName" label="Last Name" .modelValue=${'Bar'}></lion-input>
<button @click=${ev => action('modelValue')(ev.target.parentElement.modelValue)}>
Log to Action Logger
</button>
</lion-fieldset>
`,
)
.add(
'Sub Fieldsets Data',
() => html`
<lion-fieldset>
<div slot="label">Personal data</div>
<lion-fieldset name="nameGroup" label="Name">
<lion-input name="FirstName" label="First Name" .modelValue=${'Foo'}></lion-input>
<lion-input name="LastName" label="Last Name" .modelValue=${'Bar'}></lion-input>
</lion-fieldset>
<lion-fieldset name="location" label="Location">
<lion-input name="country" label="Country" .modelValue=${'Netherlands'}></lion-input>
</lion-fieldset>
<lion-input name="age" label="Age" .modelValue=${21}></lion-input>
<button @click=${ev => action('modelValue')(ev.target.parentElement.modelValue)}>
Log to Action Logger
</button>
<br />
<button
@click=${ev =>
action('modelValue')(ev.target.parentElement.formElements.nameGroup.modelValue)}
>
Log nameGroup to Action Logger
</button>
</lion-fieldset>
`,
);