2022-09-22 16:55:55 +08:00
|
|
|
/* eslint-disable import/prefer-default-export */
|
|
|
|
|
|
|
|
import type * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
2023-01-06 11:06:46 +08:00
|
|
|
import { isPresetColor } from '../_util/colors';
|
2022-09-22 16:55:55 +08:00
|
|
|
|
|
|
|
export function parseColor(prefixCls: string, color?: string) {
|
2023-01-06 11:06:46 +08:00
|
|
|
const isInternalColor = isPresetColor(color);
|
|
|
|
|
2022-09-22 16:55:55 +08:00
|
|
|
const className = classNames({
|
2023-01-06 11:06:46 +08:00
|
|
|
[`${prefixCls}-${color}`]: color && isInternalColor,
|
2022-09-22 16:55:55 +08:00
|
|
|
});
|
|
|
|
|
2022-11-18 18:37:18 +08:00
|
|
|
const overlayStyle: React.CSSProperties = {};
|
|
|
|
const arrowStyle: React.CSSProperties = {};
|
2022-09-22 16:55:55 +08:00
|
|
|
|
2023-01-06 11:06:46 +08:00
|
|
|
if (color && !isInternalColor) {
|
2022-11-18 18:37:18 +08:00
|
|
|
overlayStyle.background = color;
|
2022-09-22 16:55:55 +08:00
|
|
|
// @ts-ignore
|
2022-11-18 18:37:18 +08:00
|
|
|
arrowStyle['--antd-arrow-background-color'] = color;
|
2022-09-22 16:55:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return { className, overlayStyle, arrowStyle };
|
|
|
|
}
|