1
1
import React , { ReactNode , FormEvent , MouseEvent , ChangeEvent } from 'react' ;
2
2
import type { DebouncedFunc } from 'lodash' ;
3
+ import { css } from '@emotion/react' ;
3
4
import { Select } from '@redux-devtools/ui' ;
4
5
import { QueryFormValues } from '../types' ;
5
- import { StyleUtilsContext } from '../styles/createStylingFromTheme ' ;
6
+ import { StyleUtilsContext } from '../styles/themes ' ;
6
7
import { SelectOption } from '../types' ;
7
8
import debounce from 'lodash.debounce' ;
8
9
import { sortQueryOptions , QueryComparators } from '../utils/comparators' ;
9
10
import { QueryFilters , filterQueryOptions } from '../utils/filters' ;
10
11
import { SortOrderButton } from './SortOrderButton' ;
11
12
import { RegexIcon } from './RegexIcon' ;
12
13
14
+ const srOnlyCss = css ( {
15
+ position : 'absolute' ,
16
+ width : 1 ,
17
+ height : 1 ,
18
+ padding : 0 ,
19
+ margin : '-1px' ,
20
+ overflow : 'hidden' ,
21
+ clip : 'rect(0,0,0,0)' ,
22
+ border : 0 ,
23
+ } ) ;
24
+
13
25
export interface QueryFormProps {
14
26
values : QueryFormValues ;
15
27
searchQueryRegex : RegExp | null ;
@@ -125,19 +137,68 @@ export class QueryForm extends React.PureComponent<
125
137
126
138
return (
127
139
< StyleUtilsContext . Consumer >
128
- { ( { styling , base16Theme } ) => {
140
+ { ( { base16Theme } ) => {
129
141
return (
130
142
< form
131
143
id = "rtk-query-monitor-query-selection-form"
132
144
action = "#"
133
145
onSubmit = { this . handleSubmit }
134
- { ...styling ( 'queryForm' ) }
146
+ css = { {
147
+ display : 'flex' ,
148
+ flexFlow : 'column nowrap' ,
149
+ } }
135
150
>
136
- < div { ...styling ( 'queryListHeader' ) } >
137
- < label htmlFor = { searchId } { ...styling ( 'srOnly' ) } >
151
+ < div
152
+ css = { ( theme ) => ( {
153
+ display : 'flex' ,
154
+ padding : 4 ,
155
+ flex : '0 0 auto' ,
156
+ alignItems : 'center' ,
157
+ borderBottomWidth : '1px' ,
158
+ borderBottomStyle : 'solid' ,
159
+
160
+ borderColor : theme . LIST_BORDER_COLOR ,
161
+ } ) }
162
+ >
163
+ < label htmlFor = { searchId } css = { srOnlyCss } >
138
164
filter query
139
165
</ label >
140
- < div { ...styling ( 'querySearch' ) } >
166
+ < div
167
+ css = { ( theme ) => ( {
168
+ maxWidth : '65%' ,
169
+ backgroundColor : theme . BACKGROUND_COLOR ,
170
+ display : 'flex' ,
171
+ alignItems : 'center' ,
172
+ flexFlow : 'row nowrap' ,
173
+ flex : '1 1 auto' ,
174
+ paddingRight : 6 ,
175
+ '& input' : {
176
+ outline : 'none' ,
177
+ border : 'none' ,
178
+ width : '100%' ,
179
+ flex : '1 1 auto' ,
180
+ padding : '5px 10px' ,
181
+ fontSize : '1em' ,
182
+ position : 'relative' ,
183
+ fontFamily :
184
+ 'monaco, Consolas, "Lucida Console", monospace' ,
185
+
186
+ backgroundColor : theme . BACKGROUND_COLOR ,
187
+ color : theme . TEXT_COLOR ,
188
+
189
+ '&::-webkit-input-placeholder' : {
190
+ color : theme . TEXT_PLACEHOLDER_COLOR ,
191
+ } ,
192
+
193
+ '&::-moz-placeholder' : {
194
+ color : theme . TEXT_PLACEHOLDER_COLOR ,
195
+ } ,
196
+ '&::-webkit-search-cancel-button' : {
197
+ WebkitAppearance : 'none' ,
198
+ } ,
199
+ } ,
200
+ } ) }
201
+ >
141
202
< input
142
203
ref = { this . inputSearchRef }
143
204
type = "search"
@@ -152,7 +213,32 @@ export class QueryForm extends React.PureComponent<
152
213
+ ( this . state . searchValue . length === 0 ) || undefined
153
214
}
154
215
onClick = { this . handleClearSearchClick }
155
- { ...styling ( 'closeButton' ) }
216
+ css = { ( theme ) => ( {
217
+ WebkitAppearance : 'none' ,
218
+ border : 'none' ,
219
+ outline : 'none' ,
220
+ boxShadow : 'none' ,
221
+ display : 'block' ,
222
+ flex : '0 0 auto' ,
223
+ cursor : 'pointer' ,
224
+ background : 'transparent' ,
225
+ position : 'relative' ,
226
+ fontSize : 'inherit' ,
227
+ '&[data-invisible="1"]' : {
228
+ visibility : 'hidden !important' as 'hidden' ,
229
+ } ,
230
+ '&::after' : {
231
+ content : '"\u00d7"' ,
232
+ display : 'block' ,
233
+ padding : 4 ,
234
+ fontSize : '1.2em' ,
235
+ color : theme . TEXT_PLACEHOLDER_COLOR ,
236
+ background : 'transparent' ,
237
+ } ,
238
+ '&:hover::after' : {
239
+ color : theme . TEXT_COLOR ,
240
+ } ,
241
+ } ) }
156
242
/>
157
243
< button
158
244
type = "button"
@@ -161,12 +247,41 @@ export class QueryForm extends React.PureComponent<
161
247
data-type = { regexToggleType }
162
248
aria-pressed = { isRegexSearch }
163
249
onClick = { this . handleRegexSearchClick }
164
- { ...styling ( 'toggleButton' ) }
250
+ css = { ( theme ) => ( {
251
+ width : '24px' ,
252
+ height : '24px' ,
253
+ display : 'inline-block' ,
254
+ flex : '0 0 auto' ,
255
+ color : theme . TEXT_PLACEHOLDER_COLOR ,
256
+ cursor : 'pointer' ,
257
+ padding : 0 ,
258
+ fontSize : '0.7em' ,
259
+ letterSpacing : '-0.7px' ,
260
+ outline : 'none' ,
261
+ boxShadow : 'none' ,
262
+ fontWeight : '700' ,
263
+ border : 'none' ,
264
+
265
+ '&:hover' : {
266
+ color : theme . TEXT_COLOR ,
267
+ } ,
268
+
269
+ backgroundColor : 'transparent' ,
270
+ '&[aria-pressed="true"]' : {
271
+ color : theme . BACKGROUND_COLOR ,
272
+ backgroundColor : theme . TEXT_COLOR ,
273
+ } ,
274
+
275
+ '&[data-type="error"]' : {
276
+ color : theme . TEXT_COLOR ,
277
+ backgroundColor : theme . TOGGLE_BUTTON_ERROR ,
278
+ } ,
279
+ } ) }
165
280
>
166
281
< RegexIcon />
167
282
</ button >
168
283
</ div >
169
- < label htmlFor = { selectId } { ... styling ( 'srOnly' ) } >
284
+ < label htmlFor = { selectId } css = { srOnlyCss } >
170
285
filter by
171
286
</ label >
172
287
< Select < SelectOption < QueryFilters > >
@@ -180,7 +295,24 @@ export class QueryForm extends React.PureComponent<
180
295
onChange = { this . handleSelectFilterChange }
181
296
/>
182
297
</ div >
183
- < div { ...styling ( 'sortBySection' ) } >
298
+ < div
299
+ css = { {
300
+ display : 'flex' ,
301
+ padding : '0.4em' ,
302
+ '& label' : {
303
+ display : 'flex' ,
304
+ flex : '0 0 auto' ,
305
+ whiteSpace : 'nowrap' ,
306
+ alignItems : 'center' ,
307
+ paddingRight : '0.4em' ,
308
+ } ,
309
+
310
+ '& > :last-child' : {
311
+ flex : '0 0 auto' ,
312
+ marginLeft : '0.4em' ,
313
+ } ,
314
+ } }
315
+ >
184
316
< label htmlFor = { selectId } > Sort by</ label >
185
317
< Select < SelectOption < QueryComparators > >
186
318
id = { selectId }
0 commit comments