Skip to content

Commit 161a931

Browse files
fix: Adds validation styles to datepicker (#2398)
Co-authored-by: Brandon Lenz <[email protected]>
1 parent 8521b2a commit 161a931

File tree

3 files changed

+112
-127
lines changed

3 files changed

+112
-127
lines changed

src/components/forms/DatePicker/DatePicker.stories.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export default {
1313
argTypes: {
1414
onSubmit: { action: 'submitted' },
1515
disabled: { control: { type: 'boolean' } },
16+
validationStatus: {
17+
control: {
18+
type: 'select',
19+
options: [undefined, 'success', 'error'],
20+
},
21+
defaultValue: undefined,
22+
}
1623
},
1724
parameters: {
1825
docs: {
@@ -45,14 +52,15 @@ We may find that we want to expose props for custom event handlers or even a ref
4552
type StorybookArguments = {
4653
onSubmit: React.FormEventHandler<HTMLFormElement>
4754
disabled?: boolean
55+
validationStatus: 'success' | 'error' | undefined
4856
}
4957

5058
export const completeDatePicker = (
5159
argTypes: StorybookArguments
5260
): React.ReactElement => (
5361
<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'}>
5664
Appointment date
5765
</Label>
5866
<div className="usa-hint" id="appointment-date-hint">
@@ -64,10 +72,11 @@ export const completeDatePicker = (
6472
aria-describedby="appointment-date-hint"
6573
aria-labelledby="appointment-date-label"
6674
disabled={argTypes.disabled}
75+
validationStatus={argTypes.validationStatus}
6776
/>
68-
<Label htmlFor="otherInput">Another unrelated input</Label>
69-
<TextInput id="otherInput" name="otherInput" type="text" />
7077
</FormGroup>
78+
<Label htmlFor="otherInput">Another unrelated input</Label>
79+
<TextInput id="otherInput" name="otherInput" type="tel" />
7180
</Form>
7281
)
7382

0 commit comments

Comments
 (0)