feat: storybook 추가

This commit is contained in:
2026-04-14 10:38:36 +09:00
parent 52f8c30b2e
commit 8d6bff88d6
23 changed files with 1687 additions and 10 deletions

View File

@@ -0,0 +1,62 @@
import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'
import { Calendar } from './Calendar'
import { RangeCalendar } from './RangeCalendar'
const meta = {
title: 'Components/Calendar',
component: Calendar,
argTypes: {
isDisabled: {
control: 'boolean',
},
},
} satisfies Meta<typeof Calendar>
export default meta
type Story = StoryObj<typeof meta>
export const Default: Story = {
args: {},
}
export const WithSelectedDate: Story = {
render: function Render() {
const [date, setDate] = useState<Date | null>(new Date())
return <Calendar value={date} onChange={setDate} />
},
}
export const WithMinMaxDate: Story = {
render: function Render() {
const [date, setDate] = useState<Date | null>(new Date())
const minDate = new Date()
minDate.setDate(minDate.getDate() - 7)
const maxDate = new Date()
maxDate.setDate(maxDate.getDate() + 7)
return <Calendar value={date} onChange={setDate} minValue={minDate} maxValue={maxDate} />
},
}
export const Disabled: Story = {
args: {
isDisabled: true,
},
}
export const Range: StoryObj<typeof RangeCalendar> = {
render: function Render() {
const [range, setRange] = useState<{ start: Date; end: Date } | null>(null)
return <RangeCalendar value={range} onChange={setRange} />
},
}
export const RangeWithSelectedDates: StoryObj<typeof RangeCalendar> = {
render: function Render() {
const start = new Date()
const end = new Date()
end.setDate(end.getDate() + 7)
const [range, setRange] = useState<{ start: Date; end: Date } | null>({ start, end })
return <RangeCalendar value={range} onChange={setRange} />
},
}

View File

@@ -12,7 +12,7 @@ import {
import { getLocalTimeZone, today } from '@internationalized/date';
import { tv } from 'tailwind-variants';
import { ChevronLeftIcon, ChevronRightIcon } from '@/components/icons';
import { ChevronLeftIcon, ChevronRightIcon } from '../icons';
import { calendarDateToDate, dateToCalendarDate } from './utils';
@@ -128,8 +128,7 @@ export function Calendar({ value, defaultValue, onChange, maxValue, minValue, is
isToday: !isSelected ? isToday : false,
isHovered: !isSelected ? isHovered : false,
isFocusVisible,
})
}
})}
/>
);
}}