mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
863f61d908
Co-authored-by: afc163 <afc163@gmail.com>
24 lines
634 B
TypeScript
24 lines
634 B
TypeScript
import type * as React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
import { isPresetColor } from '../_util/colors';
|
|
|
|
export function parseColor(prefixCls: string, color?: string) {
|
|
const isInternalColor = isPresetColor(color);
|
|
|
|
const className = classNames({
|
|
[`${prefixCls}-${color}`]: color && isInternalColor,
|
|
});
|
|
|
|
const overlayStyle: React.CSSProperties = {};
|
|
const arrowStyle: React.CSSProperties = {};
|
|
|
|
if (color && !isInternalColor) {
|
|
overlayStyle.background = color;
|
|
// @ts-ignore
|
|
arrowStyle['--antd-arrow-background-color'] = color;
|
|
}
|
|
|
|
return { className, overlayStyle, arrowStyle };
|
|
}
|