2023-02-15 10:21:28 +08:00
|
|
|
import React, { useMemo, useState } from 'react';
|
2023-10-30 13:57:57 +08:00
|
|
|
import { Button, Segmented, Tooltip, ConfigProvider } from 'antd';
|
2023-01-19 11:21:05 +08:00
|
|
|
|
|
|
|
const text = <span>prompt text</span>;
|
|
|
|
|
2023-10-30 13:57:57 +08:00
|
|
|
const buttonWidth = 80;
|
2023-01-19 11:21:05 +08:00
|
|
|
|
|
|
|
const App: React.FC = () => {
|
2023-02-15 10:21:28 +08:00
|
|
|
const [arrow, setArrow] = useState('Show');
|
2023-01-19 11:21:05 +08:00
|
|
|
|
|
|
|
const mergedArrow = useMemo(() => {
|
2023-02-15 10:21:28 +08:00
|
|
|
if (arrow === 'Hide') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arrow === 'Show') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2023-03-05 17:51:19 +08:00
|
|
|
pointAtCenter: true,
|
2023-02-15 10:21:28 +08:00
|
|
|
};
|
|
|
|
}, [arrow]);
|
2023-01-19 11:21:05 +08:00
|
|
|
|
|
|
|
return (
|
2023-10-30 13:57:57 +08:00
|
|
|
<ConfigProvider
|
|
|
|
button={{
|
|
|
|
style: { width: buttonWidth },
|
|
|
|
}}
|
|
|
|
>
|
2023-01-19 11:21:05 +08:00
|
|
|
<Segmented
|
2023-02-15 10:21:28 +08:00
|
|
|
value={arrow}
|
2023-10-30 15:02:00 +08:00
|
|
|
options={['Show', 'Hide', 'Center']}
|
2023-02-15 10:21:28 +08:00
|
|
|
onChange={(val: string) => {
|
|
|
|
setArrow(val);
|
2023-01-19 11:21:05 +08:00
|
|
|
}}
|
2023-10-30 13:57:57 +08:00
|
|
|
style={{ marginBottom: 24 }}
|
2023-01-19 11:21:05 +08:00
|
|
|
/>
|
2023-10-30 13:57:57 +08:00
|
|
|
<div className="demo">
|
|
|
|
<div style={{ marginInlineStart: buttonWidth, whiteSpace: 'nowrap' }}>
|
|
|
|
<Tooltip placement="topLeft" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>TL</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="top" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>Top</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="topRight" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>TR</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<div style={{ width: buttonWidth, float: 'inline-start' }}>
|
|
|
|
<Tooltip placement="leftTop" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>LT</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="left" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>Left</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="leftBottom" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>LB</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<div style={{ width: buttonWidth, marginInlineStart: buttonWidth * 4 + 24 }}>
|
|
|
|
<Tooltip placement="rightTop" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>RT</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="right" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>Right</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="rightBottom" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>RB</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<div style={{ marginInlineStart: buttonWidth, clear: 'both', whiteSpace: 'nowrap' }}>
|
|
|
|
<Tooltip placement="bottomLeft" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>BL</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="bottom" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>Bottom</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="bottomRight" title={text} arrow={mergedArrow}>
|
|
|
|
<Button>BR</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2023-01-19 11:21:05 +08:00
|
|
|
</div>
|
2023-10-30 13:57:57 +08:00
|
|
|
</ConfigProvider>
|
2023-01-19 11:21:05 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|