88
99import { css } from '@emotion/react' ;
1010
11+ import { logicalSizeCSS , mathWithUnits } from '../../../global_styling' ;
1112import { UseEuiTheme } from '../../../services' ;
1213
1314export const EuiFormControlLayoutClearButtonStyles = ( {
@@ -16,38 +17,52 @@ export const EuiFormControlLayoutClearButtonStyles = ({
1617 highContrastMode,
1718} : UseEuiTheme ) => {
1819 const backgroundColor =
19- highContrastMode === 'forced'
20- ? euiTheme . colors . fullShade
21- : colorMode === 'DARK' || highContrastMode // mediumShade is not sufficient WCAG contrast
20+ colorMode === 'DARK' || highContrastMode // mediumShade is not sufficient WCAG contrast
2221 ? euiTheme . colors . darkShade
2322 : euiTheme . colors . mediumShade ;
2423
2524 return {
2625 euiFormControlLayoutClearButton : css `
2726 pointer-events : all;
28- background-color : ${ backgroundColor } ;
29- ${ highContrastMode === 'forced' ? 'forced-color-adjust: none;' : '' }
27+ display : flex;
28+ justify-content : center;
29+ align-items : center;
3030 border-radius : 50% ;
31- line-height : 0 ; /* ensures the icon stays vertically centered */
31+ /* Windows high contrast themes ignore background-color, so we use border to color the button instead for better support */
32+ border-style : solid;
33+ border-color : ${ backgroundColor } ;
3234
3335 & : disabled {
3436 cursor : not-allowed;
3537 background-color : ${ euiTheme . colors . disabled } ;
3638 }
3739 ` ,
3840
39- euiFormControlLayoutClearButton__icon : css `
40- transform : scale (0.5 );
41- fill : ${ euiTheme . colors . emptyShade } ;
42- stroke : ${ euiTheme . colors . emptyShade } ;
43- ` ,
4441 size : {
45- s : css `
46- stroke-width : ${ euiTheme . size . xs } ;
42+ s : `
43+ ${ logicalSizeCSS ( euiTheme . size . m ) }
44+ border-width: ${ mathWithUnits ( euiTheme . size . m , ( x ) => x / 2 ) } ;
45+ ` ,
46+ m : `
47+ ${ logicalSizeCSS ( euiTheme . size . base ) }
48+ border-width: ${ mathWithUnits ( euiTheme . size . base , ( x ) => x / 2 ) } ;
4749 ` ,
48- m : css `
49- stroke-width : ${ euiTheme . size . xxs } ;
50+ } ,
51+
52+ icon : {
53+ euiFormControlLayoutClearButton__icon : css `
54+ transform : scale (0.5 );
55+ fill : ${ euiTheme . colors . emptyShade } ;
56+ stroke : ${ euiTheme . colors . emptyShade } ;
5057 ` ,
58+ size : {
59+ s : css `
60+ stroke-width : ${ euiTheme . size . xs } ;
61+ ` ,
62+ m : css `
63+ stroke-width : ${ euiTheme . size . xxs } ;
64+ ` ,
65+ } ,
5166 } ,
5267 } ;
5368} ;
0 commit comments