mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
ffe73ac23f
* feat: color-picker support cssvar * fix: replace rootCls * fix: popover add mergeRootCls * fix: lint issue
85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import { unit, type CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import type { GenerateStyle } from '../../theme/internal';
|
|
import { getTransBg } from './color-block';
|
|
import type { ColorPickerToken } from './index';
|
|
|
|
const genPickerStyle: GenerateStyle<ColorPickerToken, CSSObject> = (token) => {
|
|
const {
|
|
componentCls,
|
|
controlHeightLG,
|
|
borderRadiusSM,
|
|
colorPickerInsetShadow,
|
|
marginSM,
|
|
colorBgElevated,
|
|
colorFillSecondary,
|
|
lineWidthBold,
|
|
colorPickerHandlerSize,
|
|
colorPickerHandlerSizeSM,
|
|
colorPickerSliderHeight,
|
|
} = token;
|
|
|
|
return {
|
|
[`${componentCls}-select`]: {
|
|
[`${componentCls}-palette`]: {
|
|
minHeight: token.calc(controlHeightLG).mul(4).equal(),
|
|
overflow: 'hidden',
|
|
borderRadius: borderRadiusSM,
|
|
},
|
|
[`${componentCls}-saturation`]: {
|
|
position: 'absolute',
|
|
borderRadius: 'inherit',
|
|
boxShadow: colorPickerInsetShadow,
|
|
inset: 0,
|
|
},
|
|
marginBottom: marginSM,
|
|
},
|
|
|
|
[`${componentCls}-handler`]: {
|
|
width: colorPickerHandlerSize,
|
|
height: colorPickerHandlerSize,
|
|
border: `${unit(lineWidthBold)} solid ${colorBgElevated}`,
|
|
position: 'relative',
|
|
borderRadius: '50%',
|
|
cursor: 'pointer',
|
|
boxShadow: `${colorPickerInsetShadow}, 0 0 0 1px ${colorFillSecondary}`,
|
|
'&-sm': {
|
|
width: colorPickerHandlerSizeSM,
|
|
height: colorPickerHandlerSizeSM,
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-slider`]: {
|
|
borderRadius: token.calc(colorPickerSliderHeight).div(2).equal(),
|
|
[`${componentCls}-palette`]: {
|
|
height: colorPickerSliderHeight,
|
|
},
|
|
[`${componentCls}-gradient`]: {
|
|
borderRadius: token.calc(colorPickerSliderHeight).div(2).equal(),
|
|
boxShadow: colorPickerInsetShadow,
|
|
},
|
|
'&-alpha': getTransBg(`${unit(colorPickerSliderHeight)}`, token.colorFillSecondary),
|
|
'&-hue': { marginBottom: marginSM },
|
|
},
|
|
|
|
[`${componentCls}-slider-container`]: {
|
|
display: 'flex',
|
|
gap: marginSM,
|
|
marginBottom: marginSM,
|
|
[`${componentCls}-slider-group`]: {
|
|
flex: 1,
|
|
'&-disabled-alpha': {
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
[`${componentCls}-slider`]: {
|
|
flex: 1,
|
|
marginBottom: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
export default genPickerStyle;
|