@@ -10,7 +10,7 @@ import React from 'react';
10
10
import { Global , css } from '@emotion/react' ;
11
11
import { useScrollBar } from '../mixins/_helpers' ;
12
12
import { useEuiFont } from '../mixins/_typography' ;
13
- import { shade , tint } from '../../services/color' ;
13
+ import { shade , tint , transparentize } from '../../services/color' ;
14
14
import { useEuiTheme , isDefaultTheme } from '../../services/theme' ;
15
15
16
16
export const EuiGlobalReset = ( ) => {
@@ -207,6 +207,8 @@ export const EuiGlobalReset = () => {
207
207
line-height : ${ defaultTheme ? '1' : '1.142857143' } ;
208
208
}
209
209
210
+ ${ defaultTheme
211
+ ? `
210
212
*:focus {
211
213
outline: none;
212
214
@@ -218,7 +220,40 @@ export const EuiGlobalReset = () => {
218
220
&:-moz-focusring {
219
221
outline: none;
220
222
}
223
+ }`
224
+ : `
225
+ *:focus {
226
+ // 👉 Safari and Firefox innately respect only showing the outline with keyboard only
227
+ // 💔 But they don't allow coloring of the 'auto'/default outline, so contrast is no good in dark mode.
228
+ // 👉 For these browsers we use the solid type in order to match with \`currentColor\`.
229
+ // 😦 Which does means the outline will be square
230
+ // outline: $euiFocusRingSize solid currentColor;
231
+ outline: 2px solid currentColor;
232
+ // outline-offset: -($euiFocusRingSize / 2);
233
+ outline-offset: calc((2px / 2) * -1);
234
+
235
+ // 👀 Chrome respects :focus-visible and allows coloring the \`auto\` style
236
+ &:focus-visible {
237
+ outline-style: auto;
238
+ }
239
+
240
+ //🙅♀️ But Chrome also needs to have the outline forcefully removed from regular \`:focus\` state
241
+ &:not(:focus-visible) {
242
+ outline: none;
243
+ }
244
+ }` }
245
+
246
+ ${ ! defaultTheme &&
247
+ `
248
+ // Dark mode's highlighted doesn't work well so lets just set it the same as our focus background
249
+ ::selection {
250
+ // background: $euiFocusBackgroundColor;
251
+ background: ${ transparentize (
252
+ colors . primary ,
253
+ colorMode === 'LIGHT' ? 0.9 : 0.8
254
+ ) }
221
255
}
256
+ ` }
222
257
223
258
a {
224
259
text-decoration : none;
@@ -230,7 +265,7 @@ export const EuiGlobalReset = () => {
230
265
231
266
& : focus {
232
267
text-decoration : none;
233
- outline : none;
268
+ ${ defaultTheme && ' outline: none;' }
234
269
}
235
270
}
236
271
@@ -254,7 +289,7 @@ export const EuiGlobalReset = () => {
254
289
border : none;
255
290
padding : 0 ;
256
291
margin : 0 ;
257
- outline : none;
292
+ ${ defaultTheme && ' outline: none;' }
258
293
font-size : inherit;
259
294
color : inherit;
260
295
border-radius : 0 ;
0 commit comments