1- import { useRef , useState , useCallback } from 'react'
2- import { createPortal } from 'react-dom'
3- import { Global } from '@emotion/react'
41import { 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+
57import {
6- Text ,
7- Flex ,
8- Icon ,
9- Spacing ,
108 BorderRadius ,
11- Opacity ,
12- FontWeight ,
13- FontSize ,
14- buildTransition ,
159 buildBorder ,
10+ buildTransition ,
11+ Flex ,
12+ FontSize ,
13+ FontWeight ,
1614 GlobalTheme ,
15+ Icon ,
16+ Opacity ,
17+ Spacing ,
18+ Text ,
1719} from '@edgeandnode/components'
18- import { dispatch } from 'use-bus'
1920
2021import { useI18n } from '../i18n'
2122import { EventType } from '../types'
@@ -26,7 +27,6 @@ export function DocSearch(props: DocSearchProps) {
2627 const searchButtonRef = useRef < HTMLButtonElement > ( null )
2728 const [ isOpen , setIsOpen ] = useState ( false )
2829 const [ initialQuery , setInitialQuery ] = useState < string | undefined > ( props ?. initialQuery || undefined )
29- const { t } = useI18n ( )
3030
3131 const onOpen = useCallback ( ( ) => {
3232 setIsOpen ( true )
@@ -55,15 +55,15 @@ export function DocSearch(props: DocSearchProps) {
5555 } )
5656
5757 return (
58- < div sx = { { px : [ Spacing . L , null , null , 0 ] } } >
58+ < div sx = { { px : [ Spacing [ '16px' ] , null , null , 0 ] } } >
5959 { /* TODO: Replace by `Chip` component when it's ready in the new GDS */ }
6060 < button type = "button" ref = { searchButtonRef } onClick = { onOpen } sx = { { width : '100%' } } >
6161 < Flex . Row
6262 align = "center"
63- gap = { Spacing . M }
63+ gap = { Spacing [ '8px' ] }
6464 sx = { {
6565 height : '32px' ,
66- px : Spacing . M ,
66+ px : Spacing [ '8px' ] ,
6767 borderRadius : BorderRadius . FULL ,
6868 border : 'White4' ,
6969 bg : 'White4' ,
@@ -80,12 +80,12 @@ export function DocSearch(props: DocSearchProps) {
8080 as = "kbd"
8181 size = "14px"
8282 color = "White48"
83- sx = { { marginInlineStart : 'auto' , px : Spacing . M , fontFamily : 'inherit' } }
83+ sx = { { marginInlineStart : 'auto' , px : Spacing [ '8px' ] , fontFamily : 'inherit' } }
8484 >
8585 < abbr title = "Command" sx = { { textDecoration : 'none' } } >
8686 ⌘
8787 </ abbr >
88- < span sx = { { marginInlineStart : Spacing . S } } > K</ span >
88+ < span sx = { { marginInlineStart : Spacing [ '4px' ] } } > K</ span >
8989 </ Text . P14 >
9090 </ Flex . Row >
9191 </ button >
@@ -128,12 +128,12 @@ export function DocSearch(props: DocSearchProps) {
128128 } ,
129129 } ,
130130 '.DocSearch-SearchBar' : {
131- padding : `0 ${ Spacing . L_XL } ` ,
131+ padding : `0 ${ Spacing [ '24px' ] } ` ,
132132 '&::after' : {
133133 content : `''` ,
134134 zIndex : 100 ,
135135 position : 'absolute' ,
136- insetInline : Spacing . L_XL ,
136+ insetInline : Spacing [ '24px' ] ,
137137 bottom : '-1px' ,
138138 borderBottom : buildBorder ( 'White16' ) ( theme ) ,
139139 backgroundColor : 'var(--docsearch-modal-background)' ,
@@ -150,7 +150,7 @@ export function DocSearch(props: DocSearchProps) {
150150 } ,
151151 } ,
152152 '.DocSearch-Input' : {
153- padding : `${ Spacing . XL } ${ Spacing . L } ` ,
153+ padding : `${ Spacing [ '32px' ] } ${ Spacing [ '16px' ] } ` ,
154154 outline : 'none' ,
155155 fontSize : FontSize [ '18px' ] ,
156156 } ,
@@ -163,8 +163,8 @@ export function DocSearch(props: DocSearchProps) {
163163 } ,
164164 } ,
165165 '.DocSearch-Cancel' : {
166- marginInlineStart : Spacing . L ,
167- marginInlineEnd : Spacing . S ,
166+ marginInlineStart : Spacing [ '16px' ] ,
167+ marginInlineEnd : Spacing [ '4px' ] ,
168168 color : 'inherit' ,
169169 } ,
170170 '.DocSearch-Dropdown' : {
@@ -175,16 +175,16 @@ export function DocSearch(props: DocSearchProps) {
175175 scrollPaddingTop : '32px' ,
176176 } ,
177177 '.DocSearch-Dropdown-Container' : {
178- padding : `${ Spacing . L_XL } ${ Spacing . L } ` ,
179- paddingBottom : Spacing . XXL ,
178+ padding : `${ Spacing [ '24px' ] } ${ Spacing [ '16px' ] } ` ,
179+ paddingBottom : Spacing [ '64px' ] ,
180180 [ `@media (min-width: ${ BREAKPOINT } )` ] : {
181- padding : `${ Spacing . L_XL } ${ Spacing . XL } ` ,
181+ padding : `${ Spacing [ '24px' ] } ${ Spacing [ '32px' ] } ` ,
182182 } ,
183183 } ,
184184 '.DocSearch-Hits' : {
185185 width : 'auto' ,
186186 '& + .DocSearch-Hits' : {
187- marginTop : Spacing . L ,
187+ marginTop : Spacing [ '16px' ] ,
188188 } ,
189189 mark : {
190190 color : 'inherit' ,
@@ -193,9 +193,9 @@ export function DocSearch(props: DocSearchProps) {
193193 } ,
194194 '.DocSearch-Hit-source' : {
195195 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 ,
199199 fontSize : FontSize [ '12px' ] ,
200200 textTransform : 'uppercase' ,
201201 letterSpacing : '0.15em' ,
@@ -204,7 +204,7 @@ export function DocSearch(props: DocSearchProps) {
204204 '.DocSearch-Hit' : {
205205 padding : 0 ,
206206 a : {
207- padding : `0 ${ Spacing . L } ` ,
207+ padding : `0 ${ Spacing [ '16px' ] } ` ,
208208 borderRadius : BorderRadius . S ,
209209 } ,
210210 '&[aria-selected=true] a' : {
@@ -213,10 +213,10 @@ export function DocSearch(props: DocSearchProps) {
213213 } ,
214214 '.DocSearch-Hit-Container' : {
215215 height : 'auto' ,
216- padding : `${ Spacing . M_L } 0` ,
216+ padding : `${ Spacing [ '12px' ] } 0` ,
217217 } ,
218218 '.DocSearch-Hit-Tree' : {
219- width : Spacing . L ,
219+ width : Spacing [ '16px' ] ,
220220 height : 0 ,
221221 opacity : 0 ,
222222 } ,
@@ -228,19 +228,19 @@ export function DocSearch(props: DocSearchProps) {
228228 } ,
229229 '.DocSearch-Hit-title' : {
230230 fontSize : FontSize [ '16px' ] ,
231- fontWeight : FontWeight . Semibold ,
231+ fontWeight : FontWeight . SEMIBOLD ,
232232 overflow : 'hidden' ,
233233 textOverflow : 'ellipsis' ,
234234 } ,
235235 '.DocSearch-Hit-path' : {
236- marginTop : Spacing . S ,
236+ marginTop : Spacing [ '4px' ] ,
237237 fontSize : FontSize [ '16px' ] ,
238- fontWeight : FontWeight . Normal ,
238+ fontWeight : FontWeight . REGULAR ,
239239 overflow : 'hidden' ,
240240 textOverflow : 'ellipsis' ,
241241 } ,
242242 '.DocSearch-Hit-action' : {
243- marginInlineStart : Spacing . L ,
243+ marginInlineStart : Spacing [ '16px' ] ,
244244 } ,
245245 '.DocSearch-HitsFooter' : {
246246 display : 'none' ,
@@ -249,7 +249,7 @@ export function DocSearch(props: DocSearchProps) {
249249 position : 'fixed' ,
250250 bottom : 0 ,
251251 insetInline : 0 ,
252- padding : Spacing . L ,
252+ padding : Spacing [ '16px' ] ,
253253 backgroundColor : 'transparent' ,
254254 boxShadow : 'none' ,
255255 '&::before' : {
@@ -278,16 +278,16 @@ export function DocSearch(props: DocSearchProps) {
278278 } ,
279279 '.DocSearch-Screen-Icon' : {
280280 padding : 0 ,
281- marginBottom : Spacing . L ,
281+ marginBottom : Spacing [ '16px' ] ,
282282 display : 'flex' ,
283283 justifyContent : 'center' ,
284284 } ,
285285 '.DocSearch-NoResults' : {
286- padding : `${ Spacing . XXL } 0` ,
286+ padding : `${ Spacing [ '64px' ] } 0` ,
287287 } ,
288288 '.DocSearch-NoResults-Prefill-List' : {
289289 padding : 0 ,
290- marginTop : Spacing . XL ,
290+ marginTop : Spacing [ '32px' ] ,
291291 textAlign : 'center' ,
292292 } ,
293293 } ) }
0 commit comments