1
1
import { DocSearchModal , DocSearchProps , useDocSearchKeyboardEvents } from '@docsearch/react'
2
+ import { keyframes } from '@emotion/react'
2
3
import { useCallback , useRef , useState } from 'react'
3
4
import { createPortal } from 'react-dom'
4
5
import { Global } from 'theme-ui'
@@ -12,6 +13,7 @@ import {
12
13
FontSize ,
13
14
FontWeight ,
14
15
Icon ,
16
+ LineHeight ,
15
17
Link ,
16
18
Opacity ,
17
19
Responsive ,
@@ -20,6 +22,11 @@ import {
20
22
useTheme ,
21
23
} from '@edgeandnode/gds'
22
24
25
+ const animationFadeIn = keyframes ( {
26
+ from : { opacity : 0 } ,
27
+ to : { opacity : 1 } ,
28
+ } )
29
+
23
30
export function DocSearch ( props : DocSearchProps ) {
24
31
const searchButtonRef = useRef < HTMLButtonElement > ( null )
25
32
const [ isOpen , setIsOpen ] = useState ( false )
@@ -153,30 +160,33 @@ export function DocSearch(props: DocSearchProps) {
153
160
'--docsearch-spacing' : '0 !important' ,
154
161
'--docsearch-container-background' : `${ theme . colors ! . Midnight88 } !important` ,
155
162
'--docsearch-modal-width' : 'min(calc(100vw - 32px), 840px) !important' ,
156
- '--docsearch-modal-background' : '#292738 !important' ,
163
+ '--docsearch-modal-background' : ` ${ theme . colors ! . Tooltip } !important` ,
157
164
'--docsearch-modal-shadow' : 'none !important' ,
158
- '--docsearch-searchbox-height' : ' 96px !important',
165
+ '--docsearch-searchbox-height' : [ '64px !important' , null , ' 96px !important'] ,
159
166
'--docsearch-searchbox-focus-background' : 'transparent !important' ,
160
167
'--docsearch-searchbox-shadow' : 'none !important' ,
161
168
'--docsearch-hit-background' : 'transparent !important' ,
162
169
'--docsearch-hit-color' : `${ theme . colors ! . White88 } !important` ,
163
170
'--docsearch-hit-active-color' : `${ theme . colors ! . White } !important` ,
164
171
'--docsearch-highlight-color' : `${ theme . colors ! . Purple } !important` ,
165
172
} ,
173
+ '.DocSearch-Container' : {
174
+ animation : `${ animationFadeIn } 150ms ease-in-out` ,
175
+ } ,
166
176
'.DocSearch-Modal' : {
167
177
m : [ null , null , '96px auto auto' ] ,
168
- border : buildBorder ( 'White8' ) ,
178
+ border : [ null , null , 'White8' ] ,
169
179
overflow : 'hidden' ,
170
180
cursor : 'default' ,
171
181
} ,
172
182
'.DocSearch-SearchBar' : {
173
- p : `0 ${ Spacing [ '24px' ] } ` ,
183
+ p : [ `0 ${ Spacing [ '16px' ] } ` , null , `0 ${ Spacing [ ' 24px'] } `] ,
174
184
'&::after' : {
175
185
content : `''` ,
176
186
zIndex : 100 ,
177
187
position : 'absolute' ,
178
- left : Spacing [ '24px' ] ,
179
- right : Spacing [ '24px' ] ,
188
+ left : [ Spacing [ '16px' ] , null , Spacing [ ' 24px'] ] ,
189
+ right : [ Spacing [ '16px' ] , null , Spacing [ ' 24px'] ] ,
180
190
bottom : '-1px' ,
181
191
borderBottom : buildBorder ( 'White16' ) ,
182
192
bg : 'var(--docsearch-modal-background)' ,
@@ -188,10 +198,15 @@ export function DocSearch(props: DocSearchProps) {
188
198
'.DocSearch-MagnifierLabel, .DocSearch-LoadingIndicator' : {
189
199
color : 'white' ,
190
200
svg : {
191
- width : '18px ' ,
192
- height : '18px ' ,
201
+ width : '20px ' ,
202
+ height : '20px ' ,
193
203
} ,
194
204
} ,
205
+ '.DocSearch-Search-Icon' : {
206
+ left : '3px' ,
207
+ color : 'transparent' ,
208
+ backgroundImage : `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" style="fill: white;"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.70768 1C9.85995 1 12.4154 3.55542 12.4154 6.70768C12.4154 8.08963 11.9242 9.35686 11.107 10.3444C11.3349 10.5734 11.6474 10.8859 12.0424 11.2809L12.4833 11.7218C13.1109 12.3494 13.8972 13.1357 14.8423 14.0808C15.0526 14.2911 15.0526 14.632 14.8423 14.8423C14.632 15.0526 14.2911 15.0526 14.0808 14.8423L10.3444 11.107C9.35686 11.9242 8.08963 12.4154 6.70768 12.4154C3.55542 12.4154 1 9.85995 1 6.70768C1 3.55542 3.55542 1 6.70768 1ZM6.70768 2.07692C4.15018 2.07692 2.07692 4.15018 2.07692 6.70768C2.07692 9.26518 4.15018 11.3384 6.70768 11.3384C9.26518 11.3384 11.3384 9.26518 11.3384 6.70768C11.3384 4.15018 9.26518 2.07692 6.70768 2.07692Z" /></svg>')` ,
209
+ } ,
195
210
'.DocSearch-Input' : {
196
211
p : `${ Spacing [ '32px' ] } ${ Spacing [ '16px' ] } ` ,
197
212
outline : 'none' ,
@@ -232,9 +247,10 @@ export function DocSearch(props: DocSearchProps) {
232
247
'.DocSearch-Hit-source' : {
233
248
m : 0 ,
234
249
mb : Spacing [ '2px' ] ,
235
- p : `0 ${ Spacing [ '16px' ] } ` ,
250
+ p : `${ Spacing [ '8px' ] } ${ Spacing [ '16px' ] } ` ,
236
251
fontWeight : FontWeight . MEDIUM ,
237
252
fontSize : FontSize [ '12px' ] ,
253
+ lineHeight : LineHeight . TIGHT ,
238
254
textTransform : 'uppercase' ,
239
255
letterSpacing : '0.15em' ,
240
256
color : 'White32' ,
@@ -327,8 +343,19 @@ export function DocSearch(props: DocSearchProps) {
327
343
} ,
328
344
'.DocSearch-NoResults-Prefill-List' : {
329
345
p : 0 ,
330
- mt : Spacing [ '32px ' ] ,
346
+ mt : Spacing [ '48px ' ] ,
331
347
textAlign : 'center' ,
348
+ ul : {
349
+ display : 'flex' ,
350
+ flexDirection : 'column' ,
351
+ gap : Spacing [ '8px' ] ,
352
+ li : {
353
+ listStyle : 'none' ,
354
+ } ,
355
+ } ,
356
+ } ,
357
+ '.DocSearch-Prefill' : {
358
+ fontWeight : FontWeight . REGULAR ,
332
359
} ,
333
360
} }
334
361
/>
0 commit comments