Skip to content

Commit

Permalink
add hover effect to radio buttons (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswithf authored Jul 18, 2024
1 parent f29759e commit 4941b28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/form/primitive/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(
size,
})
const radioLabelCss = useRadioLabelCss({ mode, size, disabled })
const radioInputCss = useRadioInputCss({ size })
const radioInputCss = useRadioInputCss({ size, disabled })

return (
<label className={classNames(radioCss, className)}>
Expand Down
14 changes: 12 additions & 2 deletions src/components/form/primitive/useThemedCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,24 @@ export function useRadioLabelCss({
)
}

export function useRadioInputCss({ size }: { size: Size }) {
export function useRadioInputCss({
size,
disabled,
}: {
size: Size
disabled: boolean
}) {
const {
form: {
radio: { input: theme },
},
} = useTheme()

return classNames(theme.base, theme.size[size])
return classNames(
theme.base,
theme.size[size],
disabled ? theme.disabled : theme.normal,
)
}

export function useRadioIconCss({
Expand Down
2 changes: 2 additions & 0 deletions src/components/form/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ export default {
},
input: {
base: 'peer absolute h-0 w-0 opacity-0',
normal: 'cursor-pointer',
disabled: '',
size: {
[Size.Sm]: 'h-4 w-4',
[Size.Md]: 'h-5 w-5',
Expand Down

0 comments on commit 4941b28

Please sign in to comment.