// @flow import * as React from 'react'; import { IntlProvider } from 'react-intl'; import { State, Store } from '@sambego/storybook-state'; import DatePicker from './DatePicker'; import notes from './DatePicker.stories.md'; export const basic = () => { const MIN_TIME = new Date(0); const TODAY = new Date('July 18, 2018'); const yearRange = [MIN_TIME.getFullYear(), TODAY.getFullYear()]; const componentStore = new Store({ date: new Date('July 9, 2018'), fromDate: null, toDate: null, }); return ( {state => ( { componentStore.set({ date }); }} placeholder="Date" value={state.date} yearRange={yearRange} /> )} ); }; export const withDescription = () => ( ); export const manuallyEditable = () => ( ); export const disabledWithErrorMessage = () => ( ); export const customErrorTooltipPosition = () => ( ); export const withRange = () => { const MAX_TIME = new Date('3000-01-01T00:00:00.000Z'); const MIN_TIME = new Date(0); const TODAY = new Date(); const componentStore = new Store({ date: new Date(), fromDate: null, toDate: null, }); return ( {state => (
{ componentStore.set({ fromDate: date }); }} placeholder="Choose a Date" value={state.fromDate} /> { componentStore.set({ toDate: date }); }} placeholder="Choose a Date" value={state.toDate} />
)}
); }; export default { title: 'Components|DatePicker', component: DatePicker, parameters: { notes, }, };