66 */
77
88import styled , { css , DefaultTheme , ThemeProps } from 'styled-components' ;
9- import { getColorV8 , retrieveComponentStyles , DEFAULT_THEME } from '@zendeskgarden/react-theming' ;
9+ import { retrieveComponentStyles , DEFAULT_THEME , getColor } from '@zendeskgarden/react-theming' ;
1010import { StyledRadioInput } from '../radio/StyledRadioInput' ;
1111import { StyledCheckLabel } from './StyledCheckLabel' ;
1212
1313const COMPONENT_ID = 'forms.checkbox' ;
1414
15- const colorStyles = ( props : ThemeProps < DefaultTheme > ) => {
16- const SHADE = 600 ;
15+ const colorStyles = ( { theme } : ThemeProps < DefaultTheme > ) => {
16+ const backgroundOptions = { theme, variable : 'background.primaryEmphasis' } ;
17+ const borderOptions = { theme, variable : 'border.primaryEmphasis' } ;
1718
18- const indeterminateBorderColor = getColorV8 ( 'primaryHue' , SHADE , props . theme ) ;
19- const indeterminateBackgroundColor = indeterminateBorderColor ;
20- const indeterminateActiveBorderColor = getColorV8 ( 'primaryHue' , SHADE + 100 , props . theme ) ;
21- const indeterminateActiveBackgroundColor = indeterminateActiveBorderColor ;
22- const indeterminateDisabledBackgroundColor = getColorV8 ( 'neutralHue' , SHADE - 400 , props . theme ) ;
19+ const indeterminateBackgroundColor = getColor ( backgroundOptions ) ;
20+ const indeterminateBorderColor = getColor ( borderOptions ) ;
21+
22+ const offset100 = { dark : { offset : - 100 } , light : { offset : 100 } } ;
23+ const offset200 = { dark : { offset : - 200 } , light : { offset : 200 } } ;
24+
25+ const indeterminateHoverBackgroundColor = getColor ( { ...backgroundOptions , ...offset100 } ) ;
26+ const indeterminateHoverBorderColor = getColor ( { ...borderOptions , ...offset100 } ) ;
27+ const indeterminateActiveBackgroundColor = getColor ( { ...backgroundOptions , ...offset200 } ) ;
28+ const indeterminateActiveBorderColor = getColor ( { ...borderOptions , ...offset200 } ) ;
29+ const indeterminateDisabledBackgroundColor = getColor ( {
30+ theme,
31+ variable : 'background.disabled' ,
32+ transparency : theme . opacity [ 300 ]
33+ } ) ;
2334
2435 return css `
2536 & : indeterminate ~ ${ StyledCheckLabel } ::before {
@@ -28,6 +39,11 @@ const colorStyles = (props: ThemeProps<DefaultTheme>) => {
2839 }
2940
3041 /* stylelint-disable selector-max-specificity */
42+ & : enabled : indeterminate ~ ${ StyledCheckLabel } : hover ::before {
43+ border-color : ${ indeterminateHoverBorderColor } ;
44+ background-color : ${ indeterminateHoverBackgroundColor } ;
45+ }
46+
3147 & : enabled : indeterminate ~ ${ StyledCheckLabel } : active ::before {
3248 border-color : ${ indeterminateActiveBorderColor } ;
3349 background-color : ${ indeterminateActiveBackgroundColor } ;
@@ -51,7 +67,7 @@ export const StyledCheckInput = styled(StyledRadioInput).attrs({
5167 border-radius: ${ props => props . theme . borderRadii . md } ;
5268 }
5369
54- ${ props => colorStyles ( props ) } ;
70+ ${ colorStyles } ;
5571
5672 ${ props => retrieveComponentStyles ( COMPONENT_ID , props ) } ;
5773` ;
0 commit comments