File size: 1,707 Bytes
1e92f2d |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
import React from 'react';
import { createStyles } from 'antd-style';
import { Flex, Popover } from 'antd';
import type { GetProp } from 'antd';
const useStyle = createStyles(() => ({
item: {
width: '280px',
height: '280px',
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
border: '1px dashed purple',
},
box: {
width: '40px',
height: '40px',
backgroundColor: 'deepskyblue',
},
cross: {
position: 'relative',
'&::before, &::after': {
content: '""',
position: 'absolute',
inset: 0,
},
'&::before': {
top: '50%',
height: '1px',
backgroundColor: 'red',
},
'&::after': {
left: '50%',
width: '1px',
backgroundColor: 'blue',
},
},
}));
type Placement = GetProp<typeof Popover, 'placement'>;
const placements: Placement[] = [
'topLeft',
'top',
'topRight',
'leftTop',
'left',
'leftBottom',
'rightTop',
'right',
'rightBottom',
'bottomLeft',
'bottom',
'bottomRight',
];
const App = () => {
const { styles, cx } = useStyle();
return (
<Flex gap={16} wrap>
{placements.map((placement) => (
<div key={placement} className={styles.item}>
<Popover
placement={placement}
content={
<Flex align="center" justify="center">
{placement}
</Flex>
}
autoAdjustOverflow={false}
arrow={{ pointAtCenter: true }}
forceRender
open
>
<div className={cx(styles.box, styles.cross)} />
</Popover>
</div>
))}
</Flex>
);
};
export default App;
|