Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DateField): add DateField from date-components #162

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@doc-tools/transform": "^3.11.0",
"@gravity-ui/components": "2.1.0",
"@gravity-ui/date-components": "^1.2.0",
"@gravity-ui/icons": "^2.8.1",
"@gravity-ui/page-constructor": "^4.41.0",
"@gravity-ui/uikit": "5.24.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/get-packages-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {fileURLToPath} from 'node:url';
const packagesMap = {
'@gravity-ui/uikit': 'uikit',
'@gravity-ui/components': 'components',
// '@gravity-ui/date-components': 'date-components',
'@gravity-ui/date-components': 'date-components',
};

const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../package.json');
Expand Down
2 changes: 2 additions & 0 deletions src/components/MDXRenderer/MDXRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Components from '@gravity-ui/components';
import * as DateComponents from '@gravity-ui/date-components';
import {Col, Grid, Row} from '@gravity-ui/page-constructor';
import * as UIKit from '@gravity-ui/uikit';
import {EvaluateOptions, evaluate} from '@mdx-js/mdx';
Expand Down Expand Up @@ -31,6 +32,7 @@ const componentsAvailableInMDX: MDXComponents = {
UIKitExamples,
UIKit: UIKit as unknown as Record<string, MDXComponents>,
Components: Components as unknown as Record<string, MDXComponents>,
DateComponents: DateComponents as unknown as Record<string, MDXComponents>,
};

type Props = {
Expand Down
81 changes: 80 additions & 1 deletion src/content/components/date-components/DateField/index.ts
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: 'DateField'};

export const dateFieldConfig: Component = {
id: 'date-field',
title: 'Date Field',
isComingSoon: true,
githubUrl: getGithubUrl(getterOptions),
content: {
readmeUrl: getReadmeUrl(getterOptions),
},
sandbox: {
component: dynamic(() =>
import('@gravity-ui/date-components').then((mod) => mod.DateField),
),
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',
},
},
},
};
3 changes: 2 additions & 1 deletion src/content/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const TARGET_REPOS_VERSIONS = {
[Repos.Uikit]: process.env.DEV_BRANCH_UIKIT || `v${packagesVersions[Repos.Uikit]}`,
[Repos.Components]:
process.env.DEV_BRANCH_COMPONENTS || `v${packagesVersions[Repos.Components]}`,
// [Repos.DateComponents]: process.env.DEV_BRANCH_DATE_COMPONENTS || `v${packagesVersions['@gravity-ui/date-components']}`,
[Repos.DateComponents]:
process.env.DEV_BRANCH_DATE_COMPONENTS || `v${packagesVersions[Repos.DateComponents]}`,
};

export type GetterProps = {componentName: string; repoName: Repos};
Expand Down
2 changes: 1 addition & 1 deletion src/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum Repos {
Uikit = 'uikit',
Components = 'components',
// DateComponents = 'date-components',
DateComponents = 'date-components',
}
Loading