-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1a3d04
commit 79bf7ef
Showing
10 changed files
with
221 additions
and
76 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
bau-ui/examples/bau-storybook/src/pages/calendar/calendar-controlled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Context } from "@grucloud/bau-ui/context"; | ||
import button from "@grucloud/bau-ui/button"; | ||
import calendar from "@grucloud/bau-ui/calendar"; | ||
|
||
export default (context: Context) => { | ||
const { bau } = context; | ||
const { form, footer, article, label } = bau.tags; | ||
|
||
const Calendar = calendar(context); | ||
const ButtonSubmit = button(context, { | ||
variant: "outline", | ||
color: "primary", | ||
}); | ||
|
||
return () => { | ||
const calendarState = bau.state("2023-08-08"); | ||
|
||
const onsubmit = (event: any) => { | ||
event.preventDefault(); | ||
const payload = Object.fromEntries(new FormData(event.currentTarget)); | ||
alert(JSON.stringify(payload)); | ||
}; | ||
|
||
return form( | ||
{ onsubmit }, | ||
article( | ||
label( | ||
"Start date:", | ||
Calendar({ | ||
name: "start", | ||
min: "2023-01-01", | ||
max: "2024-12-31", | ||
oninput: (event: any) => { | ||
calendarState.val = event.target.value; | ||
}, | ||
}) | ||
) | ||
), | ||
footer(ButtonSubmit({ type: "submit" }, "Submit")) | ||
); | ||
}; | ||
}; |
28 changes: 0 additions & 28 deletions
28
bau-ui/examples/bau-storybook/src/pages/calendar/calendar-example-default.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
bau-ui/examples/bau-storybook/src/pages/calendar/calendar-uncontrolled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Context } from "@grucloud/bau-ui/context"; | ||
import button from "@grucloud/bau-ui/button"; | ||
import calendar from "@grucloud/bau-ui/calendar"; | ||
|
||
export default (context: Context) => { | ||
const { bau } = context; | ||
const { form, footer, article, label } = bau.tags; | ||
|
||
const Calendar = calendar(context); | ||
const ButtonSubmit = button(context, { | ||
variant: "outline", | ||
color: "primary", | ||
}); | ||
|
||
return () => { | ||
const onsubmit = (event: any) => { | ||
event.preventDefault(); | ||
const payload = Object.fromEntries(new FormData(event.currentTarget)); | ||
alert(JSON.stringify(payload)); | ||
}; | ||
|
||
return form( | ||
{ onsubmit }, | ||
article( | ||
label( | ||
"Start date:", | ||
Calendar({ | ||
name: "start", | ||
min: "2023-01-01", | ||
max: "2024-12-31", | ||
required: true, | ||
}) | ||
) | ||
), | ||
footer(ButtonSubmit({ type: "submit" }, "Submit")) | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
bau-ui/examples/bau-storybook/src/pages/switch/switch-controlled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Context } from "@grucloud/bau-ui/context"; | ||
import createSwitch from "@grucloud/bau-ui/switch"; | ||
import button from "@grucloud/bau-ui/button"; | ||
|
||
export default (context: Context) => { | ||
const { bau, css } = context; | ||
const { footer, form, label, article } = bau.tags; | ||
|
||
const Switch = createSwitch(context, { variant: "outline" }); | ||
const Button = button(context, { | ||
variant: "outline", | ||
color: "primary", | ||
}); | ||
|
||
const className = css` | ||
& label { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
} | ||
`; | ||
|
||
return () => { | ||
const switchState = bau.state("on"); | ||
|
||
const onchange = (event: any) => { | ||
switchState.val = event.target.value; | ||
}; | ||
|
||
const onsubmit = (event: any) => { | ||
event.preventDefault(); | ||
const payload = Object.fromEntries(new FormData(event.currentTarget)); | ||
alert(JSON.stringify(payload)); | ||
}; | ||
|
||
return form( | ||
{ onsubmit, class: className }, | ||
article( | ||
label( | ||
"My controlled switch", | ||
Switch({ name: "my-shinny-switch", onchange, checked: switchState }) | ||
) | ||
), | ||
footer(Button({ type: "submit" }, "Submit")) | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
bau-ui/examples/bau-storybook/src/pages/toggleGroup/toggleGroup-example-default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters