@@ -13,6 +13,13 @@ export default {
13
13
argTypes : {
14
14
onSubmit : { action : 'submitted' } ,
15
15
disabled : { control : { type : 'boolean' } } ,
16
+ validationStatus : {
17
+ control : {
18
+ type : 'select' ,
19
+ options : [ undefined , 'success' , 'error' ] ,
20
+ } ,
21
+ defaultValue : undefined ,
22
+ }
16
23
} ,
17
24
parameters : {
18
25
docs : {
@@ -45,14 +52,15 @@ We may find that we want to expose props for custom event handlers or even a ref
45
52
type StorybookArguments = {
46
53
onSubmit : React . FormEventHandler < HTMLFormElement >
47
54
disabled ?: boolean
55
+ validationStatus : 'success' | 'error' | undefined
48
56
}
49
57
50
58
export const completeDatePicker = (
51
59
argTypes : StorybookArguments
52
60
) : React . ReactElement => (
53
61
< Form onSubmit = { argTypes . onSubmit } >
54
- < FormGroup >
55
- < Label id = "appointment-date-label" htmlFor = "appointment-date" >
62
+ < FormGroup error = { argTypes . validationStatus === 'error' } >
63
+ < Label id = "appointment-date-label" htmlFor = "appointment-date" error = { argTypes . validationStatus === 'error' } >
56
64
Appointment date
57
65
</ Label >
58
66
< div className = "usa-hint" id = "appointment-date-hint" >
@@ -64,10 +72,11 @@ export const completeDatePicker = (
64
72
aria-describedby = "appointment-date-hint"
65
73
aria-labelledby = "appointment-date-label"
66
74
disabled = { argTypes . disabled }
75
+ validationStatus = { argTypes . validationStatus }
67
76
/>
68
- < Label htmlFor = "otherInput" > Another unrelated input</ Label >
69
- < TextInput id = "otherInput" name = "otherInput" type = "text" />
70
77
</ FormGroup >
78
+ < Label htmlFor = "otherInput" > Another unrelated input</ Label >
79
+ < TextInput id = "otherInput" name = "otherInput" type = "tel" />
71
80
</ Form >
72
81
)
73
82
0 commit comments