-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #508 from Groww-OSS/develop
Develop Merge PR | Sep 11
- Loading branch information
Showing
4 changed files
with
167 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
import { StoryFn } from '@storybook/react'; | ||
import { Calendar } from '../src/components/molecules'; | ||
import { Props as CalendarProps, CALENDAR_TYPE } from '../src/components/molecules/Calendar/Calendar'; | ||
|
||
export default { | ||
title: 'Calendar', | ||
component: Calendar, | ||
tags: [ 'autodocs' ] | ||
}; | ||
|
||
|
||
const Template: StoryFn<CalendarProps> = (args) => <Calendar {...args} />; | ||
|
||
export const CalendarStory = { | ||
render: (args) => { | ||
const updatedArgs = { ...args }; | ||
|
||
// Adjust props based on the selected type (MONTH or DATE) | ||
if (args.type === CALENDAR_TYPE.MONTH) { | ||
updatedArgs.minMonth = new Date(args.minMonth ?? new Date()); | ||
updatedArgs.maxMonth = new Date(args.maxMonth ?? new Date()); | ||
|
||
} else if (args.type === CALENDAR_TYPE.DATE) { | ||
updatedArgs.minDate = new Date(args.minDate ?? new Date()); | ||
updatedArgs.maxDate = new Date(args.maxDate ?? new Date()); | ||
} | ||
|
||
return <Template {...updatedArgs} />; | ||
}, | ||
args: { | ||
type: CALENDAR_TYPE.MONTH, | ||
minMonth: new Date(2021, 6, 6), | ||
maxMonth: new Date(2031, 9, 6), | ||
minDate: new Date(2021, 6, 6), | ||
maxDate: new Date(2031, 6, 20) | ||
}, | ||
argTypes: { | ||
type: { | ||
control: 'select', | ||
options: Object.values(CALENDAR_TYPE) | ||
}, | ||
minMonth: { | ||
control: 'date', | ||
if: { arg: 'type', eq: CALENDAR_TYPE.MONTH } // Only show when MONTH type is selected | ||
}, | ||
maxMonth: { | ||
control: 'date', | ||
if: { arg: 'type', eq: CALENDAR_TYPE.MONTH } // Only show when MONTH type is selected | ||
}, | ||
minDate: { | ||
control: 'date', | ||
if: { arg: 'type', eq: CALENDAR_TYPE.DATE } // Only show when DATE type is selected | ||
}, | ||
maxDate: { | ||
control: 'date', | ||
if: { arg: 'type', eq: CALENDAR_TYPE.DATE } // Only show when DATE type is selected | ||
} | ||
} | ||
}; |