Skip to content

Commit

Permalink
feat: update radio style
Browse files Browse the repository at this point in the history
  • Loading branch information
gndz07 authored Jun 27, 2023
1 parent ea75108 commit 44baca7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 3 additions & 3 deletions components/Radio/Radio.themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export namespace Theme {
type Factory = (primaryColor: ColorInfo) => Colors;

export const getLight: Factory = (primaryColor) => ({
radioIndicator: tinycolor(primaryColor.value).darken(20).toHslString(),
radioIndicator: '$primary',
radioBorder: '$deepBlue6',
radioHoverBg: 'transparent',
radioHoverBorder: tinycolor(primaryColor.value).darken(20).toHslString(),
radioFocusBorder: tinycolor(primaryColor.value).darken(20).toHslString(),
radioHoverBorder: '$primary',
radioFocusBorder: '$primary',
radioDisabledBg: '$deepBlue3',
radioDisabledBorder: '$deepBlue5',
radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),
Expand Down
16 changes: 10 additions & 6 deletions components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const INDICATOR_BASE_STYLES = {
'&::after': {
content: '""',
display: 'block',
width: '8px',
height: '8px',
width: '7px',
height: '7px',
borderRadius: '$round',
backgroundColor: '$radioIndicator',
backgroundColor: '$contentBg',
},
};

Expand Down Expand Up @@ -50,13 +50,15 @@ export const RADIO_BASE_STYLES = {
color: '$hiContrast',
boxShadow: 'inset 0 0 0 1px $colors$radioBorder',
overflow: 'hidden',
'&[data-state=checked]': {
backgroundColor: '$radioIndicator',
},
};
const StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {
'@hover': {
'&:hover': {
cursor: 'pointer',
boxShadow: 'inset 0 0 0 1px $colors$radioHoverBorder',
backgroundColor: '$radioHoverBg',
},
},
'&:focus-visible': {
Expand All @@ -66,14 +68,16 @@ const StyledRadio = styled(RadioGroupPrimitive.Item, RADIO_BASE_STYLES, {

'&:disabled': {
pointerEvents: 'none',
backgroundColor: '$radioDisabledBg',
'&::placeholder': {
color: '$radioDisabledText',
},
'&[data-state=checked]': {
backgroundColor: '$radioIndicatorDisabledBg',
},

[`& ${StyledIndicator}`]: {
'&::after': {
backgroundColor: '$radioIndicatorDisabledBg',
backgroundColor: '$radioDisabledBg',
},
},
},
Expand Down
15 changes: 4 additions & 11 deletions components/RadioAccordion/RadioAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,18 @@ const StyledRadio = styled('div', RADIO_BASE_STYLES, {
width: 18,
height: 18,
mr: '$2',
});

const StyledIndicator = styled('div', INDICATOR_BASE_STYLES, {
'&::after': {
'[data-state=open] &': {
backgroundColor: '$radioIndicator',
},
'[data-state=closed] &': {
backgroundColor: 'transparent',
},
'[data-state=open] &': {
backgroundColor: '$radioIndicator',
},
});

const StyledIndicator = styled('div', INDICATOR_BASE_STYLES);

const StyledRadioAccordionTrigger = styled(StyledAccordionTrigger, {
'@hover': {
'&:hover': {
[`& ${StyledRadio}`]: {
boxShadow: 'inset 0 0 0 1px $colors$radioHoverBorder',
backgroundColor: '$radioHoverBg',
},
},
},
Expand Down

0 comments on commit 44baca7

Please sign in to comment.