|
1 | 1 | import React from 'react'; |
2 | 2 | import { |
3 | 3 | Text, |
4 | | - Pressable, |
5 | | - Popover, |
6 | 4 | Button, |
| 5 | + Popover, |
7 | 6 | CloseIcon, |
8 | 7 | Icon, |
9 | 8 | Box, |
| 9 | + Center, |
10 | 10 | } from '../../../ui-components'; |
11 | 11 |
|
12 | 12 | import Wrapper from '../../Wrapper'; |
13 | 13 |
|
14 | | -export const PopoverStory = () => { |
| 14 | +export const PopoverStory = ({ placement }: any) => { |
| 15 | + const [isOpen, setIsOpen] = React.useState(false); |
| 16 | + |
| 17 | + const handleOpen = () => { |
| 18 | + setIsOpen(true); |
| 19 | + }; |
| 20 | + |
| 21 | + const handleClose = () => { |
| 22 | + setIsOpen(false); |
| 23 | + }; |
| 24 | + |
15 | 25 | return ( |
16 | 26 | <Wrapper> |
17 | | - <Popover |
18 | | - placement={'bottom'} |
19 | | - trigger={(triggerProps: any) => { |
20 | | - return ( |
21 | | - <Pressable |
22 | | - bgColor={'$red500'} |
23 | | - borderRadius={'$md'} |
24 | | - {...triggerProps} |
25 | | - > |
26 | | - <Text color={'white'} padding="$3"> |
27 | | - Popover |
| 27 | + <Center w={1200} h={800}> |
| 28 | + <Popover |
| 29 | + isOpen={isOpen} |
| 30 | + onClose={handleClose} |
| 31 | + onOpen={handleOpen} |
| 32 | + offset={30} |
| 33 | + placement={placement} |
| 34 | + trigger={(triggerProps: any) => { |
| 35 | + return ( |
| 36 | + <Button {...triggerProps}> |
| 37 | + <Button.Text>Popover</Button.Text> |
| 38 | + </Button> |
| 39 | + ); |
| 40 | + }} |
| 41 | + > |
| 42 | + <Popover.Backdrop /> |
| 43 | + <Popover.Content> |
| 44 | + <Popover.Header> |
| 45 | + <Text>Delete Customer</Text> |
| 46 | + <Popover.CloseButton> |
| 47 | + <Icon as={CloseIcon} sx={{ w: 16, h: 16 }} /> |
| 48 | + </Popover.CloseButton> |
| 49 | + </Popover.Header> |
| 50 | + |
| 51 | + <Popover.Body> |
| 52 | + <Text> |
| 53 | + This will remove all data relating to Alex. This action cannot |
| 54 | + be reversed. Deleted data can not be recovered. |
28 | 55 | </Text> |
29 | | - </Pressable> |
30 | | - ); |
31 | | - }} |
32 | | - > |
33 | | - <Popover.Content> |
34 | | - <Popover.Header> |
35 | | - <Text>Delete Customer</Text> |
36 | | - <Popover.CloseButton> |
37 | | - <Icon as={CloseIcon} sx={{ w: 16, h: 16 }} /> |
38 | | - </Popover.CloseButton> |
39 | | - </Popover.Header> |
40 | | - <Popover.Body> |
41 | | - <Text> |
42 | | - This will remove all data relating to Alex. This action cannot be |
43 | | - reversed. Deleted data can not be recovered. |
44 | | - </Text> |
45 | | - </Popover.Body> |
46 | | - <Popover.Footer> |
47 | | - {/* @ts-ignore */} |
48 | | - <Button variant="outline" mr={'$2'}> |
49 | | - <Button.Text>Cancel</Button.Text> |
50 | | - </Button> |
51 | | - <Button> |
52 | | - <Button.Text color={'white'}>Delete</Button.Text> |
53 | | - </Button> |
54 | | - </Popover.Footer> |
55 | | - </Popover.Content> |
56 | | - </Popover> |
| 56 | + </Popover.Body> |
| 57 | + |
| 58 | + <Popover.Footer> |
| 59 | + {/* @ts-ignore */} |
| 60 | + <Button variant="outline" mr={'$2'} onPress={handleClose}> |
| 61 | + <Button.Text>Cancel</Button.Text> |
| 62 | + </Button> |
| 63 | + <Button> |
| 64 | + <Button.Text color={'white'} onPress={handleClose}> |
| 65 | + Delete |
| 66 | + </Button.Text> |
| 67 | + </Button> |
| 68 | + </Popover.Footer> |
| 69 | + </Popover.Content> |
| 70 | + </Popover> |
| 71 | + </Center> |
57 | 72 | </Wrapper> |
58 | 73 | ); |
59 | 74 | }; |
60 | 75 |
|
61 | | -export { Text, Pressable, Popover, Button, CloseIcon, Box }; |
| 76 | +export { Text, Popover, Button, CloseIcon, Box }; |
0 commit comments