Skip to content

Commit a13dcf0

Browse files
committed
re-introduce uui form story
1 parent a379df3 commit a13dcf0

File tree

1 file changed

+47
-63
lines changed

1 file changed

+47
-63
lines changed

packages/uui-form-layout-item/lib/form.story.ts renamed to packages/uui-form/lib/uui-form.story.ts

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Story } from '@storybook/web-components';
22
import { html } from 'lit-html';
3+
import '@umbraco-ui/uui-form/lib/index';
34
import '@umbraco-ui/uui-checkbox/lib';
45
import '@umbraco-ui/uui-slider/lib';
56
import '@umbraco-ui/uui-radio/lib';
67
import '@umbraco-ui/uui-toggle/lib';
78
import { UUIRadioGroupEvent } from '@umbraco-ui/uui-radio/lib/UUIRadioGroupEvent';
89

910
export default {
10-
id: 'form',
11-
title: 'Inputs/Form/Overview',
11+
id: 'uui-form',
12+
title: 'Inputs/Form/Form',
13+
component: 'uui-form',
1214
};
1315

1416
const _onRadioGroupChanged = (e: UUIRadioGroupEvent) => {
@@ -17,6 +19,7 @@ const _onRadioGroupChanged = (e: UUIRadioGroupEvent) => {
1719

1820
const _onSubmit = (e: SubmitEvent) => {
1921
e.preventDefault();
22+
console.log('SUBMIT', e);
2023

2124
const form = e.target as HTMLFormElement;
2225
const isValid = form.checkValidity();
@@ -33,11 +36,8 @@ const _onSubmit = (e: SubmitEvent) => {
3336
};
3437

3538
export const Overview: Story = () => {
36-
return html`<form
37-
id="MyForm"
38-
novalidate
39-
@submit="${_onSubmit}"
40-
style="max-width: 800px;">
39+
return html` <uui-form>
40+
<form @submit="${_onSubmit}">
4141
<uui-form-layout-item>
4242
<uui-label slot="label">Checkbox</uui-label>
4343
<uui-checkbox
@@ -120,63 +120,47 @@ export const Overview: Story = () => {
120120
</uui-button>
121121
</div>
122122
</form>
123-
124-
<!-- Submit Handler
125-
const form = document.getElementById('MyForm');
126-
127-
form.addEventHandler('submit', (e) => {
128-
e.preventDefault();
129-
130-
const isValid = form.checkValidity();
131-
132-
if (!isValid) {
133-
return;
134-
}
135-
136-
const formData = new FormData(form);
137-
138-
for (const value of formData.values()) {
139-
console.log(value);
140-
}
141-
});
142-
--> `;
123+
</uui-form>`;
143124
};
144125

145126
/*
146-
<uui-form-layout-item>
147-
<uui-label slot="label">Native Checkbox</uui-label>
148-
<input
149-
name="nativeCheckbox"
150-
label="Native input text"
151-
type="checkbox"
152-
value="NativeCheckboxValue"
153-
placeholder="native text input"
154-
required />
155-
</uui-form-layout-item>
156-
157-
<uui-form-layout-item>
158-
<uui-label slot="label">Native Input</uui-label>
159-
<input
160-
name="nativeInput"
161-
label="Native input text"
162-
type="text"
163-
default-value="default test value"
164-
value="test value"
165-
placeholder="native text input"
166-
required />
167-
</uui-form-layout-item>
168-
169-
<uui-form-layout-item>
170-
<uui-label slot="label">Native Input</uui-label>
171-
<input
172-
style="width: 100%;"
173-
name="nativeInputNumber"
174-
label="Native input number"
175-
type="number"
176-
value=""
177-
placeholder="native number input"
178-
min="0"
179-
max="10"
180-
required />
181-
</uui-form-layout-item>
127+
128+
129+
<uui-form-layout-item>
130+
<uui-label slot="label">Native Checkbox</uui-label>
131+
<input
132+
name="nativeCheckbox"
133+
label="Native input text"
134+
type="checkbox"
135+
value="NativeCheckboxValue"
136+
placeholder="native text input"
137+
required />
138+
</uui-form-layout-item>
139+
140+
<uui-form-layout-item>
141+
<uui-label slot="label">Native Input</uui-label>
142+
<input
143+
name="nativeInput"
144+
label="Native input text"
145+
type="text"
146+
default-value="default test value"
147+
value="test value"
148+
placeholder="native text input"
149+
required />
150+
</uui-form-layout-item>
151+
152+
<uui-form-layout-item>
153+
<uui-label slot="label">Native Input</uui-label>
154+
<input
155+
style="width: 100%;"
156+
name="nativeInputNumber"
157+
label="Native input number"
158+
type="number"
159+
value=""
160+
placeholder="native number input"
161+
min="0"
162+
max="10"
163+
required />
164+
</uui-form-layout-item>
165+
182166
*/

0 commit comments

Comments
 (0)