-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DatePicker): add description and sandbox for DatePicker (#170)
- Loading branch information
Showing
6 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,86 @@ | ||
import dynamic from 'next/dynamic'; | ||
import {Repos} from 'src/types/common'; | ||
|
||
import {Component} from '../../types'; | ||
import {getGithubUrl, getReadmeUrl, mappingOptions} from '../../utils'; | ||
|
||
const getterOptions = {repoName: Repos.DateComponents, componentName: 'DatePicker'}; | ||
|
||
export const datePickerConfig: Component = { | ||
id: 'date-picker', | ||
title: 'Date Picker', | ||
isComingSoon: true, | ||
githubUrl: getGithubUrl(getterOptions), | ||
content: { | ||
readmeUrl: getReadmeUrl(getterOptions), | ||
}, | ||
sandbox: { | ||
component: dynamic(() => | ||
import('../examples/components/index').then((mod) => mod.DatePickerSandboxExample), | ||
), | ||
props: { | ||
view: { | ||
type: 'radioButton', | ||
values: mappingOptions(['normal', 'clear']), | ||
defaultValue: 'normal', | ||
}, | ||
size: { | ||
type: 'radioButton', | ||
values: mappingOptions(['s', 'm', 'l', 'xl']), | ||
defaultValue: 'm', | ||
}, | ||
placeholder: { | ||
type: 'input', | ||
defaultValue: 'Type here...', | ||
}, | ||
label: { | ||
type: 'input', | ||
}, | ||
validationState: { | ||
type: 'radioButton', | ||
values: mappingOptions(['normal', 'invalid']), | ||
defaultValue: 'normal', | ||
}, | ||
errorMessage: { | ||
type: 'input', | ||
defaultValue: 'Input is invalid', | ||
}, | ||
disabled: { | ||
type: 'switch', | ||
defaultValue: false, | ||
}, | ||
hasClear: { | ||
type: 'switch', | ||
defaultValue: false, | ||
}, | ||
readOnly: { | ||
type: 'switch', | ||
defaultValue: false, | ||
}, | ||
format: { | ||
type: 'input', | ||
defaultValue: 'MM/DD/YYYY', | ||
}, | ||
pin: { | ||
type: 'select', | ||
values: mappingOptions([ | ||
'round-round', | ||
'brick-brick', | ||
'clear-clear', | ||
'round-brick', | ||
'brick-round', | ||
'round-clear', | ||
'clear-round', | ||
'brick-clear', | ||
'clear-brick', | ||
]), | ||
defaultValue: 'round-round', | ||
}, | ||
minValue: { | ||
type: 'input', | ||
}, | ||
maxValue: { | ||
type: 'input', | ||
}, | ||
}, | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
src/content/components/date-components/examples/components/DatePickerExample.tsx
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,28 @@ | ||
import {DatePicker, DatePickerProps} from '@gravity-ui/date-components'; | ||
import {DateTimeInput, dateTimeParse} from '@gravity-ui/date-utils'; | ||
|
||
type DatePickerExampleProps = { | ||
defaultValue?: DateTimeInput; | ||
maxValue?: DateTimeInput; | ||
minValue?: DateTimeInput; | ||
} & Omit<DatePickerProps, 'defaultValue' | 'maxValue' | 'minValue'>; | ||
|
||
export const DatePickerExample = ({ | ||
defaultValue, | ||
maxValue, | ||
minValue, | ||
...restProps | ||
}: DatePickerExampleProps) => { | ||
return ( | ||
<DatePicker | ||
{...restProps} | ||
defaultValue={dateTimeParse(defaultValue)} | ||
maxValue={dateTimeParse(maxValue)} | ||
minValue={dateTimeParse(minValue)} | ||
/> | ||
); | ||
}; | ||
|
||
export const DatePickerSandboxExample = (props: DatePickerExampleProps) => ( | ||
<DatePickerExample {...props} style={{alignSelf: 'flex-start'}} /> | ||
); |
1 change: 1 addition & 0 deletions
1
src/content/components/date-components/examples/components/index.tsx
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './CalendarExample'; | ||
export * from './RangeCalendarExample'; | ||
export * from './DateFieldExample'; | ||
export * from './DatePickerExample'; |