-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Calendar): add documentation for Calendar (#163)
* feat: add date components * fix: remove timeZone from sandbox * fix: landing cases with DateField * feat: add Calendar to landing * feat: update @gravity-ui/date-components to latest
- Loading branch information
Showing
8 changed files
with
112 additions
and
7 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,49 @@ | ||
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: 'Calendar'}; | ||
|
||
export const calendarConfig: Component = { | ||
id: 'calendar', | ||
title: 'Calendar', | ||
isComingSoon: true, | ||
githubUrl: getGithubUrl(getterOptions), | ||
content: { | ||
readmeUrl: getReadmeUrl(getterOptions), | ||
}, | ||
sandbox: { | ||
component: dynamic(() => | ||
import('../examples/components/index').then((mod) => mod.CalendarExample), | ||
), | ||
props: { | ||
size: { | ||
type: 'radioButton', | ||
values: mappingOptions(['m', 'l', 'xl']), | ||
defaultValue: 'm', | ||
}, | ||
mode: { | ||
type: 'select', | ||
values: mappingOptions(['days', 'months', 'quarters', 'years']), | ||
}, | ||
disabled: { | ||
type: 'switch', | ||
defaultValue: false, | ||
}, | ||
readOnly: { | ||
type: 'switch', | ||
defaultValue: false, | ||
}, | ||
minValue: { | ||
type: 'input', | ||
}, | ||
maxValue: { | ||
type: 'input', | ||
}, | ||
focusedValue: { | ||
type: 'input', | ||
}, | ||
}, | ||
}, | ||
}; |
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
35 changes: 35 additions & 0 deletions
35
src/content/components/date-components/examples/components/CalendarExample.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,35 @@ | ||
import {Calendar, CalendarProps} from '@gravity-ui/date-components'; | ||
import {DateTimeInput, dateTimeParse} from '@gravity-ui/date-utils'; | ||
|
||
type CalendarExampleProps = { | ||
defaultValue?: DateTimeInput; | ||
maxValue?: DateTimeInput; | ||
minValue?: DateTimeInput; | ||
defaultFocusedValue?: DateTimeInput; | ||
focusedValue?: DateTimeInput; | ||
} & Omit< | ||
CalendarProps, | ||
'defaultValue' | 'maxValue' | 'minValue' | 'defaultFocusedValue' | 'focusedValue' | ||
>; | ||
|
||
export const CalendarExample = ({ | ||
focusedValue, | ||
defaultFocusedValue, | ||
defaultValue, | ||
maxValue, | ||
minValue, | ||
...otherProps | ||
}: CalendarExampleProps) => { | ||
const modes: CalendarProps['modes'] = {days: true, months: true, quarters: true, years: true}; | ||
return ( | ||
<Calendar | ||
{...otherProps} | ||
defaultFocusedValue={dateTimeParse(defaultFocusedValue)} | ||
defaultValue={dateTimeParse(defaultValue)} | ||
minValue={dateTimeParse(minValue)} | ||
maxValue={dateTimeParse(maxValue)} | ||
focusedValue={dateTimeParse(focusedValue)} | ||
modes={modes} | ||
/> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
src/content/components/date-components/examples/components/DateFieldExample.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,24 @@ | ||
import {DateField, DateFieldProps} from '@gravity-ui/date-components'; | ||
import {DateTimeInput, dateTimeParse} from '@gravity-ui/date-utils'; | ||
|
||
type DateFieldExampleProps = { | ||
defaultValue?: DateTimeInput; | ||
maxValue?: DateTimeInput; | ||
minValue?: DateTimeInput; | ||
} & Omit<DateFieldProps, 'defaultValue' | 'maxValue' | 'minValue'>; | ||
|
||
export const DateFieldExample = ({ | ||
defaultValue, | ||
maxValue, | ||
minValue, | ||
...restProps | ||
}: DateFieldExampleProps) => { | ||
return ( | ||
<DateField | ||
{...restProps} | ||
defaultValue={dateTimeParse(defaultValue)} | ||
maxValue={dateTimeParse(maxValue)} | ||
minValue={dateTimeParse(minValue)} | ||
/> | ||
); | ||
}; |
2 changes: 2 additions & 0 deletions
2
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './CalendarExample'; | ||
export * from './DateFieldExample'; |