mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-15 14:31:09 +08:00
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { Tooltip } from 'antd';
|
|
import type { TooltipProps } from 'antd';
|
|
|
|
import SemanticPreview from '../../../.dumi/theme/common/SemanticPreview';
|
|
import useLocale from '../../../.dumi/hooks/useLocale';
|
|
|
|
const locales = {
|
|
cn: {
|
|
root: '根元素 (包含箭头、内容元素)',
|
|
body: '内容元素',
|
|
},
|
|
en: {
|
|
root: 'Root element (including arrows, content elements)',
|
|
body: 'Body element',
|
|
},
|
|
};
|
|
|
|
const BlockList: React.FC<React.PropsWithChildren<TooltipProps>> = (props) => {
|
|
const { children, ...rest } = props;
|
|
const divRef = React.useRef<HTMLDivElement>(null);
|
|
return (
|
|
<div ref={divRef} style={{ position: 'absolute', marginTop: 60 }}>
|
|
<Tooltip
|
|
open
|
|
placement="top"
|
|
title="tooltip prompt text"
|
|
autoAdjustOverflow={false}
|
|
getPopupContainer={() => divRef.current!}
|
|
{...rest}
|
|
>
|
|
{children}
|
|
</Tooltip>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const App: React.FC = () => {
|
|
const [locale] = useLocale(locales);
|
|
return (
|
|
<SemanticPreview
|
|
componentName="Tooltip"
|
|
semantics={[
|
|
{ name: 'root', desc: locale.root, version: '5.23.0' },
|
|
{ name: 'body', desc: locale.body, version: '5.23.0' },
|
|
]}
|
|
>
|
|
<BlockList />
|
|
</SemanticPreview>
|
|
);
|
|
};
|
|
|
|
export default App;
|