-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(storybook): update all styling stories
- Loading branch information
Showing
5 changed files
with
405 additions
and
303 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React from 'react'; | ||
import { createBaseStory, BaseTemplate, baseArgs } from '../base'; | ||
import { newDate, format, Picker, WheelPickerSelectEvent } from '../../index'; // in your code: @persian-tools/persian-mobile-datepicker | ||
import { storiesOf } from '@storybook/react'; | ||
import { digitsEnToFa } from '@persian-tools/persian-tools'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { BADGE } from '@geometricpanda/storybook-addon-badges'; | ||
// Types | ||
import type { ComponentStory } from '@storybook/react'; | ||
import type { Event } from '../../components/WheelPicker/index.types'; | ||
|
||
const title = 'Styling/Active Item Style'; | ||
export default createBaseStory(title); | ||
|
||
const BasePickerTemplate: ComponentStory<typeof Picker> = (args) => { | ||
const [selectedDateValue, setSelectedDateValue] = React.useState<string>(); | ||
const [selectedDateEvents, setSelectedDateEvents] = React.useState< | ||
Array<Event> | ||
>([]); | ||
|
||
function handleOnChange(data: WheelPickerSelectEvent) { | ||
setSelectedDateValue(format(data.date!, 'd MMMM yyyy')); | ||
setSelectedDateEvents(data.events); | ||
action('onClick')(data); | ||
} | ||
|
||
return ( | ||
<BaseTemplate value={selectedDateValue!} events={selectedDateEvents!}> | ||
<Picker {...args} onChange={handleOnChange} onSubmit={handleOnChange} /> | ||
</BaseTemplate> | ||
); | ||
}; | ||
|
||
storiesOf(title, module).add( | ||
'Active Item Style', | ||
(args: any) => <BasePickerTemplate {...args} />, | ||
{ | ||
component: Picker, | ||
args: { | ||
isOpen: true, | ||
theme: 'auto', | ||
highlightHolidays: true, | ||
highlightWeekends: true, | ||
config: { | ||
year: { | ||
caption: { | ||
text: 'سال', | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.year); | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#bae6c1', | ||
}, | ||
itemStyle: { | ||
color: '#6ea674', | ||
background: '#def6e2', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
month: { | ||
caption: { | ||
text: 'ماه', | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#a5c7ef', | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
day: { | ||
caption: { | ||
text: 'روز', | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.day); | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#a5c7ef', | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
}, | ||
initialValue: newDate({ year: 1400, month: 1, day: 1 }), | ||
}, | ||
argTypes: baseArgs, | ||
badges: [BADGE.STABLE], | ||
}, | ||
); |
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,96 @@ | ||
import React from 'react'; | ||
import { createBaseStory, BaseTemplate, baseArgs } from '../base'; | ||
import { newDate, format, Picker, WheelPickerSelectEvent } from '../../index'; // in your code: @persian-tools/persian-mobile-datepicker | ||
import { storiesOf } from '@storybook/react'; | ||
import { digitsEnToFa } from '@persian-tools/persian-tools'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { BADGE } from '@geometricpanda/storybook-addon-badges'; | ||
// Types | ||
import type { ComponentStory } from '@storybook/react'; | ||
import type { Event } from '../../components/WheelPicker/index.types'; | ||
|
||
const title = 'Styling/Column Items Style'; | ||
export default createBaseStory(title); | ||
|
||
const BasePickerTemplate: ComponentStory<typeof Picker> = (args) => { | ||
const [selectedDateValue, setSelectedDateValue] = React.useState<string>(); | ||
const [selectedDateEvents, setSelectedDateEvents] = React.useState< | ||
Array<Event> | ||
>([]); | ||
|
||
function handleOnChange(data: WheelPickerSelectEvent) { | ||
setSelectedDateValue(format(data.date!, 'd MMMM yyyy')); | ||
setSelectedDateEvents(data.events); | ||
action('onClick')(data); | ||
} | ||
|
||
return ( | ||
<BaseTemplate value={selectedDateValue!} events={selectedDateEvents!}> | ||
<Picker {...args} onChange={handleOnChange} onSubmit={handleOnChange} /> | ||
</BaseTemplate> | ||
); | ||
}; | ||
|
||
storiesOf(title, module).add( | ||
'Column Items Style', | ||
(args: any) => <BasePickerTemplate {...args} />, | ||
{ | ||
component: Picker, | ||
args: { | ||
isOpen: true, | ||
theme: 'auto', | ||
highlightHolidays: true, | ||
highlightWeekends: true, | ||
config: { | ||
year: { | ||
caption: { | ||
text: 'سال', | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.year); | ||
}, | ||
itemStyle: { | ||
color: '#6ea674', | ||
background: '#def6e2', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
month: { | ||
caption: { | ||
text: 'ماه', | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
day: { | ||
caption: { | ||
text: 'روز', | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.day); | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
}, | ||
initialValue: newDate({ year: 1400, month: 1, day: 1 }), | ||
}, | ||
argTypes: baseArgs, | ||
badges: [BADGE.STABLE], | ||
}, | ||
); |
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,120 @@ | ||
import React from 'react'; | ||
import { createBaseStory, BaseTemplate, baseArgs } from '../base'; | ||
import { newDate, format, Picker, WheelPickerSelectEvent } from '../../index'; // in your code: @persian-tools/persian-mobile-datepicker | ||
import { storiesOf } from '@storybook/react'; | ||
import { digitsEnToFa } from '@persian-tools/persian-tools'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { BADGE } from '@geometricpanda/storybook-addon-badges'; | ||
// Types | ||
import type { ComponentStory } from '@storybook/react'; | ||
import type { Event } from '../../components/WheelPicker/index.types'; | ||
|
||
const title = 'Styling/Columns Caption Style'; | ||
export default createBaseStory(title); | ||
|
||
const BasePickerTemplate: ComponentStory<typeof Picker> = (args) => { | ||
const [selectedDateValue, setSelectedDateValue] = React.useState<string>(); | ||
const [selectedDateEvents, setSelectedDateEvents] = React.useState< | ||
Array<Event> | ||
>([]); | ||
|
||
function handleOnChange(data: WheelPickerSelectEvent) { | ||
setSelectedDateValue(format(data.date!, 'd MMMM yyyy')); | ||
setSelectedDateEvents(data.events); | ||
action('onClick')(data); | ||
} | ||
|
||
return ( | ||
<BaseTemplate value={selectedDateValue!} events={selectedDateEvents!}> | ||
<Picker {...args} onChange={handleOnChange} onSubmit={handleOnChange} /> | ||
</BaseTemplate> | ||
); | ||
}; | ||
|
||
storiesOf(title, module).add( | ||
'Columns Caption Style', | ||
(args: any) => <BasePickerTemplate {...args} />, | ||
{ | ||
component: Picker, | ||
args: { | ||
isOpen: true, | ||
theme: 'auto', | ||
highlightHolidays: true, | ||
highlightWeekends: true, | ||
config: { | ||
year: { | ||
caption: { | ||
text: 'سال', | ||
style: { | ||
fontSize: '1.2em', | ||
color: '#ade8b7', | ||
}, | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.year); | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#bae6c1', | ||
}, | ||
itemStyle: { | ||
color: '#6ea674', | ||
background: '#def6e2', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
month: { | ||
caption: { | ||
text: 'ماه', | ||
style: { | ||
fontSize: '1.2em', | ||
color: '#84b4ec', | ||
}, | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#a5c7ef', | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
day: { | ||
caption: { | ||
text: 'روز', | ||
style: { | ||
fontSize: '1.2em', | ||
color: '#84b4ec', | ||
}, | ||
}, | ||
formatter(value: Record<string, any>) { | ||
return digitsEnToFa(value.day); | ||
}, | ||
selectedItemStyle: { | ||
color: '#215e25', | ||
backgroundColor: '#a5c7ef', | ||
}, | ||
itemStyle: { | ||
color: '#404345', | ||
background: '#ddeafa', | ||
height: 30, | ||
fontSize: '15px', | ||
lineHeight: '30px', | ||
borderRadius: 5, | ||
}, | ||
}, | ||
}, | ||
initialValue: newDate({ year: 1400, month: 1, day: 1 }), | ||
}, | ||
argTypes: baseArgs, | ||
badges: [BADGE.STABLE], | ||
}, | ||
); |
Oops, something went wrong.