1
- import { useRef , useState , useCallback } from 'react'
2
- import { createPortal } from 'react-dom'
3
- import { Global } from '@emotion/react'
4
1
import { DocSearchModal , DocSearchProps , useDocSearchKeyboardEvents } from '@docsearch/react'
2
+ import { Global } from '@emotion/react'
3
+ import { useCallback , useRef , useState } from 'react'
4
+ import { createPortal } from 'react-dom'
5
+ import { dispatch } from 'use-bus'
6
+
5
7
import {
6
- Text ,
7
- Flex ,
8
- Icon ,
9
- Spacing ,
10
8
BorderRadius ,
11
- Opacity ,
12
- FontWeight ,
13
- FontSize ,
14
- buildTransition ,
15
9
buildBorder ,
10
+ buildTransition ,
11
+ Flex ,
12
+ FontSize ,
13
+ FontWeight ,
16
14
GlobalTheme ,
15
+ Icon ,
16
+ Opacity ,
17
+ Spacing ,
18
+ Text ,
17
19
} from '@edgeandnode/components'
18
- import { dispatch } from 'use-bus'
19
20
20
21
import { useI18n } from '../i18n'
21
22
import { EventType } from '../types'
@@ -26,7 +27,6 @@ export function DocSearch(props: DocSearchProps) {
26
27
const searchButtonRef = useRef < HTMLButtonElement > ( null )
27
28
const [ isOpen , setIsOpen ] = useState ( false )
28
29
const [ initialQuery , setInitialQuery ] = useState < string | undefined > ( props ?. initialQuery || undefined )
29
- const { t } = useI18n ( )
30
30
31
31
const onOpen = useCallback ( ( ) => {
32
32
setIsOpen ( true )
@@ -55,15 +55,15 @@ export function DocSearch(props: DocSearchProps) {
55
55
} )
56
56
57
57
return (
58
- < div sx = { { px : [ Spacing . L , null , null , 0 ] } } >
58
+ < div sx = { { px : [ Spacing [ '16px' ] , null , null , 0 ] } } >
59
59
{ /* TODO: Replace by `Chip` component when it's ready in the new GDS */ }
60
60
< button type = "button" ref = { searchButtonRef } onClick = { onOpen } sx = { { width : '100%' } } >
61
61
< Flex . Row
62
62
align = "center"
63
- gap = { Spacing . M }
63
+ gap = { Spacing [ '8px' ] }
64
64
sx = { {
65
65
height : '32px' ,
66
- px : Spacing . M ,
66
+ px : Spacing [ '8px' ] ,
67
67
borderRadius : BorderRadius . FULL ,
68
68
border : 'White4' ,
69
69
bg : 'White4' ,
@@ -80,12 +80,12 @@ export function DocSearch(props: DocSearchProps) {
80
80
as = "kbd"
81
81
size = "14px"
82
82
color = "White48"
83
- sx = { { marginInlineStart : 'auto' , px : Spacing . M , fontFamily : 'inherit' } }
83
+ sx = { { marginInlineStart : 'auto' , px : Spacing [ '8px' ] , fontFamily : 'inherit' } }
84
84
>
85
85
< abbr title = "Command" sx = { { textDecoration : 'none' } } >
86
86
⌘
87
87
</ abbr >
88
- < span sx = { { marginInlineStart : Spacing . S } } > K</ span >
88
+ < span sx = { { marginInlineStart : Spacing [ '4px' ] } } > K</ span >
89
89
</ Text . P14 >
90
90
</ Flex . Row >
91
91
</ button >
@@ -128,12 +128,12 @@ export function DocSearch(props: DocSearchProps) {
128
128
} ,
129
129
} ,
130
130
'.DocSearch-SearchBar' : {
131
- padding : `0 ${ Spacing . L_XL } ` ,
131
+ padding : `0 ${ Spacing [ '24px' ] } ` ,
132
132
'&::after' : {
133
133
content : `''` ,
134
134
zIndex : 100 ,
135
135
position : 'absolute' ,
136
- insetInline : Spacing . L_XL ,
136
+ insetInline : Spacing [ '24px' ] ,
137
137
bottom : '-1px' ,
138
138
borderBottom : buildBorder ( 'White16' ) ( theme ) ,
139
139
backgroundColor : 'var(--docsearch-modal-background)' ,
@@ -150,7 +150,7 @@ export function DocSearch(props: DocSearchProps) {
150
150
} ,
151
151
} ,
152
152
'.DocSearch-Input' : {
153
- padding : `${ Spacing . XL } ${ Spacing . L } ` ,
153
+ padding : `${ Spacing [ '32px' ] } ${ Spacing [ '16px' ] } ` ,
154
154
outline : 'none' ,
155
155
fontSize : FontSize [ '18px' ] ,
156
156
} ,
@@ -163,8 +163,8 @@ export function DocSearch(props: DocSearchProps) {
163
163
} ,
164
164
} ,
165
165
'.DocSearch-Cancel' : {
166
- marginInlineStart : Spacing . L ,
167
- marginInlineEnd : Spacing . S ,
166
+ marginInlineStart : Spacing [ '16px' ] ,
167
+ marginInlineEnd : Spacing [ '4px' ] ,
168
168
color : 'inherit' ,
169
169
} ,
170
170
'.DocSearch-Dropdown' : {
@@ -175,16 +175,16 @@ export function DocSearch(props: DocSearchProps) {
175
175
scrollPaddingTop : '32px' ,
176
176
} ,
177
177
'.DocSearch-Dropdown-Container' : {
178
- padding : `${ Spacing . L_XL } ${ Spacing . L } ` ,
179
- paddingBottom : Spacing . XXL ,
178
+ padding : `${ Spacing [ '24px' ] } ${ Spacing [ '16px' ] } ` ,
179
+ paddingBottom : Spacing [ '64px' ] ,
180
180
[ `@media (min-width: ${ BREAKPOINT } )` ] : {
181
- padding : `${ Spacing . L_XL } ${ Spacing . XL } ` ,
181
+ padding : `${ Spacing [ '24px' ] } ${ Spacing [ '32px' ] } ` ,
182
182
} ,
183
183
} ,
184
184
'.DocSearch-Hits' : {
185
185
width : 'auto' ,
186
186
'& + .DocSearch-Hits' : {
187
- marginTop : Spacing . L ,
187
+ marginTop : Spacing [ '16px' ] ,
188
188
} ,
189
189
mark : {
190
190
color : 'inherit' ,
@@ -193,9 +193,9 @@ export function DocSearch(props: DocSearchProps) {
193
193
} ,
194
194
'.DocSearch-Hit-source' : {
195
195
margin : 0 ,
196
- marginBottom : Spacing . XS ,
197
- padding : `0 ${ Spacing . L } ` ,
198
- fontWeight : FontWeight . Medium ,
196
+ marginBottom : Spacing [ '2px' ] ,
197
+ padding : `0 ${ Spacing [ '16px' ] } ` ,
198
+ fontWeight : FontWeight . MEDIUM ,
199
199
fontSize : FontSize [ '12px' ] ,
200
200
textTransform : 'uppercase' ,
201
201
letterSpacing : '0.15em' ,
@@ -204,7 +204,7 @@ export function DocSearch(props: DocSearchProps) {
204
204
'.DocSearch-Hit' : {
205
205
padding : 0 ,
206
206
a : {
207
- padding : `0 ${ Spacing . L } ` ,
207
+ padding : `0 ${ Spacing [ '16px' ] } ` ,
208
208
borderRadius : BorderRadius . S ,
209
209
} ,
210
210
'&[aria-selected=true] a' : {
@@ -213,10 +213,10 @@ export function DocSearch(props: DocSearchProps) {
213
213
} ,
214
214
'.DocSearch-Hit-Container' : {
215
215
height : 'auto' ,
216
- padding : `${ Spacing . M_L } 0` ,
216
+ padding : `${ Spacing [ '12px' ] } 0` ,
217
217
} ,
218
218
'.DocSearch-Hit-Tree' : {
219
- width : Spacing . L ,
219
+ width : Spacing [ '16px' ] ,
220
220
height : 0 ,
221
221
opacity : 0 ,
222
222
} ,
@@ -228,19 +228,19 @@ export function DocSearch(props: DocSearchProps) {
228
228
} ,
229
229
'.DocSearch-Hit-title' : {
230
230
fontSize : FontSize [ '16px' ] ,
231
- fontWeight : FontWeight . Semibold ,
231
+ fontWeight : FontWeight . SEMIBOLD ,
232
232
overflow : 'hidden' ,
233
233
textOverflow : 'ellipsis' ,
234
234
} ,
235
235
'.DocSearch-Hit-path' : {
236
- marginTop : Spacing . S ,
236
+ marginTop : Spacing [ '4px' ] ,
237
237
fontSize : FontSize [ '16px' ] ,
238
- fontWeight : FontWeight . Normal ,
238
+ fontWeight : FontWeight . REGULAR ,
239
239
overflow : 'hidden' ,
240
240
textOverflow : 'ellipsis' ,
241
241
} ,
242
242
'.DocSearch-Hit-action' : {
243
- marginInlineStart : Spacing . L ,
243
+ marginInlineStart : Spacing [ '16px' ] ,
244
244
} ,
245
245
'.DocSearch-HitsFooter' : {
246
246
display : 'none' ,
@@ -249,7 +249,7 @@ export function DocSearch(props: DocSearchProps) {
249
249
position : 'fixed' ,
250
250
bottom : 0 ,
251
251
insetInline : 0 ,
252
- padding : Spacing . L ,
252
+ padding : Spacing [ '16px' ] ,
253
253
backgroundColor : 'transparent' ,
254
254
boxShadow : 'none' ,
255
255
'&::before' : {
@@ -278,16 +278,16 @@ export function DocSearch(props: DocSearchProps) {
278
278
} ,
279
279
'.DocSearch-Screen-Icon' : {
280
280
padding : 0 ,
281
- marginBottom : Spacing . L ,
281
+ marginBottom : Spacing [ '16px' ] ,
282
282
display : 'flex' ,
283
283
justifyContent : 'center' ,
284
284
} ,
285
285
'.DocSearch-NoResults' : {
286
- padding : `${ Spacing . XXL } 0` ,
286
+ padding : `${ Spacing [ '64px' ] } 0` ,
287
287
} ,
288
288
'.DocSearch-NoResults-Prefill-List' : {
289
289
padding : 0 ,
290
- marginTop : Spacing . XL ,
290
+ marginTop : Spacing [ '32px' ] ,
291
291
textAlign : 'center' ,
292
292
} ,
293
293
} ) }
0 commit comments