Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
errorRingColor = inputColors.warning.border;
errorRingBorderColor = colors.cantaloupe600;
} else {
return;
}
const errorStyles = {
'& ~ div:first-of-type': {
border: `1px solid ${errorRingColor}`,
boxShadow: `0 0 0 1px ${errorRingColor}, 0 0 0 2px ${errorRingBorderColor}`,
},
'&:not(:checked):not(:disabled):not(:focus):hover ~ div:first-of-type': {
borderColor: errorRingColor,
},
'&:checked ~ div:first-of-type': {
borderColor: colors.blueberry400,
boxShadow: `
0 0 0 2px ${colors.frenchVanilla100},
0 0 0 4px ${errorRingColor},
0 0 0 5px ${errorRingBorderColor}`,
},
};
return {
...errorStyles,
// Error rings take precedence over focus
...mouseFocusBehavior({
...errorStyles,
'&:not(:checked):focus ~ div:first-of-type': {
border: `1px solid ${errorRingColor}`,
boxShadow: `0 0 0 1px ${errorRingColor}, 0 0 0 2px ${errorRingBorderColor}`,
},
}),
marginTop: '-3px',
marginLeft: '-3px',
position: 'absolute',
opacity: 0,
'&:not(:disabled)': {
cursor: 'pointer',
},
// States
'&:not(:checked):not(:disabled):not(:focus):hover ~ div:first-of-type': {
borderColor: inputColors.hoverBorder,
},
'&:checked ~ div:first-of-type': {
borderColor: colors.blueberry400,
backgroundColor: colors.blueberry400,
},
'&:disabled ~ div:first-of-type': {
borderColor: inputColors.disabled.border,
backgroundColor: inputColors.disabled.background,
},
'&:disabled:checked ~ div:first-of-type': {
borderColor: colors.blueberry200,
backgroundColor: colors.blueberry200,
},
// Focus
'&:focus, &:active': {
outline: 'none',
},
'&:focus ~ div:first-of-type': {
borderColor: colors.blueberry400,
margin: 0,
marginTop: '-3px',
marginLeft: '-3px',
position: 'absolute',
opacity: 0,
'&:not(:disabled)': {
cursor: 'pointer',
},
// States
'&:not(:checked):not(:disabled):not(:focus):hover ~ div:first-of-type': {
borderColor: inputColors.hoverBorder,
},
'&:checked ~ div:first-of-type': {
borderColor: colors.blueberry400,
backgroundColor: colors.blueberry400,
},
'&:disabled ~ div:first-of-type': {
borderColor: inputColors.disabled.border,
backgroundColor: inputColors.disabled.background,
},
'&:disabled:checked ~ div:first-of-type': {
borderColor: colors.blueberry200,
backgroundColor: colors.blueberry200,
},
// Focus
'&:focus, &:active': {
outline: 'none',
},
'&:focus ~ div:first-of-type': {
[key: string]: ThemeAttributes;
}
export const themes: Themes = {
[HeaderTheme.White]: {
color: colors.blackPepper400,
background: colors.frenchVanilla100,
depth: depth['1'],
systemIcon: {
color: iconColors.standard,
colorHover: iconColors.hover,
},
linkColor: colors.blackPepper400,
linkFadeOutColor: colors.licorice200,
currentLinkColor: colors.blueberry500,
chipColor: colors.blueberry400,
},
[HeaderTheme.Blue]: {
color: colors.frenchVanilla100,
background: colors.gradients.blueberry,
depth: depth['3'],
systemIcon: {
color: colors.frenchVanilla100,
colorHover: colors.blueberry200,
},
linkColor: colors.frenchVanilla100,
linkFadeOutColor: chroma(colors.frenchVanilla100)
.alpha(0.5)
.css(),
currentLinkColor: colors.frenchVanilla100,
chipColor: colors.frenchVanilla100,
},
const RadioInput = styled('input')(
{
borderRadius: radioBorderRadius,
width: radioTapArea,
height: radioTapArea,
margin: 0,
marginTop: '-3px',
marginLeft: '-3px',
position: 'absolute',
opacity: 0,
'&:focus, &:active': {
outline: 'none',
},
'&:focus, &:active, &focus:hover, &:active:hover': {
'& ~ div:first-of-type': {
borderColor: colors.blueberry400,
borderWidth: '2px',
zIndex: 2,
},
},
'&:checked:focus ~ div:first-of-type': {
...focusRing(2, 2),
},
},
({checked, disabled}) => ({
cursor: disabled ? undefined : 'pointer',
'&:focus:hover ~ div:first-of-type': {
borderColor: disabled ? inputColors.border : colors.blueberry400,
},
[`[data-whatinput="mouse"] &:focus ~ div:first-of-type,
[data-whatinput="touch"] &:focus ~ div:first-of-type,
[data-whatinput="pointer"] &:focus ~ div:first-of-type`]: {
'&:focus:hover ~ div:first-of-type': {
borderColor: disabled ? inputColors.border : colors.blueberry400,
},
[`[data-whatinput="mouse"] &:focus ~ div:first-of-type,
[data-whatinput="touch"] &:focus ~ div:first-of-type,
[data-whatinput="pointer"] &:focus ~ div:first-of-type`]: {
...focusRing(0, 0),
borderWidth: '1px',
borderColor: checked ? colors.blueberry400 : inputColors.border,
'&:hover': {
borderColor: checked ? colors.blueberry400 : inputColors.hoverBorder,
},
},
[`[data-whatinput="mouse"] &:hover ~ div:first-of-type`]: {
backgroundColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.background
: 'white',
borderColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.border
: inputColors.hoverBorder,
borderWidth: '1px',
},
})
);
...getFillSelector(colors.blueberry400),
...getAccentSelector(colors.blueberry400),
};
case IconButtonVariant.Circle:
return {
'&:active': {
...getFillSelector(colors.blueberry400),
...getAccentSelector(colors.frenchVanilla100),
},
...getBackgroundSelector(colors.blueberry400),
...getFillSelector(colors.blueberry400),
...getAccentSelector(colors.frenchVanilla100),
};
case IconButtonVariant.CircleFilled:
return {
backgroundColor: colors.blueberry400,
'&:hover, &:focus&:hover': {
backgroundColor: colors.blueberry500,
...getAccentSelector(colors.blueberry500),
},
...getBackgroundSelector(colors.frenchVanilla100),
...getFillSelector(colors.frenchVanilla100),
...getAccentSelector(colors.blueberry400),
};
case IconButtonVariant.Inverse:
return {
'&:hover span .wd-icon-fill, span .wd-icon-fill': {
fill: colors.frenchVanilla100,
},
...getBackgroundSelector(colors.frenchVanilla100),
...getAccentSelector(colors.licorice200),
};
[data-whatinput="pointer"] &:focus ~ div:first-of-type`]: {
...focusRing(0, 0),
borderWidth: '1px',
borderColor: checked ? colors.blueberry400 : inputColors.border,
'&:hover': {
borderColor: checked ? colors.blueberry400 : inputColors.hoverBorder,
},
},
[`[data-whatinput="mouse"] &:hover ~ div:first-of-type`]: {
backgroundColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.background
: 'white',
borderColor: checked
? colors.blueberry400
: disabled
? inputColors.disabled.border
: inputColors.hoverBorder,
borderWidth: '1px',
},
})
);
({variant, toggled}) => {
if (!toggled) {
return {};
}
switch (variant) {
case IconButtonVariant.SquareFilled:
default:
return {
'&:focus&:hover, &:focus, &:active': {
backgroundColor: colors.blueberry400,
...getFillSelector(colors.frenchVanilla100),
...getAccentSelector(colors.frenchVanilla100),
},
'&:not([disabled]):focus': {
...(toggled ? focusRing(2, 2) : {}),
},
'&:hover': {
backgroundColor: colors.blueberry500,
},
backgroundColor: colors.blueberry400,
borderColor: colors.blueberry400,
...getFillSelector(colors.frenchVanilla100),
...getAccentSelector(colors.frenchVanilla100),
};
case IconButtonVariant.Square:
return {