-
Notifications
You must be signed in to change notification settings - Fork 53
fix(radio buttons): Update radio button styles #830
Changes from all commits
e75b9ba
c3e4455
877069b
5e6bdb2
44dd36b
fa6d6a5
dd955ed
9da7b9a
c088a53
6ec0927
856628c
6cc4c92
39edc9d
2a80787
3d8cd40
7e0ac55
ac43832
dce4412
316a1be
023a22f
3407906
3d43f60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { RadioGroupItemVariables } from 'src/themes/teams/components/RadioGroup/radioGroupItemVariables' | ||
|
||
export default (siteVars: any): Partial<RadioGroupItemVariables> => ({ | ||
textColorDefault: siteVars.gray02, | ||
textColorDefaultHoverFocus: siteVars.colors.white, | ||
textColorChecked: siteVars.colors.white, | ||
|
||
iconBorderColorDefaultHover: siteVars.colors.white, | ||
iconBorderColorChecked: siteVars.brand06, | ||
|
||
iconBackgroundColorChecked: siteVars.brand06, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { RadioGroupItemVariables } from 'src/themes/teams/components/RadioGroup/radioGroupItemVariables' | ||
|
||
export default (siteVars: any): Partial<RadioGroupItemVariables> => ({ | ||
colorDisabled: siteVars.accessibleGreen, | ||
|
||
textColorDefault: siteVars.white, | ||
textColorDefaultHoverFocus: siteVars.white, | ||
textColorChecked: siteVars.white, | ||
|
||
iconBorderColorDefaultHover: siteVars.accessibleCyan, | ||
iconBorderColorChecked: siteVars.accessibleCyan, | ||
|
||
iconBackgroundColorChecked: siteVars.accessibleCyan, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,36 +4,95 @@ import { | |
RadioGroupItemState, | ||
} from '../../../../components/RadioGroup/RadioGroupItem' | ||
import { RadioGroupItemVariables } from './radioGroupItemVariables' | ||
import Icon from '../../../../components/Icon/Icon' | ||
import { pxToRem } from '../../../../lib' | ||
|
||
const restHoverFocusTextColor = textColor => ({ | ||
color: textColor, | ||
|
||
':hover': { | ||
color: textColor, | ||
}, | ||
|
||
':focus': { | ||
color: textColor, | ||
}, | ||
}) | ||
|
||
const radioStyles: ComponentSlotStylesInput< | ||
RadioGroupItemProps & RadioGroupItemState, | ||
RadioGroupItemVariables | ||
> = { | ||
root: ({ props: p, variables: v }): ICSSInJSStyle => ({ | ||
alignItems: 'baseline', | ||
// can remove this after global style for border-box goes in | ||
boxSizing: 'border-box', | ||
|
||
alignItems: 'center', | ||
borderStyle: 'solid', | ||
borderWidth: `${pxToRem(1)}`, | ||
borderColor: 'transparent', | ||
borderRadius: `${pxToRem(2)}`, | ||
color: v.textColorDefault, | ||
cursor: 'pointer', | ||
display: p.vertical ? 'flex' : 'inline-flex', | ||
fontWeight: 400, | ||
minHeight: '2.5rem', | ||
outline: 0, | ||
fontSize: v.textFontSize, | ||
padding: v.padding, | ||
outline: 0, | ||
|
||
':hover': { | ||
color: v.textColorDefaultHoverFocus, | ||
|
||
[`& .${Icon.className}`]: { | ||
color: v.iconBorderColorDefaultHover, | ||
}, | ||
}, | ||
|
||
':focus': { | ||
color: v.textColorDefaultHoverFocus, | ||
}, | ||
|
||
...(p.checked && { | ||
...restHoverFocusTextColor(v.textColorChecked), | ||
}), | ||
|
||
...(p.disabled && { | ||
color: v.colorDisabled, | ||
...restHoverFocusTextColor(v.colorDisabled), | ||
}), | ||
|
||
...(p.isFromKeyboard && { | ||
borderColor: v.focusInnerBorderColor, | ||
boxShadow: `0 0 0 ${pxToRem(1)} ${v.focusOuterBorderColor}`, | ||
}), | ||
}), | ||
|
||
icon: ({ props: p, variables: v }): ICSSInJSStyle => ({ | ||
margin: `0 ${pxToRem(10)} 0 0`, | ||
color: p.checked ? v.colorChecked : v.color, | ||
backgroundColor: p.checked ? v.colorBackgroundChecked : v.colorBackground, | ||
borderColor: p.checked ? v.colorBorderChecked : v.colorBorder, | ||
outlineColor: v.color, | ||
// overrides from icon styles | ||
backgroundColor: 'transparent', | ||
boxShadow: 'none', | ||
|
||
...(p.isFromKeyboard && { | ||
// this creates both inset and outset box shadow that some readers (NVDA) show when radio is not checked but it is focused | ||
boxShadow: `0 0 0 ${pxToRem(1)} ${v.color},` + `0 0 0 ${pxToRem(2)} ${v.color} inset`, | ||
// can remove this after global style for border-box goes in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo: remove after #1057 gets checked in |
||
boxSizing: 'border-box', | ||
|
||
borderStyle: 'solid', | ||
borderWidth: `${pxToRem(1)}`, | ||
borderColor: 'currentColor', | ||
margin: `0 ${pxToRem(12)} 0 0`, | ||
height: `${pxToRem(12)}`, | ||
width: `${pxToRem(12)}`, | ||
|
||
...(p.checked && { | ||
backgroundColor: v.iconBackgroundColorChecked, | ||
borderColor: v.iconBorderColorChecked, | ||
}), | ||
|
||
...(p.disabled && { | ||
borderColor: v.colorDisabled, | ||
}), | ||
|
||
...(p.checked && | ||
p.disabled && { | ||
backgroundColor: v.colorDisabled, | ||
}), | ||
}), | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
import { pxToRem } from '../../../../lib' | ||
|
||
export type RadioGroupItemVariables = { | ||
codepretty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
color: string | ||
colorChecked: string | ||
colorDisabled: string | ||
|
||
colorBorder: string | ||
colorBorderChecked: string | ||
// can these be global colors so we don't have to define for every component? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any suggestions? Almost every component will need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the color scheme this will be aligned with the color scheme used per theme. Let's restrain for making some changes at this moment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can define the |
||
focusInnerBorderColor: string | ||
focusOuterBorderColor: string | ||
|
||
colorBackground: string | ||
colorBackgroundChecked: string | ||
textFontSize: string | ||
|
||
textColorDefault: string | ||
textColorDefaultHoverFocus: string | ||
textColorChecked: string | ||
|
||
iconBorderColorDefaultHover: string | ||
iconBorderColorChecked: string | ||
|
||
iconBackgroundColorChecked: string | ||
|
||
padding: string | ||
} | ||
|
||
export default (siteVars: any): RadioGroupItemVariables => ({ | ||
color: siteVars.colors.primary[500], | ||
colorChecked: siteVars.colors.white, | ||
colorDisabled: siteVars.gray06, | ||
focusInnerBorderColor: siteVars.colors.white, | ||
focusOuterBorderColor: siteVars.colors.black, | ||
|
||
textFontSize: siteVars.fontSizes.medium, | ||
|
||
textColorDefault: siteVars.gray02, | ||
textColorDefaultHoverFocus: siteVars.colors.grey[900], | ||
textColorChecked: siteVars.colors.grey[900], | ||
|
||
colorBorder: siteVars.colors.primary[500], | ||
colorBorderChecked: siteVars.colors.white, | ||
iconBorderColorDefaultHover: siteVars.colors.grey[900], | ||
iconBorderColorChecked: siteVars.colors.primary[500], | ||
|
||
colorBackground: siteVars.colors.white, | ||
colorBackgroundChecked: siteVars.colors.primary[500], | ||
iconBackgroundColorChecked: siteVars.colors.primary[500], | ||
|
||
padding: `0 ${pxToRem(4)}`, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: remove after #1057 gets checked in