|
8 | 8 | import React from 'react'; |
9 | 9 | import { Story } from '@storybook/react'; |
10 | 10 | import { Col, Grid, Row } from '@zendeskgarden/react-grid'; |
11 | | -import { Field, Input, Label } from '@zendeskgarden/react-forms'; |
| 11 | +import { Field, Input, Label, Message } from '@zendeskgarden/react-forms'; |
12 | 12 | import { Datepicker, IDatepickerProps } from '@zendeskgarden/react-datepickers'; |
13 | 13 | import { DATE_STYLE } from './types'; |
14 | 14 |
|
15 | 15 | interface IArgs extends IDatepickerProps { |
16 | 16 | dateStyle: DATE_STYLE; |
| 17 | + hasMessage?: boolean; |
| 18 | + message?: string; |
| 19 | + validation?: 'success' | 'warning' | 'error'; |
| 20 | + validationLabel?: string; |
17 | 21 | } |
18 | 22 |
|
19 | | -export const DatepickerStory: Story<IArgs> = ({ dateStyle, isCompact, ...args }) => { |
| 23 | +export const DatepickerStory: Story<IArgs> = ({ |
| 24 | + dateStyle, |
| 25 | + isCompact, |
| 26 | + hasMessage, |
| 27 | + message, |
| 28 | + validation, |
| 29 | + validationLabel, |
| 30 | + ...args |
| 31 | +}) => { |
20 | 32 | const formatDate = (date: Date) => |
21 | 33 | new Intl.DateTimeFormat(args.locale, { dateStyle }).format(date); |
22 | 34 |
|
23 | 35 | return ( |
24 | 36 | <Grid> |
25 | | - <Row style={{ height: 'calc(100vh - 80px)' }}> |
26 | | - <Col textAlign="center" alignSelf="center"> |
| 37 | + <Row justifyContent="center" style={{ height: 'calc(100vh - 80px)' }}> |
| 38 | + <Col alignSelf="center"> |
27 | 39 | <Field> |
28 | 40 | <Label hidden>{Datepicker.displayName}</Label> |
29 | 41 | <Datepicker {...args} formatDate={formatDate} isCompact={isCompact}> |
30 | | - <Input isCompact={isCompact} style={{ width: isCompact ? 256 : 320 }} /> |
| 42 | + <Input isCompact={isCompact} validation={validation} /> |
31 | 43 | </Datepicker> |
| 44 | + {hasMessage && ( |
| 45 | + <Message validation={validation} validationLabel={validationLabel}> |
| 46 | + {message} |
| 47 | + </Message> |
| 48 | + )} |
32 | 49 | </Field> |
33 | 50 | </Col> |
34 | 51 | </Row> |
|
0 commit comments