diff --git a/src/color-picker/components/panel/format/index.tsx b/src/color-picker/components/panel/format/index.tsx index 4c5eb51547..bb4c3e1685 100644 --- a/src/color-picker/components/panel/format/index.tsx +++ b/src/color-picker/components/panel/format/index.tsx @@ -3,7 +3,7 @@ import upperCase from 'lodash/upperCase'; import Select from '../../../../select'; import FormatInput from './inputs'; import Color from '../../../../_common/js/color-picker/color'; -import { FORMATS } from '../../../const'; +import { FORMATS } from '../../../../_common/js/color-picker/constants'; import { TdColorPickerProps } from '../../../type'; export interface TdColorFormatProps extends TdColorPickerProps { @@ -21,8 +21,6 @@ const FormatPanel = (props: TdColorFormatProps) => { onModeChange(v); }; - const formats: TdColorPickerProps['format'][] = [...FORMATS]; - return ( <div className={`${baseClassName}__format`}> <div className={`${baseClassName}__format--item`}> @@ -37,7 +35,7 @@ const FormatPanel = (props: TdColorFormatProps) => { value={formatMode} onChange={handleModeChange} > - {formats.map((item) => ( + {FORMATS.map((item) => ( <Select.Option key={item} value={item} label={upperCase(item)} style={{ fontSize: '12px' }} /> ))} </Select> diff --git a/src/color-picker/components/panel/header.tsx b/src/color-picker/components/panel/header.tsx index e7c93de067..c1a54242aa 100644 --- a/src/color-picker/components/panel/header.tsx +++ b/src/color-picker/components/panel/header.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { COLOR_MODES } from '../../const'; +import { COLOR_MODES } from '../../../_common/js/color-picker/constants'; import Radio, { RadioValue } from '../../../radio'; import { TdColorModes } from '../../interface'; import { TdColorPickerProps } from '../../type'; diff --git a/src/color-picker/components/panel/index.tsx b/src/color-picker/components/panel/index.tsx index 54518c5546..b251c3bd53 100644 --- a/src/color-picker/components/panel/index.tsx +++ b/src/color-picker/components/panel/index.tsx @@ -13,7 +13,7 @@ import { DEFAULT_LINEAR_GRADIENT, TD_COLOR_USED_COLORS_MAX_SIZE, DEFAULT_SYSTEM_SWATCH_COLORS, -} from '../../const'; +} from '../../../_common/js/color-picker/constants'; import { ColorPickerProps, TdColorModes, TdColorSaturationData } from '../../interface'; import { ColorPickerChangeTrigger, TdColorPickerProps } from '../../type'; import { colorPickerDefaultProps } from '../../defaultProps'; diff --git a/src/color-picker/components/panel/linear-gradient.tsx b/src/color-picker/components/panel/linear-gradient.tsx index 8f68809f6c..b16b89ee72 100644 --- a/src/color-picker/components/panel/linear-gradient.tsx +++ b/src/color-picker/components/panel/linear-gradient.tsx @@ -5,7 +5,7 @@ import useClassName from '../../hooks/useClassNames'; import { genGradientPoint, gradientColors2string } from '../../../_common/js/color-picker/color'; import { GradientColorPoint } from '../../../_common/js/color-picker/gradient'; import useCommonClassName from '../../../hooks/useCommonClassName'; -import { GRADIENT_SLIDER_DEFAULT_WIDTH } from '../../const'; +import { GRADIENT_SLIDER_DEFAULT_WIDTH } from '../../../_common/js/color-picker/constants'; import InputNumber from '../../../input-number'; const DELETE_KEYS: string[] = ['delete', 'backspace']; diff --git a/src/color-picker/components/panel/saturation.tsx b/src/color-picker/components/panel/saturation.tsx index a94ef1516a..72bc6b8b1e 100644 --- a/src/color-picker/components/panel/saturation.tsx +++ b/src/color-picker/components/panel/saturation.tsx @@ -1,5 +1,8 @@ import React, { useRef, useEffect, useCallback } from 'react'; -import { SATURATION_PANEL_DEFAULT_HEIGHT, SATURATION_PANEL_DEFAULT_WIDTH } from '../../const'; +import { + SATURATION_PANEL_DEFAULT_HEIGHT, + SATURATION_PANEL_DEFAULT_WIDTH, +} from '../../../_common/js/color-picker/constants'; import { TdColorBaseProps } from '../../interface'; import useDrag, { Coordinate } from '../../../hooks/useDrag'; diff --git a/src/color-picker/components/panel/slider.tsx b/src/color-picker/components/panel/slider.tsx index 2609dbb7d8..38f90dce9c 100644 --- a/src/color-picker/components/panel/slider.tsx +++ b/src/color-picker/components/panel/slider.tsx @@ -1,6 +1,6 @@ import React, { useRef, useEffect } from 'react'; import classnames from 'classnames'; -import { SLIDER_DEFAULT_WIDTH } from '../../const'; +import { SLIDER_DEFAULT_WIDTH } from '../../../_common/js/color-picker/constants'; import useDrag, { Coordinate } from '../../../hooks/useDrag'; import { TdColorBaseProps } from '../../interface'; import useStyles from '../../hooks/useStyles'; diff --git a/src/color-picker/const.ts b/src/color-picker/const.ts deleted file mode 100644 index f557f15c9d..0000000000 --- a/src/color-picker/const.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { TdColorPickerProps } from '.'; - -/** 常量 */ - -// 最近使用颜色最大个数 -export const TD_COLOR_USED_COLORS_MAX_SIZE = 100; // 每行10个 - -// 颜色模式options配置 -export const COLOR_MODES = { - monochrome: 'singleColor', - 'linear-gradient': 'gradientColor', -}; - -// 非透明色格式化类型 -export const FORMATS: TdColorPickerProps['format'][] = ['HEX', 'RGB', 'HSL', 'HSV', 'CMYK', 'CSS']; - -// 默认颜色 -export const DEFAULT_COLOR = '#001F97'; - -// 默认渐变色 -export const DEFAULT_LINEAR_GRADIENT = 'linear-gradient(90deg, rgba(241,29,0,1) 0%, rgba(73,106,220,1) 100%);'; - -// 默认系统色彩 -export const DEFAULT_SYSTEM_SWATCH_COLORS = [ - '#ECF2FE', - '#D4E3FC', - '#BBD3FB', - '#96BBF8', - '#699EF5', - '#4787F0', - '#266FE8', - '#0052D9', - '#0034B5', - '#001F97', - '#FDECEE', - '#F9D7D9', - '#F8B9BE', - '#F78D94', - '#F36D78', - '#E34D59', - '#C9353F', - '#B11F26', - '#951114', - '#680506', - '#FEF3E6', - '#F9E0C7', - '#F7C797', - '#F2995F', - '#ED7B2F', - '#D35A21', - '#BA431B', - '#9E3610', - '#842B0B', - '#5A1907', - '#E8F8F2', - '#BCEBDC', - '#85DBBE', - '#48C79C', - '#00A870', - '#078D5C', - '#067945', - '#056334', - '#044F2A', - '#033017', -]; - -// saturation-panel default rect -export const SATURATION_PANEL_DEFAULT_WIDTH = 230; -export const SATURATION_PANEL_DEFAULT_HEIGHT = 168; -export const SLIDER_DEFAULT_WIDTH = 168; -export const GRADIENT_SLIDER_DEFAULT_WIDTH = 158;