Browse Source

📚 docs: add token meta info to token system model (#39101)

* ♻️ refactor token system interface

* 📝 docs: add more token meta info to seeds and map token

* 🔨 chore: update token meta generator scripts

* 🚨 chore: fix lint

* 📝 docs: 补充 token 的 meta 信息

* chore: add json in pkg

* chore: update script

* chore: update flag

Co-authored-by: MadCcc <1075746765@qq.com>
pull/39114/head
Arvin Xu 2 years ago
committed by GitHub
parent
commit
479e4e8884
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .antd-tools.config.js
  2. 5
      .dumi/theme/builtins/TokenTable/index.tsx
  3. 875
      components/theme/interface.ts
  4. 195
      components/theme/interface/alias.ts
  5. 111
      components/theme/interface/components.ts
  6. 25
      components/theme/interface/index.ts
  7. 437
      components/theme/interface/maps/colors.ts
  8. 30
      components/theme/interface/maps/index.ts
  9. 67
      components/theme/interface/maps/size.ts
  10. 39
      components/theme/interface/maps/style.ts
  11. 25
      components/theme/interface/presetColors.ts
  12. 240
      components/theme/interface/seeds.ts
  13. 4
      components/theme/themes/ColorMap.ts
  14. 19
      scripts/generate-token-meta.js

6
.antd-tools.config.js

@ -2,14 +2,20 @@ const fs = require('fs');
const path = require('path');
const restCssPath = path.join(process.cwd(), 'components', 'style', 'reset.css');
const tokenStatisticPath = path.join(process.cwd(), 'components', 'version', 'token.json');
const tokenMetaPath = path.join(process.cwd(), 'components', 'version', 'token-meta.json');
function finalizeCompile() {
if (fs.existsSync(path.join(__dirname, './es'))) {
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'es', 'style', 'reset.css'));
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'es', 'version', 'token.json'));
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'es', 'version', 'token-meta.json'));
}
if (fs.existsSync(path.join(__dirname, './lib'))) {
fs.copyFileSync(restCssPath, path.join(process.cwd(), 'lib', 'style', 'reset.css'));
fs.copyFileSync(tokenStatisticPath, path.join(process.cwd(), 'lib', 'version', 'token.json'));
fs.copyFileSync(tokenMetaPath, path.join(process.cwd(), 'lib', 'version', 'token-meta.json'));
}
}

5
.dumi/theme/builtins/TokenTable/index.tsx

