mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
538d15a094
* refactor: extract color func * fix: Tooltip render panel color * test: Update snapshot
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import * as React from 'react';
|
|
import { Popup } from 'rc-tooltip';
|
|
import classNames from 'classnames';
|
|
import type { TooltipProps } from '.';
|
|
import { ConfigContext } from '../config-provider';
|
|
|
|
import useStyle from './style';
|
|
import { parseColor } from './util';
|
|
|
|
export interface PurePanelProps extends Omit<TooltipProps, 'children'> {}
|
|
|
|
// ant-tooltip css-dev-only-do-not-override-w2s56n ant-tooltip-placement-top ant-tooltip-hidden
|
|
|
|
export default function PurePanel(props: PurePanelProps) {
|
|
const {
|
|
prefixCls: customizePrefixCls,
|
|
className,
|
|
placement = 'top',
|
|
title,
|
|
color,
|
|
overlayInnerStyle,
|
|
} = props;
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('tooltip', customizePrefixCls);
|
|
const [wrapSSR, hashId] = useStyle(prefixCls, true);
|
|
|
|
// Color
|
|
const colorInfo = parseColor(prefixCls, color);
|
|
const formattedOverlayInnerStyle = { ...overlayInnerStyle, ...colorInfo.overlayStyle };
|
|
const arrowContentStyle = colorInfo.arrowStyle;
|
|
|
|
return wrapSSR(
|
|
<div
|
|
className={classNames(
|
|
hashId,
|
|
prefixCls,
|
|
`${prefixCls}-pure`,
|
|
`${prefixCls}-placement-${placement}`,
|
|
className,
|
|
colorInfo.className,
|
|
)}
|
|
style={arrowContentStyle}
|
|
>
|
|
<Popup
|
|
{...props}
|
|
className={hashId}
|
|
prefixCls={prefixCls}
|
|
overlayInnerStyle={formattedOverlayInnerStyle}
|
|
>
|
|
{title}
|
|
</Popup>
|
|
</div>,
|
|
);
|
|
}
|