HelpDot.tsx 1.07 KB
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>
  );
}