Skip to content

Commit 885b5f1

Browse files
committed
amsterdam overrides
1 parent e79c771 commit 885b5f1

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/global_styling/reset/global_reset.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import React from 'react';
1010
import { Global, css } from '@emotion/react';
1111
import { useScrollBar } from '../mixins/_helpers';
1212
import { useEuiFont } from '../mixins/_typography';
13-
import { shade, tint } from '../../services/color';
13+
import { shade, tint, transparentize } from '../../services/color';
1414
import { useEuiTheme, isDefaultTheme } from '../../services/theme';
1515

1616
export const EuiGlobalReset = () => {
@@ -207,6 +207,8 @@ export const EuiGlobalReset = () => {
207207
line-height: ${defaultTheme ? '1' : '1.142857143'};
208208
}
209209
210+
${defaultTheme
211+
? `
210212
*:focus {
211213
outline: none;
212214
@@ -218,7 +220,40 @@ export const EuiGlobalReset = () => {
218220
&:-moz-focusring {
219221
outline: none;
220222
}
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+
)}
221255
}
256+
`}
222257
223258
a {
224259
text-decoration: none;
@@ -230,7 +265,7 @@ export const EuiGlobalReset = () => {
230265
231266
&:focus {
232267
text-decoration: none;
233-
outline: none;
268+
${defaultTheme && 'outline: none;'}
234269
}
235270
}
236271
@@ -254,7 +289,7 @@ export const EuiGlobalReset = () => {
254289
border: none;
255290
padding: 0;
256291
margin: 0;
257-
outline: none;
292+
${defaultTheme && 'outline: none;'}
258293
font-size: inherit;
259294
color: inherit;
260295
border-radius: 0;

0 commit comments

Comments
 (0)