HelpDot.tsx
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { CSSProperties, ReactNode } from 'react';
import { Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
/**
* 一句口径 / 用法说明收进这颗问号。
*
* 常驻横幅会把下面的读数往下压,而这类文字属于「读过一次就够」的解释,不是每眼都要核的数 ——
* 鼠标悬停或键盘聚焦才展开,需要时再看。长相与清单头排序说明、统计维度判定说明同一套(.hm-help)。
*/
export function HelpDot({
text,
label = '说明',
className,
style,
}: {
text: ReactNode;
label?: string;
className?: string;
style?: CSSProperties;
}) {
return (
<Tooltip
title={text}
placement="bottomRight"
trigger={['hover', 'focus']}
styles={{ root: { maxWidth: 360 }, container: { fontSize: 12, lineHeight: 1.7 } }}
>
<button
type="button"
className={`hm-help${className ? ` ${className}` : ''}`}
aria-label={label}
style={style}
>
<QuestionCircleOutlined />
</button>
</Tooltip>
);
}