@ -4,8 +4,8 @@ import React, { useMemo } from 'react';
// @ts-ignore
import tokenMeta from 'antd/es/version/token-meta.json';
import { getDesignToken } from 'antd-token-previewer';
import type { TableProps } from 'antd';
import { Table } from 'antd';
import type { TableProps } from 'antd';
import { css } from '@emotion/react';
import useLocale from '../../../hooks/useLocale';
import useSiteToken from '../../../hooks/useSiteToken';
@ -68,7 +68,6 @@ const TokenTable: FC<TokenTableProps> = ({ type }) => {
title: locale.description,
key: 'desc',
dataIndex: 'desc',
width: 300,
},
{
title: locale.type,
@ -104,7 +103,7 @@ const TokenTable: FC<TokenTableProps> = ({ type }) => {
const data = useMemo<TokenData[]>(
() =>
tokenMeta[type].map((token) => ({
name: token.name,
name: token.token,
desc: lang === 'cn' ? token.desc : token.descEn,
type: token.type,
value: (defaultToken as any)[token.name],

875
components/theme/interface.ts

@ -1,875 +0,0 @@
import type * as React from 'react';
import type { ComponentToken as AlertComponentToken } from '../alert/style';
import type { ComponentToken as AnchorComponentToken } from '../anchor/style';
import type { ComponentToken as AvatarComponentToken } from '../avatar/style';
import type { ComponentToken as BackTopComponentToken } from '../back-top/style';
import type { ComponentToken as ButtonComponentToken } from '../button/style';
import type { ComponentToken as FloatButtonComponentToken } from '../float-button/style';
import type { ComponentToken as CalendarComponentToken } from '../calendar/style';
import type { ComponentToken as CardComponentToken } from '../card/style';
import type { ComponentToken as CarouselComponentToken } from '../carousel/style';
import type { ComponentToken as CascaderComponentToken } from '../cascader/style';
import type { ComponentToken as CheckboxComponentToken } from '../checkbox/style';
import type { ComponentToken as CollapseComponentToken } from '../collapse/style';
import type { ComponentToken as DatePickerComponentToken } from '../date-picker/style';
import type { ComponentToken as DividerComponentToken } from '../divider/style';
import type { ComponentToken as DropdownComponentToken } from '../dropdown/style';
import type { ComponentToken as DrawerComponentToken } from '../drawer/style';
import type { ComponentToken as EmptyComponentToken } from '../empty/style';
import type { ComponentToken as ImageComponentToken } from '../image/style';
import type { ComponentToken as InputNumberComponentToken } from '../input-number/style';
import type { ComponentToken as LayoutComponentToken } from '../layout/style';
import type { ComponentToken as ListComponentToken } from '../list/style';
import type { ComponentToken as MentionsComponentToken } from '../mentions/style';
import type { ComponentToken as MenuComponentToken } from '../menu/style';
import type { ComponentToken as MessageComponentToken } from '../message/style';
import type { ComponentToken as ModalComponentToken } from '../modal/style';
import type { ComponentToken as NotificationComponentToken } from '../notification/style';
import type { ComponentToken as PopconfirmComponentToken } from '../popconfirm/style';
import type { ComponentToken as PopoverComponentToken } from '../popover/style';
import type { ComponentToken as ProgressComponentToken } from '../progress/style';
import type { ComponentToken as RadioComponentToken } from '../radio/style';
import type { ComponentToken as RateComponentToken } from '../rate/style';
import type { ComponentToken as ResultComponentToken } from '../result/style';
import type { ComponentToken as SegmentedComponentToken } from '../segmented/style';
import type { ComponentToken as SelectComponentToken } from '../select/style';
import type { ComponentToken as SkeletonComponentToken } from '../skeleton/style';
import type { ComponentToken as SliderComponentToken } from '../slider/style';
import type { ComponentToken as SpaceComponentToken } from '../space/style';
import type { ComponentToken as SpinComponentToken } from '../spin/style';
import type { ComponentToken as StepsComponentToken } from '../steps/style';
import type { ComponentToken as TableComponentToken } from '../table/style';
import type { ComponentToken as TabsComponentToken } from '../tabs/style';
import type { ComponentToken as TagComponentToken } from '../tag/style';
import type { ComponentToken as TimelineComponentToken } from '../timeline/style';
import type { ComponentToken as TooltipComponentToken } from '../tooltip/style';
import type { ComponentToken as TransferComponentToken } from '../transfer/style';
import type { ComponentToken as TypographyComponentToken } from '../typography/style';
import type { ComponentToken as UploadComponentToken } from '../upload/style';
import type { ComponentToken as TourComponentToken } from '../tour/style';
export const PresetColors = [
'blue',
'purple',
'cyan',
'green',
'magenta',
'pink',
'red',
'orange',
'yellow',
'volcano',
'geekblue',
'lime',
'gold',
] as const;
type PresetColorKey = typeof PresetColors[number];
export type PresetColorType = Record<PresetColorKey, string>;
type ColorPaletteKeyIndex = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
export type ColorPalettes = {
[key in `${keyof PresetColorType}-${ColorPaletteKeyIndex}`]: string;
};
export interface ComponentTokenMap {
Affix?: {};
Alert?: AlertComponentToken;
Anchor?: AnchorComponentToken;
Avatar?: AvatarComponentToken;
BackTop?: BackTopComponentToken;
Badge?: {};
Button?: ButtonComponentToken;
Breadcrumb?: {};
Card?: CardComponentToken;
Carousel?: CarouselComponentToken;
Cascader?: CascaderComponentToken;
Checkbox?: CheckboxComponentToken;
Collapse?: CollapseComponentToken;
DatePicker?: DatePickerComponentToken;
Descriptions?: {};
Divider?: DividerComponentToken;
Drawer?: DrawerComponentToken;
Dropdown?: DropdownComponentToken;
Empty?: EmptyComponentToken;
FloatButton?: FloatButtonComponentToken;
Form?: {};
Grid?: {};
Image?: ImageComponentToken;
Input?: {};
InputNumber?: InputNumberComponentToken;
Layout?: LayoutComponentToken;
List?: ListComponentToken;
Mentions?: MentionsComponentToken;
Notification?: NotificationComponentToken;
Pagination?: {};
Popover?: PopoverComponentToken;
Popconfirm?: PopconfirmComponentToken;
Rate?: RateComponentToken;
Radio?: RadioComponentToken;
Result?: ResultComponentToken;
Segmented?: SegmentedComponentToken;
Select?: SelectComponentToken;
Skeleton?: SkeletonComponentToken;
Slider?: SliderComponentToken;
Spin?: SpinComponentToken;
Statistic?: {};
Switch?: {};
Tag?: TagComponentToken;
Tree?: {};
TreeSelect?: {};
Typography?: TypographyComponentToken;
Timeline?: TimelineComponentToken;
Transfer?: TransferComponentToken;
Tabs?: TabsComponentToken;
Calendar?: CalendarComponentToken;
Steps?: StepsComponentToken;
Menu?: MenuComponentToken;
Modal?: ModalComponentToken;
Message?: MessageComponentToken;
Upload?: UploadComponentToken;
Tooltip?: TooltipComponentToken;
Table?: TableComponentToken;
Space?: SpaceComponentToken;
Progress?: ProgressComponentToken;
Tour?: TourComponentToken;
}
export type OverrideToken = {
[key in keyof ComponentTokenMap]: Partial<ComponentTokenMap[key]> & Partial<AliasToken>;
};
/** Final token which contains the components level override */
export type GlobalToken = AliasToken & ComponentTokenMap;
// ======================================================================
// == Seed Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface SeedToken extends PresetColorType {
/**
* @desc
*/
colorPrimary: string;
/**
* @desc
*/
colorSuccess: string;
/**
* @desc
*/
colorWarning: string;
/**
* @desc
*/
colorError: string;
/**
* @desc
*/
colorInfo: string;
/**
* @desc
*/
colorTextBase: string;
/**
* Base component background color. Will derivative container background color with this
* @desc
*/
colorBgBase: string;
// Font
/**
* @desc
*/
fontFamily: string;
/**
* @desc
*/
fontSize: number;
/**
* Border width of base components
* @desc 线
*/
lineWidth: number;
/**
* @desc 线
*/
lineType: string;
/**
* @desc
*/
motionUnit: number;
/**
* @desc
*/
motionBase: number;
/**
* @desc
*/
motionEaseOutCirc: string;
/**
* @desc
*/
motionEaseInOutCirc: string;
/**
* @desc
*/
motionEaseInOut: string;
/**
* @desc
*/
motionEaseOutBack: string;
/**
* @desc
*/
motionEaseInBack: string;
/**
* @desc
*/
motionEaseInQuint: string;
/**
* @desc
*/
motionEaseOutQuint: string;
/**
* @desc
*/
motionEaseOut: string;
// Radius
/**
* @desc
* @descEn Base border radius
*/
borderRadius: number;
/**
* @desc
*/
sizeUnit: number;
/**
* @desc
*/
sizeStep: number;
/**
* @desc
*/
sizePopupArrow: number;
// Control Base
/**
* @desc
*/
controlHeight: number;
/**
* @desc zIndex
* @descEn Base popup component zIndex
*/
zIndexBase: number;
/** */
/**
* @desc zIndex
* @descEn Base zIndex of component like FloatButton, Affix which can be cover by large popup
*/
zIndexPopupBase: number;
/**
* @desc
* @descEn Define default Image opacity. Useful when in dark-like theme
*/
opacityImage: number;
/**
* @desc 线
*/
wireframe: boolean;
}
export interface NeutralColorMapToken {
/**
* @internal
*/
colorTextBase: string;
/**
* @internal
*/
colorBgBase: string;
/**
* @desc
*/
colorText: string;
/**
* @desc
*/
colorTextSecondary: string;
/**
* @desc
*/
colorTextTertiary: string;
/**
* @desc
*/
colorTextQuaternary: string;
/**
* @desc
*/
colorFill: string;
/**
* @desc
*/
colorFillSecondary: string;
/**
* @desc
*/
colorFillTertiary: string;
/**
* @desc
*/
colorFillQuaternary: string;
/**
* @desc
*/
colorBgContainer: string;
/**
* @desc
*/
colorBgElevated: string;
/**
* @desc
*/
colorBgLayout: string;
/**
* @desc
*/
colorBgSpotlight: string;
/**
* @desc
*/
colorBorder: string;
/**
* @desc
*/
colorBorderSecondary: string;
}
export interface ColorMapToken extends NeutralColorMapToken {
// Primary
/**
* @desc
*/
colorPrimaryBg: string; // 1
/**
* @desc
*/
colorPrimaryBgHover: string; // 2
/**
* @desc
*/
colorPrimaryBorder: string; // 3
/**
* @desc
*/
colorPrimaryBorderHover: string; // 4
/**
* @desc
*/
colorPrimaryHover: string; // 5
/**
* @desc
*/
colorPrimary: string; // 6
/**
* @desc
*/
colorPrimaryActive: string; // 7
/**
* @desc
*/
colorPrimaryTextHover: string; // 8
/**
* @desc
*/
colorPrimaryText: string; // 9
/**
* @desc
*/
colorPrimaryTextActive: string; // 10
/**
* @desc
*/
colorSuccessBg: string; // 1
/**
* @desc
*/
colorSuccessBgHover: string; // 2
/**
* @desc
*/
colorSuccessBorder: string; // 3
/**
* @desc
*/
colorSuccessBorderHover: string; // 4
/**
* @desc
*/
colorSuccessHover: string; // 5
/**
* @desc
*/
colorSuccess: string; // 6
/**
* @desc
*/
colorSuccessActive: string; // 7
/**
* @desc
*/
colorSuccessTextHover: string; // 8
/**
* @desc
*/
colorSuccessText: string; // 9
/**
* @desc
*/
colorSuccessTextActive: string; // 10
/**
* @desc
*/
colorWarningBg: string; // 1
/**
* @desc
*/
colorWarningBgHover: string; // 2
/**
* @desc
*/
colorWarningBorder: string; // 3
/**
* @desc
*/
colorWarningBorderHover: string; // 4
/**
* @desc
*/
colorWarningHover: string; // 5
/**
* @desc
*/
colorWarning: string; // 6
/**
* @desc
*/
colorWarningActive: string; // 7
/**
* @desc
*/
colorWarningTextHover: string; // 8
/**
* @desc
*/
colorWarningText: string; // 9
/**
* @desc
*/
colorWarningTextActive: string; // 10
/**
* @desc
*/
colorErrorBg: string; // 1
/**
* @desc
*/
colorErrorBgHover: string; // 2
/**
* @desc
*/
colorErrorBorder: string; // 3
/**
* @desc
*/
colorErrorBorderHover: string; // 4
/**
* @desc
*/
colorErrorHover: string; // 5
/**
* @desc
*/
colorError: string; // 6
/**
* @desc
*/
colorErrorActive: string; // 7
/**
* @desc
*/
colorErrorTextHover: string; // 8
/**
* @desc
*/
colorErrorText: string; // 9
/**
* @desc
*/
colorErrorTextActive: string; // 10
/**
* @desc
*/
colorInfoBg: string; // 1
/**
* @desc
*/
colorInfoBgHover: string; // 2
/**
* @desc
*/
colorInfoBorder: string; // 3
/**
* @desc
*/
colorInfoBorderHover: string; // 4
/**
* @desc
*/
colorInfoHover: string; // 5
/**
* @desc
*/
colorInfo: string; // 6
/**
* @desc
*/
colorInfoActive: string; // 7
/**
* @desc
*/
colorInfoTextHover: string; // 8
/**
* @desc
*/
colorInfoText: string; // 9
/**
* @desc
*/
colorInfoTextActive: string; // 10
/**
* @desc
*/
colorBgMask: string;
colorWhite: string;
}
export interface SizeMapToken {
// Size
sizeXXL: number;
sizeXL: number;
sizeLG: number;
sizeMD: number;
/** Same as size by default, but could be larger in compact mode */
sizeMS: number;
size: number;
sizeSM: number;
sizeXS: number;
sizeXXS: number;
}
export interface HeightMapToken {
// Control
/** @private Only Used for control inside component like Multiple Select inner selection item */
controlHeightXS: number;
controlHeightSM: number;
controlHeightLG: number;
}
export interface CommonMapToken {
// Font
/**
* @internal
*/
fontSizes: number[];
/**
* @internal
*/
lineHeights: number[];
// Line
lineWidthBold: number;
// Motion
motionDurationFast: string;
motionDurationMid: string;
motionDurationSlow: string;
// Radius
borderRadiusXS: number;
borderRadiusSM: number;
borderRadiusLG: number;
borderRadiusOuter: number;
}
// ======================================================================
// == Map Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface MapToken
extends SeedToken,
ColorPalettes,
ColorMapToken,
SizeMapToken,
HeightMapToken,
CommonMapToken {}
// ======================================================================
// == Alias Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface AliasToken extends MapToken {
// Background
colorFillContentHover: string;
colorFillAlter: string;
colorBgContainerDisabled: string;
colorFillContent: string;
// Border
colorBorderBg: string;
colorSplit: string;
// Text
colorTextPlaceholder: string;
colorTextDisabled: string;
colorTextHeading: string;
colorTextLabel: string;
colorTextDescription: string;
colorTextLightSolid: string;
colorBgTextHover: string;
colorBgTextActive: string;
/** Weak action. Such as `allowClear` or Alert close button */
colorIcon: string;
/** Weak action hover color. Such as `allowClear` or Alert close button */
colorIconHover: string;
colorLink: string;
colorLinkHover: string;
colorLinkActive: string;
colorHighlight: string;
controlOutline: string;
colorWarningOutline: string;
colorErrorOutline: string;
// Font
fontSizeSM: number;
fontSize: number;
fontSizeLG: number;
fontSizeXL: number;
/** Operation icon in Select, Cascader, etc. icon fontSize. Normal is same as fontSizeSM */
fontSizeIcon: number;
fontSizeHeading1: number;
fontSizeHeading2: number;
fontSizeHeading3: number;
fontSizeHeading4: number;
fontSizeHeading5: number;
/** For heading like h1, h2, h3 or option selected item */
fontWeightStrong: number;
// LineHeight
lineHeight: number;
lineHeightLG: number;
lineHeightSM: number;
lineHeightHeading1: number;
lineHeightHeading2: number;
lineHeightHeading3: number;
lineHeightHeading4: number;
lineHeightHeading5: number;
// Control
controlOutlineWidth: number;
controlItemBgHover: string; // Note. It also is a color
controlItemBgActive: string; // Note. It also is a color
controlItemBgActiveHover: string; // Note. It also is a color
controlInteractiveSize: number;
controlItemBgActiveDisabled: string; // Note. It also is a color
// Padding
paddingXXS: number;
paddingXS: number;
paddingSM: number;
padding: number;
paddingMD: number;
paddingLG: number;
paddingXL: number;
// Padding Content
paddingContentHorizontalLG: number;
paddingContentHorizontal: number;
paddingContentHorizontalSM: number;
paddingContentVerticalLG: number;
paddingContentVertical: number;
paddingContentVerticalSM: number;
// Margin
marginXXS: number;
marginXS: number;
marginSM: number;
margin: number;
marginMD: number;
marginLG: number;
marginXL: number;
marginXXL: number;
// =============== Legacy: should be remove ===============
opacityLoading: number;
boxShadow: string;
boxShadowSecondary: string;
linkDecoration: React.CSSProperties['textDecoration'];
linkHoverDecoration: React.CSSProperties['textDecoration'];
linkFocusDecoration: React.CSSProperties['textDecoration'];
controlPaddingHorizontal: number;
controlPaddingHorizontalSM: number;
// Media queries breakpoints
screenXS: number;
screenXSMin: number;
screenXSMax: number;
screenSM: number;
screenSMMin: number;
screenSMMax: number;
screenMD: number;
screenMDMin: number;
screenMDMax: number;
screenLG: number;
screenLGMin: number;
screenLGMax: number;
screenXL: number;
screenXLMin: number;
screenXLMax: number;
screenXXL: number;
screenXXLMin: number;
screenXXLMax: number;
/** Used for DefaultButton, Switch which has default outline */
controlTmpOutline: string;
// FIXME: component box-shadow, should be removed
/** @internal */
boxShadowPopoverArrow: string;
/** @internal */
boxShadowCard: string;
/** @internal */
boxShadowDrawerRight: string;
/** @internal */
boxShadowDrawerLeft: string;
/** @internal */
boxShadowDrawerUp: string;
/** @internal */
boxShadowDrawerDown: string;
/** @internal */
boxShadowTabsOverflowLeft: string;
/** @internal */
boxShadowTabsOverflowRight: string;
/** @internal */
boxShadowTabsOverflowTop: string;
/** @internal */
boxShadowTabsOverflowBottom: string;
}

195
components/theme/interface/alias.ts

@ -0,0 +1,195 @@
import type * as React from 'react';
import type { MapToken } from './maps';
// ======================================================================
// == Alias Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface AliasToken extends MapToken {
// Background
colorFillContentHover: string;
colorFillAlter: string;
colorFillContent: string;
colorBgContainerDisabled: string;
colorBgTextHover: string;
colorBgTextActive: string;
// Border
colorBorderBg: string;
/**
* @nameZH 线
* @desc 线 colorBorderSecondary
*/
colorSplit: string;
// Text
colorTextPlaceholder: string;
colorTextDisabled: string;
colorTextHeading: string;
colorTextLabel: string;
colorTextDescription: string;
colorTextLightSolid: string;
/** Weak action. Such as `allowClear` or Alert close button */
colorIcon: string;
/** Weak action hover color. Such as `allowClear` or Alert close button */
colorIconHover: string;
colorLink: string;
colorLinkHover: string;
colorLinkActive: string;
colorHighlight: string;
controlOutline: string;
colorWarningOutline: string;
colorErrorOutline: string;
// Font
fontSizeSM: number;
fontSize: number;
fontSizeLG: number;
fontSizeXL: number;
/** Operation icon in Select, Cascader, etc. icon fontSize. Normal is same as fontSizeSM */
fontSizeIcon: number;
/**
* @nameZH
* @desc H1 使
* @default 38
*/
fontSizeHeading1: number;
/**
* @nameZH
* @desc h2 使
* @default 30
*/
fontSizeHeading2: number;
/**
* @nameZH
* @desc h3 使
* @default 24
*/
fontSizeHeading3: number;
/**
* @nameZH
* @desc h4 使
* @default 20
*/
fontSizeHeading4: number;
/**
* @nameZH
* @desc h5 使
* @default 16
*/
fontSizeHeading5: number;
/** For heading like h1, h2, h3 or option selected item */
fontWeightStrong: number;
// LineHeight
lineHeight: number;
lineHeightLG: number;
lineHeightSM: number;
lineHeightHeading1: number;
lineHeightHeading2: number;
lineHeightHeading3: number;
lineHeightHeading4: number;
lineHeightHeading5: number;
// Control
controlOutlineWidth: number;
controlItemBgHover: string; // Note. It also is a color
controlItemBgActive: string; // Note. It also is a color
controlItemBgActiveHover: string; // Note. It also is a color
controlInteractiveSize: number;
controlItemBgActiveDisabled: string; // Note. It also is a color
// Padding
paddingXXS: number;
paddingXS: number;
paddingSM: number;
padding: number;
paddingMD: number;
paddingLG: number;
paddingXL: number;
// Padding Content
paddingContentHorizontalLG: number;
paddingContentHorizontal: number;
paddingContentHorizontalSM: number;
paddingContentVerticalLG: number;
paddingContentVertical: number;
paddingContentVerticalSM: number;
// Margin
marginXXS: number;
marginXS: number;
marginSM: number;
margin: number;
marginMD: number;
marginLG: number;
marginXL: number;
marginXXL: number;
// =============== Legacy: should be remove ===============
opacityLoading: number;
boxShadow: string;
boxShadowSecondary: string;
linkDecoration: React.CSSProperties['textDecoration'];
linkHoverDecoration: React.CSSProperties['textDecoration'];
linkFocusDecoration: React.CSSProperties['textDecoration'];
controlPaddingHorizontal: number;
controlPaddingHorizontalSM: number;
// Media queries breakpoints
screenXS: number;
screenXSMin: number;
screenXSMax: number;
screenSM: number;
screenSMMin: number;
screenSMMax: number;
screenMD: number;
screenMDMin: number;
screenMDMax: number;
screenLG: number;
screenLGMin: number;
screenLGMax: number;
screenXL: number;
screenXLMin: number;
screenXLMax: number;
screenXXL: number;
screenXXLMin: number;
screenXXLMax: number;
/** Used for DefaultButton, Switch which has default outline */
controlTmpOutline: string;
// FIXME: component box-shadow, should be removed
/** @internal */
boxShadowPopoverArrow: string;
/** @internal */
boxShadowCard: string;
/** @internal */
boxShadowDrawerRight: string;
/** @internal */
boxShadowDrawerLeft: string;
/** @internal */
boxShadowDrawerUp: string;
/** @internal */
boxShadowDrawerDown: string;
/** @internal */
boxShadowTabsOverflowLeft: string;
/** @internal */
boxShadowTabsOverflowRight: string;
/** @internal */
boxShadowTabsOverflowTop: string;
/** @internal */
boxShadowTabsOverflowBottom: string;
}

111
components/theme/interface/components.ts

@ -0,0 +1,111 @@
import type { ComponentToken as AlertComponentToken } from '../../alert/style';
import type { ComponentToken as AnchorComponentToken } from '../../anchor/style';
import type { ComponentToken as AvatarComponentToken } from '../../avatar/style';
import type { ComponentToken as BackTopComponentToken } from '../../back-top/style';
import type { ComponentToken as ButtonComponentToken } from '../../button/style';
import type { ComponentToken as FloatButtonComponentToken } from '../../float-button/style';
import type { ComponentToken as CalendarComponentToken } from '../../calendar/style';
import type { ComponentToken as CardComponentToken } from '../../card/style';
import type { ComponentToken as CarouselComponentToken } from '../../carousel/style';
import type { ComponentToken as CascaderComponentToken } from '../../cascader/style';
import type { ComponentToken as CheckboxComponentToken } from '../../checkbox/style';
import type { ComponentToken as CollapseComponentToken } from '../../collapse/style';
import type { ComponentToken as DatePickerComponentToken } from '../../date-picker/style';
import type { ComponentToken as DividerComponentToken } from '../../divider/style';
import type { ComponentToken as DropdownComponentToken } from '../../dropdown/style';
import type { ComponentToken as DrawerComponentToken } from '../../drawer/style';
import type { ComponentToken as EmptyComponentToken } from '../../empty/style';
import type { ComponentToken as ImageComponentToken } from '../../image/style';
import type { ComponentToken as InputNumberComponentToken } from '../../input-number/style';
import type { ComponentToken as LayoutComponentToken } from '../../layout/style';
import type { ComponentToken as ListComponentToken } from '../../list/style';
import type { ComponentToken as MentionsComponentToken } from '../../mentions/style';
import type { ComponentToken as MenuComponentToken } from '../../menu/style';
import type { ComponentToken as MessageComponentToken } from '../../message/style';
import type { ComponentToken as ModalComponentToken } from '../../modal/style';
import type { ComponentToken as NotificationComponentToken } from '../../notification/style';
import type { ComponentToken as PopconfirmComponentToken } from '../../popconfirm/style';
import type { ComponentToken as PopoverComponentToken } from '../../popover/style';
import type { ComponentToken as ProgressComponentToken } from '../../progress/style';
import type { ComponentToken as RadioComponentToken } from '../../radio/style';
import type { ComponentToken as RateComponentToken } from '../../rate/style';
import type { ComponentToken as ResultComponentToken } from '../../result/style';
import type { ComponentToken as SegmentedComponentToken } from '../../segmented/style';
import type { ComponentToken as SelectComponentToken } from '../../select/style';
import type { ComponentToken as SkeletonComponentToken } from '../../skeleton/style';
import type { ComponentToken as SliderComponentToken } from '../../slider/style';
import type { ComponentToken as SpaceComponentToken } from '../../space/style';
import type { ComponentToken as SpinComponentToken } from '../../spin/style';
import type { ComponentToken as StepsComponentToken } from '../../steps/style';
import type { ComponentToken as TableComponentToken } from '../../table/style';
import type { ComponentToken as TabsComponentToken } from '../../tabs/style';
import type { ComponentToken as TagComponentToken } from '../../tag/style';
import type { ComponentToken as TimelineComponentToken } from '../../timeline/style';
import type { ComponentToken as TooltipComponentToken } from '../../tooltip/style';
import type { ComponentToken as TransferComponentToken } from '../../transfer/style';
import type { ComponentToken as TypographyComponentToken } from '../../typography/style';
import type { ComponentToken as UploadComponentToken } from '../../upload/style';
import type { ComponentToken as TourComponentToken } from '../../tour/style';
export interface ComponentTokenMap {
Affix?: {};
Alert?: AlertComponentToken;
Anchor?: AnchorComponentToken;
Avatar?: AvatarComponentToken;
BackTop?: BackTopComponentToken;
Badge?: {};
Button?: ButtonComponentToken;
Breadcrumb?: {};
Card?: CardComponentToken;
Carousel?: CarouselComponentToken;
Cascader?: CascaderComponentToken;
Checkbox?: CheckboxComponentToken;
Collapse?: CollapseComponentToken;
DatePicker?: DatePickerComponentToken;
Descriptions?: {};
Divider?: DividerComponentToken;
Drawer?: DrawerComponentToken;
Dropdown?: DropdownComponentToken;
Empty?: EmptyComponentToken;
FloatButton?: FloatButtonComponentToken;
Form?: {};
Grid?: {};
Image?: ImageComponentToken;
Input?: {};
InputNumber?: InputNumberComponentToken;
Layout?: LayoutComponentToken;
List?: ListComponentToken;
Mentions?: MentionsComponentToken;
Notification?: NotificationComponentToken;
Pagination?: {};
Popover?: PopoverComponentToken;
Popconfirm?: PopconfirmComponentToken;
Rate?: RateComponentToken;
Radio?: RadioComponentToken;
Result?: ResultComponentToken;
Segmented?: SegmentedComponentToken;
Select?: SelectComponentToken;
Skeleton?: SkeletonComponentToken;
Slider?: SliderComponentToken;
Spin?: SpinComponentToken;
Statistic?: {};
Switch?: {};
Tag?: TagComponentToken;
Tree?: {};
TreeSelect?: {};
Typography?: TypographyComponentToken;
Timeline?: TimelineComponentToken;
Transfer?: TransferComponentToken;
Tabs?: TabsComponentToken;
Calendar?: CalendarComponentToken;
Steps?: StepsComponentToken;
Menu?: MenuComponentToken;
Modal?: ModalComponentToken;
Message?: MessageComponentToken;
Upload?: UploadComponentToken;
Tooltip?: TooltipComponentToken;
Table?: TableComponentToken;
Space?: SpaceComponentToken;
Progress?: ProgressComponentToken;
Tour?: TourComponentToken;
}

25
components/theme/interface/index.ts

@ -0,0 +1,25 @@
import type { ComponentTokenMap } from './components';
import type { AliasToken } from './alias';
export type OverrideToken = {
[key in keyof ComponentTokenMap]: Partial<ComponentTokenMap[key]> & Partial<AliasToken>;
};
/** Final token which contains the components level override */
export type GlobalToken = AliasToken & ComponentTokenMap;
export { PresetColors } from './presetColors';
export type { PresetColorType, ColorPalettes } from './presetColors';
export type { SeedToken } from './seeds';
export type {
MapToken,
ColorMapToken,
ColorNeutralMapToken,
CommonMapToken,
HeightMapToken,
SizeMapToken,
FontSizeMapToken,
StyleMapToken,
} from './maps';
export type { AliasToken } from './alias';
export type { ComponentTokenMap } from './components';

437
components/theme/interface/maps/colors.ts

@ -0,0 +1,437 @@
export interface ColorNeutralMapToken {
/**
* @internal
*/
colorTextBase: string;
/**
* @internal
*/
colorBgBase: string;
// ---------- Text ---------- //
/**
* @nameZH
* @desc W3C标准使
*/
colorText: string;
/**
* @nameZH
* @desc Label Menu
*/
colorTextSecondary: string;
/**
* @nameZH
* @desc
*/
colorTextTertiary: string;
/**
* @nameZH
* @desc
*/
colorTextQuaternary: string;
// ---------- Border ---------- //
/**
* @nameZH
* @nameEN Default Border Color
* @desc 使, 线线
* @descEN Default border color, used to separate different elements, such as: form separator, card separator, etc.
*/
colorBorder: string;
/**
* @nameZH
* @nameEN Secondary Border Color
* @desc 使 colorSplit 使
* @descEN Slightly lighter than the default border color, this color is the same as `colorSplit`. Solid color is used.
*/
colorBorderSecondary: string;
// ---------- Fill ---------- //
/**
* @nameZH
* @desc Slider hover
*/
colorFill: string;
/**
* @nameZH
* @desc RateSkeleton Hover Table
*/
colorFillSecondary: string;
/**
* @nameZH
* @desc SliderSegmented 使
*/
colorFillTertiary: string;
/**
* @nameZH
* @desc
*/
colorFillQuaternary: string;
// ---------- Surface ---------- //
/**
* @nameZH
* @desc B1 使 token
*/
colorBgLayout: string;
/**
* @nameZH
* @desc `colorBgElevated`
*/
colorBgContainer: string;
/**
* @nameZH
* @desc token `colorBgContainer`
*/
colorBgElevated: string;
/**
* @nameZH
* @desc Tooltip
*/
colorBgSpotlight: string;
}
/**
*
*/
interface ColorPrimaryMapToken {
/**
* @nameZH
* @desc */
colorPrimary: string; // 6
/**
* @nameZH
* @nameEN Light Background Color of Primary Color
* @desc
* @descEN Light background color of primary color, usually used for weak visual level selection state.
*/
colorPrimaryBg: string; // 1
/**
* @nameZH
* @desc
*/
colorPrimaryBgHover: string; // 2
/**
* @nameZH
* @desc Slider
*/
colorPrimaryBorder: string; // 3
/**
* @nameZH
* @desc Slider Button Hover 使
*/
colorPrimaryBorderHover: string; // 4
/**
* @nameZH
* @desc 使
*/
colorPrimaryHover: string; // 5
/**
* @nameZH
* @desc
*/
colorPrimaryActive: string; // 7
/**
* @nameZH
* @desc
*/
colorPrimaryTextHover: string; // 8
/**
* @nameZH
* @desc
*/
colorPrimaryText: string; // 9
/**
* @nameZH
* @desc
*/
colorPrimaryTextActive: string; // 10
}
interface ColorSuccessMapToken {
/**
* @nameZH
* @nameEN Light Background Color of Success Color
* @desc Tag Alert
* @descEN Light background color of success color, used for Tag and Alert success state background color
*/
colorSuccessBg: string; // 1
/**
* @nameZH
* @nameEN Hover State Color of Light Success Background
* @desc antd 使 token
* @descEN Light background color of success color, but antd does not use this token currently
*/
colorSuccessBgHover: string; // 2
/**
* @nameZH
* @desc Tag Alert
*/
colorSuccessBorder: string; // 3
/**
* @nameZH
* @desc
*/
colorSuccessBorderHover: string; // 4
/**
* @nameZH
* @desc
*/
colorSuccessHover: string; // 5
/**
* @nameZH
* @desc ResultProgress 使
*/
colorSuccess: string; // 6
/**
* @nameZH
* @desc
*/
colorSuccessActive: string; // 7
/**
* @nameZH
* @desc
*/
colorSuccessTextHover: string; // 8
/**
* @nameZH
* @desc
*/
colorSuccessText: string; // 9
/**
* @nameZH
* @desc
*/
colorSuccessTextActive: string; // 10
}
interface ColorWarningMapToken {
/**
* @nameZH
*/
colorWarningBg: string; // 1
/**
* @nameZH
* @desc
*/
colorWarningBgHover: string; // 2
/**
* @nameZH
* @desc
*/
colorWarningBorder: string; // 3
/**
* @nameZH
* @desc
*/
colorWarningBorderHover: string; // 4
/**
* @nameZH
* @desc
*/
colorWarningHover: string; // 5
/**
* @nameZH
* @desc Notification Alert等警告类组件或 Input 使
*/
colorWarning: string; // 6
/**
* @nameZH
* @desc
*/
colorWarningActive: string; // 7
/**
* @nameZH
* @desc
*/
colorWarningTextHover: string; // 8
/**
* @nameZH
* @desc
*/
colorWarningText: string; // 9
/**
* @nameZH
* @desc
*/
colorWarningTextActive: string; // 10
}
interface ColorInfoMapToken {
/**
* @nameZH
* @desc
*/
colorInfoBg: string; // 1
/**
* @nameZH
* @desc
*/
colorInfoBgHover: string; // 2
/**
* @nameZH
*/
colorInfoBorder: string; // 3
/**
* @nameZH
*/
colorInfoBorderHover: string; // 4
/**
* @nameZH
*/
colorInfoHover: string; // 5
/**
* @nameZH
*/
colorInfo: string; // 6
/**
* @nameZH
*/
colorInfoActive: string; // 7
/**
* @nameZH
*/
colorInfoTextHover: string; // 8
/**
* @nameZH
*/
colorInfoText: string; // 9
/**
* @nameZH
*/
colorInfoTextActive: string; // 10
}
interface ColorErrorMapToken {
/**
* @nameZH
*/
colorErrorBg: string; // 1
/**
* @nameZH
*/
colorErrorBgHover: string; // 2
/**
* @nameZH
*/
colorErrorBorder: string; // 3
/**
* @nameZH
*/
colorErrorBorderHover: string; // 4
/**
* @nameZH
*/
colorErrorHover: string; // 5
/**
* @nameZH
*/
colorError: string; // 6
/**
* @nameZH
*/
colorErrorActive: string; // 7
/**
* @nameZH
*/
colorErrorTextHover: string; // 8
/**
* @nameZH
*/
colorErrorText: string; // 9
/**
* @nameZH
*/
colorErrorTextActive: string; // 10
}
export interface ColorMapToken
extends ColorNeutralMapToken,
ColorPrimaryMapToken,
ColorSuccessMapToken,
ColorWarningMapToken,
ColorErrorMapToken,
ColorInfoMapToken {
/**
* @nameZH
* @desc
* @descEN Pure white color don't changed by theme
* @default #FFFFFF
*/
colorWhite: string;
/**
* @nameZH
* @nameEN Background color of the mask
* @desc ModalDrawer 使 token
* @descEN The background color of the mask, used to cover the content below the mask, Modal, Drawer and other components use this token
*/
colorBgMask: string;
/**
* @nameZH
* @desc
* @default #0000
*/
// colorBlack: string;
}

30
components/theme/interface/maps/index.ts

@ -0,0 +1,30 @@
import type { ColorPalettes } from '../presetColors';
import type { SeedToken } from '../seeds';
import type { SizeMapToken, HeightMapToken, FontSizeMapToken } from './size';
import type { ColorMapToken } from './colors';
import type { StyleMapToken } from './style';
export * from './colors';
export * from './style';
export * from './size';
export interface CommonMapToken extends FontSizeMapToken, StyleMapToken {
// Motion
motionDurationFast: string;
motionDurationMid: string;
motionDurationSlow: string;
}
// ======================================================================
// == Map Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface MapToken
extends SeedToken,
ColorPalettes,
ColorMapToken,
SizeMapToken,
HeightMapToken,
StyleMapToken,
CommonMapToken {}

67
components/theme/interface/maps/size.ts

@ -0,0 +1,67 @@
export interface SizeMapToken {
/**
* @nameZH XXL
* @default 48
*/
sizeXXL: number;
/**
* @nameZH XL
* @default 32
*/
sizeXL: number;
/**
* @nameZH LG
* @default 24
*/
sizeLG: number;
/**
* @nameZH MD
* @default 20
*/
sizeMD: number;
/** Same as size by default, but could be larger in compact mode */
sizeMS: number;
/**
* @nameZH
* @desc
* @default 16
*/
size: number;
/**
* @nameZH SM
* @default 12
*/
sizeSM: number;
/**
* @nameZH XS
* @default 8
*/
sizeXS: number;
/**
* @nameZH XXS
* @default 4
*/
sizeXXS: number;
}
export interface HeightMapToken {
// Control
/** @internal Only Used for control inside component like Multiple Select inner selection item */
controlHeightXS: number;
/** @internal */
controlHeightSM: number;
/** @internal */
controlHeightLG: number;
}
// Font
export interface FontSizeMapToken {
/**
* @internal
*/
fontSizes: number[];
/**
* @internal
*/
lineHeights: number[];
}

39
components/theme/interface/maps/style.ts

@ -0,0 +1,39 @@
export interface StyleMapToken {
/**
* @nameZH 线
* @nameEN Line Width
* @desc 线 ButtonInputSelect
* @descEN The default line width of the outline class components, such as Button, Input, Select, etc.
* @default 1
*/
lineWidthBold: number;
/**
* @nameZH XS号圆角
* @desc XS号圆角 Segmented Arrow
* @descEN XS size border radius, used in some small border radius components, such as Segmented, Arrow and other components.
* @default 2
*/
borderRadiusXS: number;
/**
* @nameZH SM号圆角
* @nameEN SM Border Radius
* @desc SM号圆角 ButtonInputSelect small size
* @descEN SM size border radius, used in small size components, such as Button, Input, Select and other input components in small size
* @default 4
*/
borderRadiusSM: number;
/**
* @nameZH LG号圆角
* @nameEN LG Border Radius
* @desc LG号圆角 CardModal
* @descEN LG size border radius, used in some large border radius components, such as Card, Modal and other components.
* @default 8
*/
borderRadiusLG: number;
/**
* @default 4
* @internal
*/
borderRadiusOuter: number;
}

25
components/theme/interface/presetColors.ts

@ -0,0 +1,25 @@
export const PresetColors = [
'blue',
'purple',
'cyan',
'green',
'magenta',
'pink',
'red',
'orange',
'yellow',
'volcano',
'geekblue',
'lime',
'gold',
] as const;
type PresetColorKey = typeof PresetColors[number];
export type PresetColorType = Record<PresetColorKey, string>;
type ColorPaletteKeyIndex = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
export type ColorPalettes = {
[key in `${keyof PresetColorType}-${ColorPaletteKeyIndex}`]: string;
};

240
components/theme/interface/seeds.ts

@ -0,0 +1,240 @@
import type { PresetColorType } from './presetColors';
// ======================================================================
// == Seed Token ==
// ======================================================================
// 🔥🔥🔥🔥🔥🔥🔥 DO NOT MODIFY THIS. PLEASE CONTACT DESIGNER. 🔥🔥🔥🔥🔥🔥🔥
export interface SeedToken extends PresetColorType {
// ---------- Color ---------- //
/**
* @nameZH
* @nameEN Brand Color
* @desc
* @descEN Brand color is one of the most direct visual elements to reflect the characteristics and communication of the product. After you have selected the brand color, we will automatically generate a complete color palette and assign it effective design semantics.
*/
colorPrimary: string;
/**
* @nameZH
* @nameEN Success Color
* @desc Token ResultProgress 使
* @descEN Used to represent the token sequence of operation success, such as Result, Progress and other components will use these map tokens.
*/
colorSuccess: string;
/**
* @nameZH
* @nameEN Warning Color
* @desc Token Notification Alert等警告类组件或 Input 使
* @descEN Used to represent the warning map token, such as Notification, Alert, etc. Alert or Control component(like Input) will use these map tokens.
*/
colorWarning: string;
/**
* @nameZH
* @nameEN Error Color
* @desc Token Result
* @descEN Used to represent the visual elements of the operation failure, such as the error Button, error Result component, etc.
*/
colorError: string;
/**
* @nameZH
* @desc Token Alert Tag Progress
* @descEN Used to represent the operation information of the Token sequence, such as Alert, Tag, Progress, and other components use these map tokens.
*/
colorInfo: string;
/**
* @nameZH
* @nameEN Seed Text Color
* @desc v5 **使 Seed Token**
* @descEN Used to derive the base variable of the text color gradient. In v5, we added a layer of text color derivation algorithm to produce gradient variables of text color gradient. But please do not use this Seed Token directly in the code!
*/
colorTextBase: string;
/**
* @nameZH
* @nameEN Seed Background Color
* @desc v5 **使 Seed Token**
* @descEN Used to derive the base variable of the background color gradient. In v5, we added a layer of background color derivation algorithm to produce map token of background color. But PLEASE DO NOT USE this Seed Token directly in the code!
*/
colorBgBase: string;
// ---------- Font ---------- //
/**
* @nameZH
* @nameEN FontFamily
* @desc Ant Design 使
*/
fontFamily: string;
/**
* @nameZH
* @desc 使广
* @default 14
*/
fontSize: number;
// ---------- Line ---------- //
/**
* @nameZH 线
* @nameEN Base Line Width
* @desc 线
* @descEN Border width of base components
*/
lineWidth: number;
/**
* @nameZH 线
* @nameEN Line Style
* @desc 线线
* @descEN Border style of base components
*/
lineType: string;
// ---------- BorderRadius ---------- //
/**
* @nameZH
* @nameEN Base Border Radius
* @descEN Border radius of base components
* @desc
*/
borderRadius: number;
// ---------- Size ---------- //
/**
* @nameZH
* @nameEN Size Change Unit
* @desc Ant Design 4 便
* @descEN The unit of size change, in Ant Design, our base unit is 4, which is more fine-grained control of the size step
* @default 4
*/
sizeUnit: number;
/**
* @nameZH
* @nameEN Size Base Step
* @desc V5 2
* @descEN The base step of size change, the size step combined with the size change unit, can derive various size steps. By adjusting the step, you can get different layout modes, such as the size step of the compact mode of V5 is 2
* @default 4
*/
sizeStep: number;
/**
* @nameZH
* @internal
*/
sizePopupArrow: number;
/**
* @nameZH
* @nameEN Base Control Height
* @desc Ant Design
* @descEN The height of the basic controls such as buttons and input boxes in Ant Design
* @default 32
*/
controlHeight: number;
// ---------- zIndex ---------- //
/**
* @nameZH zIndex
* @nameEN Base zIndex
* @desc Z Z BackTop Affix
* @descEN The base Z axis value of all components, which can be used to control the level of some floating components based on the Z axis value, such as BackTop, Affix, etc.
*
* @default 0
*/
zIndexBase: number;
/**
* @nameZH zIndex
* @nameEN popup base zIndex
* @desc Z Z FloatButton AffixModal
* @descEN Base zIndex of component like FloatButton, Affix which can be cover by large popup
* @default 1000
*/
zIndexPopupBase: number;
// ---------- Opacity ---------- //
/**
* @nameZH
* @nameEN Define default Image opacity. Useful when in dark-like theme
* @internal
*/
opacityImage: number;
// ---------- motion ---------- //
// TODO: 缺一个懂 motion 的人来收敛 Motion 相关的 Token
/**
* @nameZH
* @nameEN Animation Duration Unit
* @desc
* @descEN The unit of animation duration change
* @default 100ms
*/
motionUnit: number;
/**
* @nameZH
* @internal
*/
motionBase: number;
/**
* @internal
*/
motionEaseOutCirc: string;
/**
* @internal
*/
motionEaseInOutCirc: string;
/**
* @internal
*/
motionEaseInOut: string;
/**
* @internal
*/
motionEaseOutBack: string;
/**
* @internal
*/
motionEaseInBack: string;
/**
* @internal
*/
motionEaseInQuint: string;
/**
* @internal
*/
motionEaseOutQuint: string;
/**
* @internal
*/
motionEaseOut: string;
// ---------- Style ---------- //
/**
* @nameZH 线
* @desc 线使 V4
* @default false
*/
wireframe: boolean;
}

4
components/theme/themes/ColorMap.ts

@ -1,4 +1,4 @@
import type { NeutralColorMapToken } from '../interface';
import type { ColorNeutralMapToken } from '../interface';
export interface ColorMap {
1: string;
@ -17,4 +17,4 @@ export type GenerateColorMap = (baseColor: string) => ColorMap;
export type GenerateNeutralColorMap = (
bgBaseColor: string,
textBaseColor: string,
) => NeutralColorMapToken;
) => ColorNeutralMapToken;

19
scripts/generate-token-meta.js

@ -6,11 +6,14 @@ const getTokenList = (list, source) =>
.filter((item) => !item.comment?.blockTags.some((tag) => tag.tag === '@internal'))
.map((item) => ({
source,
name: item.name,
token: item.name,
type: item.type.toString(),
desc: item.comment?.blockTags?.find((tag) => tag.tag === '@desc')?.content[0]?.text || '-',
descEn:
item.comment?.blockTags?.find((tag) => tag.tag === '@descEn')?.content[0]?.text || '-',
item.comment?.blockTags?.find((tag) => tag.tag === '@descEN')?.content[0]?.text || '-',
name: item.comment?.blockTags?.find((tag) => tag.tag === '@nameZH')?.content[0]?.text || '-',
nameEn:
item.comment?.blockTags?.find((tag) => tag.tag === '@nameEN')?.content[0]?.text || '-',
}));
function main() {
@ -22,7 +25,7 @@ function main() {
app.bootstrap({
// typedoc options here
entryPoints: ['components/theme/interface.ts'],
entryPoints: ['components/theme/interface/index.ts'],
});
const project = app.convert();
@ -46,20 +49,20 @@ function main() {
// Exclude preset colors
tokenMeta.seed = tokenMeta.seed.filter(
(item) => !presetColors.some((color) => item.name.startsWith(color)),
(item) => !presetColors.some((color) => item.token.startsWith(color)),
);
tokenMeta.map = tokenMeta.map.filter(
(item) => !presetColors.some((color) => item.name.startsWith(color)),
(item) => !presetColors.some((color) => item.token.startsWith(color)),
);
tokenMeta.alias = tokenMeta.alias.filter(
(item) => !presetColors.some((color) => item.name.startsWith(color)),
(item) => !presetColors.some((color) => item.token.startsWith(color)),
);
tokenMeta.alias = tokenMeta.alias.filter(
(item) => !tokenMeta.map.some((mapItem) => mapItem.name === item.name),
(item) => !tokenMeta.map.some((mapItem) => mapItem.token === item.token),
);
tokenMeta.map = tokenMeta.map.filter(
(item) => !tokenMeta.seed.some((seedItem) => seedItem.name === item.name),
(item) => !tokenMeta.seed.some((seedItem) => seedItem.token === item.token),
);
fs.writeJsonSync(output, tokenMeta, 'utf8');

Loading…
Cancel
Save