refactor: refactor datefield, calendar, date picker

This commit is contained in:
jinhojang6 2023-03-17 22:23:39 +09:00 committed by Jon
parent 51d995a264
commit d67057ea98
6 changed files with 98 additions and 3 deletions

View File

@ -25,5 +25,6 @@ export const Root: Story<CalendarProps> = (arg) => {
}
Root.args = {
value: '',
value: undefined,
onChange: undefined,
}

View File

@ -0,0 +1,30 @@
import { Meta, Story } from '@storybook/react'
import { useRef } from 'react'
import { Calendar, CalendarProps } from './Calendar'
export default {
title: 'ControlledCalendar',
component: Calendar,
} as Meta
export const Root: Story<CalendarProps> = (arg) => {
const ref = useRef<HTMLDivElement>(null)
return (
<div ref={ref} style={{ width: '300px' }}>
<Calendar
{...arg}
handleDateFieldChange={(date) => console.log(date?.toDateString())}
open={true}
handleRef={ref}
>
Calendar
</Calendar>
</div>
)
}
Root.args = {
value: '2023-01-01',
onChange: undefined,
}

View File

@ -0,0 +1,31 @@
import { Meta, Story } from '@storybook/react'
import { DateField, DateFieldProps } from './DateField'
export default {
title: 'ControlledDateField',
component: DateField,
argTypes: {
size: {
type: {
name: 'enum',
value: ['medium', 'large'],
},
defaultValue: 'large',
},
},
} as Meta
export const Root: Story<DateFieldProps> = ({ ...args }) => {
return <DateField {...args} />
}
Root.args = {
size: 'large',
supportingText: 'Supporting text',
disabled: false,
value: '2023-01-01',
onChange: undefined,
error: false,
errorIcon: false,
clearButton: true,
}

View File

@ -23,8 +23,9 @@ Root.args = {
size: 'large',
supportingText: 'Supporting text',
disabled: false,
value: undefined,
onChange: undefined,
error: false,
errorIcon: false,
clearButton: true,
onChange: undefined,
}

View File

@ -0,0 +1,32 @@
import { Meta, Story } from '@storybook/react'
import { DatePicker, DatePickerProps } from './DatePicker'
export default {
title: 'ControlledDatePicker',
component: DatePicker,
argTypes: {
size: {
type: {
name: 'enum',
value: ['medium', 'large'],
},
defaultValue: 'large',
},
},
} as Meta
export const Root: Story<DatePickerProps> = ({ ...args }) => {
return <DatePicker {...args}>DatePicker</DatePicker>
}
Root.args = {
size: 'large',
supportingText: 'Supporting text',
disabled: false,
error: false,
value: '2023-01-01',
onChange: undefined,
errorIcon: false,
clearButton: true,
withCalendar: true,
}

View File

@ -24,7 +24,7 @@ Root.args = {
supportingText: 'Supporting text',
disabled: false,
error: false,
value: '',
value: undefined,
onChange: undefined,
errorIcon: false,
clearButton: true,