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