6
6
InputRightElement ,
7
7
DarkMode ,
8
8
IconButton ,
9
+ Flex ,
9
10
} from '@chakra-ui/react'
10
11
import { CloseIcon , SearchIcon } from '@chakra-ui/icons'
11
12
import DragItem from './DragItem'
@@ -22,90 +23,93 @@ const Menu = () => {
22
23
overflowX = "visible"
23
24
boxShadow = "xl"
24
25
flex = "0 0 14rem"
25
- p = { 5 }
26
26
m = { 0 }
27
+ p = { 0 }
27
28
as = "menu"
28
29
backgroundColor = "#2e3748"
29
30
width = "15rem"
30
31
>
31
- < InputGroup size = "sm" mb = { 4 } >
32
- < Input
33
- value = { searchTerm }
34
- color = "gray.300"
35
- placeholder = "Search component…"
36
- onChange = { ( event : ChangeEvent < HTMLInputElement > ) =>
37
- setSearchTerm ( event . target . value )
38
- }
39
- borderColor = "rgba(255, 255, 255, 0.04)"
40
- bg = "rgba(255, 255, 255, 0.06)"
41
- _hover = { {
42
- borderColor : 'rgba(255, 255, 255, 0.08)' ,
43
- } }
44
- zIndex = { 0 }
45
- />
46
- < InputRightElement zIndex = { 1 } >
47
- { searchTerm ? (
48
- < IconButton
49
- color = "gray.300"
50
- aria-label = "clear"
51
- icon = { < CloseIcon path = "" /> }
52
- size = "xs"
53
- onClick = { ( ) => setSearchTerm ( '' ) }
54
- />
55
- ) : (
56
- < SearchIcon path = "" color = "gray.300" />
57
- ) }
58
- </ InputRightElement >
59
- </ InputGroup >
32
+ < Box p = { 5 } pb = { 1 } position = "sticky" w = "100%" bgColor = "#2e3748" top = { 0 } >
33
+ < InputGroup size = "sm" mb = { 4 } >
34
+ < Input
35
+ value = { searchTerm }
36
+ color = "gray.300"
37
+ placeholder = "Search component…"
38
+ onChange = { ( event : ChangeEvent < HTMLInputElement > ) =>
39
+ setSearchTerm ( event . target . value )
40
+ }
41
+ borderColor = "rgba(255, 255, 255, 0.04)"
42
+ bg = "rgba(255, 255, 255, 0.06)"
43
+ _hover = { {
44
+ borderColor : 'rgba(255, 255, 255, 0.08)' ,
45
+ } }
46
+ zIndex = { 0 }
47
+ />
48
+ < InputRightElement zIndex = { 1 } >
49
+ { searchTerm ? (
50
+ < IconButton
51
+ color = "gray.300"
52
+ aria-label = "clear"
53
+ icon = { < CloseIcon path = "" /> }
54
+ size = "xs"
55
+ onClick = { ( ) => setSearchTerm ( '' ) }
56
+ />
57
+ ) : (
58
+ < SearchIcon path = "" color = "gray.300" />
59
+ ) }
60
+ </ InputRightElement >
61
+ </ InputGroup >
62
+ </ Box >
63
+ < Box p = { 5 } pt = { 0 } >
64
+ { ( Object . keys ( menuItems ) as ComponentType [ ] )
65
+ . filter ( c => c . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
66
+ . map ( name => {
67
+ const { children, soon } = menuItems [ name ] as MenuItem
60
68
61
- { ( Object . keys ( menuItems ) as ComponentType [ ] )
62
- . filter ( c => c . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) ) )
63
- . map ( name => {
64
- const { children, soon } = menuItems [ name ] as MenuItem
69
+ if ( children ) {
70
+ const elements = Object . keys ( children ) . map ( childName => (
71
+ < DragItem
72
+ isChild
73
+ key = { childName }
74
+ label = { childName }
75
+ type = { childName as any }
76
+ id = { childName as any }
77
+ rootParentType = { menuItems [ name ] ?. rootParentType || name }
78
+ >
79
+ { childName }
80
+ </ DragItem >
81
+ ) )
65
82
66
- if ( children ) {
67
- const elements = Object . keys ( children ) . map ( childName => (
68
- < DragItem
69
- isChild
70
- key = { childName }
71
- label = { childName }
72
- type = { childName as any }
73
- id = { childName as any }
74
- rootParentType = { menuItems [ name ] ?. rootParentType || name }
75
- >
76
- { childName }
77
- </ DragItem >
78
- ) )
83
+ return [
84
+ < DragItem
85
+ isMeta
86
+ soon = { soon }
87
+ key = { `${ name } Meta` }
88
+ label = { name }
89
+ type = { `${ name } Meta` as any }
90
+ id = { `${ name } Meta` as any }
91
+ rootParentType = { menuItems [ name ] ?. rootParentType || name }
92
+ >
93
+ { name }
94
+ </ DragItem > ,
95
+ ...elements ,
96
+ ]
97
+ }
79
98
80
- return [
99
+ return (
81
100
< DragItem
82
- isMeta
83
101
soon = { soon }
84
- key = { ` ${ name } Meta` }
102
+ key = { name }
85
103
label = { name }
86
- type = { ` ${ name } Meta` as any }
87
- id = { ` ${ name } Meta` as any }
104
+ type = { name as any }
105
+ id = { name as any }
88
106
rootParentType = { menuItems [ name ] ?. rootParentType || name }
89
107
>
90
108
{ name }
91
- </ DragItem > ,
92
- ...elements ,
93
- ]
94
- }
95
-
96
- return (
97
- < DragItem
98
- soon = { soon }
99
- key = { name }
100
- label = { name }
101
- type = { name as any }
102
- id = { name as any }
103
- rootParentType = { menuItems [ name ] ?. rootParentType || name }
104
- >
105
- { name }
106
- </ DragItem >
107
- )
108
- } ) }
109
+ </ DragItem >
110
+ )
111
+ } ) }
112
+ </ Box >
109
113
</ Box >
110
114
</ DarkMode >
111
115
)
0 commit comments