1
- import styled from '@emotion/styled '
1
+ import { Box , Grid } from 'theme-ui '
2
2
import { useCoreHandler } from '@/handlers'
3
3
import { useCanvasContext } from '@/hooks'
4
4
import ContextMenuIcons from './ContextMenuIcons'
5
5
6
- const ContextMenuContainer = styled . div < any > (
7
- {
8
- position : 'absolute' ,
9
- width : '200px' ,
10
- zIndex : 9 ,
11
- backgroundColor : '#fff' ,
12
- border : '1px solid rgba(64, 87, 109, 0.07)' ,
13
- boxShadow : '0 2px 8px rgba(53, 71, 90, 0.2)' ,
14
- borderRadius : '4px' ,
15
- } ,
16
- props => {
17
- return {
18
- display : props . visible ? 'block' : 'none' ,
19
- top : props . top ? props . top : 0 ,
20
- left : props . left ? props . left : 0 ,
21
- }
22
- }
23
- )
24
-
25
6
function ContextMenu ( ) {
26
7
const { contextMenu, setContextMenu } = useCanvasContext ( )
27
8
const { deleteObject, cloneOject } = useCoreHandler ( )
28
9
return (
29
- < ContextMenuContainer
30
- top = { contextMenu . top }
31
- left = { contextMenu . left }
32
- visible = { contextMenu . visible }
10
+ < Box
11
+ sx = { {
12
+ position : 'absolute' ,
13
+ width : '220px' ,
14
+ zIndex : 9 ,
15
+ backgroundColor : '#fff' ,
16
+ border : '1px solid rgba(64, 87, 109, 0.07)' ,
17
+ boxShadow : '0 2px 8px rgba(53, 71, 90, 0.2)' ,
18
+ borderRadius : '4px' ,
19
+ display : contextMenu . visible ? 'block' : 'none' ,
20
+ top : contextMenu . top ? contextMenu . top : 0 ,
21
+ left : contextMenu . left ? contextMenu . left : 0 ,
22
+ } }
23
+ // @ts -ignore
33
24
onContextMenu = { ( e : Event ) => e . preventDefault ( ) }
34
25
>
35
26
< ContextMenuItem
@@ -50,7 +41,7 @@ function ContextMenu() {
50
41
setContextMenu ( { ...contextMenu , visible : false } )
51
42
} }
52
43
/>
53
- </ ContextMenuContainer >
44
+ </ Box >
54
45
)
55
46
}
56
47
@@ -62,24 +53,24 @@ interface ContextMenuItemProps {
62
53
}
63
54
function ContextMenuItem ( props : ContextMenuItemProps ) {
64
55
return (
65
- < ContextMenuItemContainer { ...props } >
56
+ < Grid
57
+ sx = { {
58
+ cursor : 'pointer' ,
59
+ height : '40px' ,
60
+ display : 'grid' ,
61
+ gridTemplateColumns : '40px 1fr 70px' ,
62
+ alignItems : 'center' ,
63
+ padding : '0 0.8rem' ,
64
+ ':hover' : {
65
+ background : 'rgba(0,0,0,0.06)' ,
66
+ } ,
67
+ } }
68
+ >
66
69
< div > { ContextMenuIcons [ props . icon as 'delete' ] } </ div >
67
70
< div style = { { fontSize : '0.94rem' } } > { props . text } </ div >
68
71
< div style = { { color : 'rgba(0,0,0,0.5)' } } > { props . shortcut } </ div >
69
- </ ContextMenuItemContainer >
72
+ </ Grid >
70
73
)
71
74
}
72
75
73
- const ContextMenuItemContainer = styled . div ( {
74
- cursor : 'pointer' ,
75
- height : '40px' ,
76
- display : 'grid' ,
77
- gridTemplateColumns : '40px 1fr 60px' ,
78
- alignItems : 'center' ,
79
- padding : '0 0.8rem' ,
80
- ':hover' : {
81
- background : 'rgba(0,0,0,0.06)' ,
82
- } ,
83
- } )
84
-
85
76
export default ContextMenu
0 commit comments