@@ -5,6 +5,7 @@ import styled, { css } from 'styled-components';
55import { createDisabledTextStyles , createFlatBoxStyles } from '../common' ;
66import { padding , fontSizes } from '../common/system' ;
77import Cutout from '../Cutout/Cutout' ;
8+ import { StyledListItem } from '../ListItem/ListItem' ;
89
910const radioSize = '20px' ;
1011const StyledLabel = styled . label `
@@ -19,6 +20,11 @@ const StyledLabel = styled.label`
1920 user-select: none;
2021 font-size: ${ fontSizes . md } ;
2122 ${ props => props . isDisabled && createDisabledTextStyles ( ) }
23+
24+ ${ StyledListItem } :hover & {
25+ margin: 0;
26+ height: 100%;
27+ }
2228` ;
2329
2430const StyledInput = styled . input `
@@ -75,6 +81,15 @@ const StyledFlatCheckbox = styled.div`
7581 border-radius: 50%;
7682 }
7783` ;
84+ const StyledMenuCheckbox = styled . div `
85+ ${ sharedCheckboxStyles }
86+ position: relative;
87+ display: inline-block;
88+ box-sizing: border-box;
89+ border: none;
90+ outline: none;
91+ background: none;
92+ ` ;
7893const Icon = styled . span . attrs ( ( ) => ( {
7994 'data-testid' : 'checkmarkIcon'
8095} ) ) `
@@ -87,8 +102,25 @@ const Icon = styled.span.attrs(() => ({
87102 height: 6px;
88103 transform: translate(-50%, -50%);
89104 border-radius: 50%;
90- background: ${ ( { theme, isDisabled } ) =>
91- isDisabled ? theme . checkmarkDisabled : theme . checkmark } ;
105+ ${ ( { variant, theme, isDisabled } ) =>
106+ variant === 'menu'
107+ ? css `
108+ background: ${ isDisabled ? theme . textDisabled : theme . text } ;
109+ filter: drop-shadow(
110+ 1px 1px 0px ${ isDisabled ? theme . textDisabledShadow : 'transparent' }
111+ );
112+ `
113+ : css `
114+ background: ${ isDisabled ? theme . checkmarkDisabled : theme . checkmark } ;
115+ ` }
116+ ${ StyledListItem } :hover & {
117+ ${ ( { theme, isDisabled, variant } ) =>
118+ ! isDisabled &&
119+ variant === 'menu' &&
120+ css `
121+ background: ${ theme . textInvert } ;
122+ ` } ;
123+ }
92124` ;
93125const LabelText = styled . span `
94126 display: inline-block;
@@ -108,8 +140,12 @@ const Radio = React.forwardRef(function Radio(props, ref) {
108140 style,
109141 ...otherProps
110142 } = props ;
111- const CheckboxComponent =
112- variant === 'flat' ? StyledFlatCheckbox : StyledCheckbox ;
143+
144+ const CheckboxComponent = {
145+ flat : StyledFlatCheckbox ,
146+ default : StyledCheckbox ,
147+ menu : StyledMenuCheckbox
148+ } [ variant ] ;
113149
114150 return (
115151 < StyledLabel isDisabled = { disabled } className = { className } style = { style } >
@@ -118,7 +154,7 @@ const Radio = React.forwardRef(function Radio(props, ref) {
118154 isDisabled = { disabled }
119155 role = 'presentation'
120156 >
121- { checked && < Icon isDisabled = { disabled } /> }
157+ { checked && < Icon isDisabled = { disabled } variant = { variant } /> }
122158 </ CheckboxComponent >
123159 { label && < LabelText > { label } </ LabelText > }
124160 < StyledInput
@@ -159,7 +195,7 @@ Radio.propTypes = {
159195 label : propTypes . oneOfType ( [ propTypes . string , propTypes . number ] ) ,
160196 checked : propTypes . bool ,
161197 disabled : propTypes . bool ,
162- variant : propTypes . oneOf ( [ 'default' , 'flat' ] ) ,
198+ variant : propTypes . oneOf ( [ 'default' , 'flat' , 'menu' ] ) ,
163199 style : propTypes . shape ( [ propTypes . string , propTypes . number ] ) ,
164200 className : propTypes . string
165201} ;
0 commit comments