Skip to content

Commit

Permalink
Fixing Checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 11, 2024
1 parent 7ab7ad0 commit 94000aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
15 changes: 5 additions & 10 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { forwardRef, Ref } from 'react'
import { Field, FieldProps } from '~/components/Field'
import { CheckmarkIcon } from '~/icons'

import {
checkboxVariants,
CheckboxVariants,
indicatorVariants,
IndicatorVariants,
} from './styles.css'
import { checkboxVariants, CheckboxVariants, indicator } from './styles.css'

export type CheckboxProps = FieldProps &
CheckboxVariants &
Expand All @@ -18,11 +13,11 @@ export type CheckboxProps = FieldProps &
id?: string
}

type IndicatorProps = IndicatorVariants & {}
type IndicatorProps = CheckboxVariants & {}

const Indicator = ({ size = 'sm' }: IndicatorProps) => (
<CheckboxPrimitive.Indicator className={indicatorVariants({ size })}>
<CheckmarkIcon size={size} />
<CheckboxPrimitive.Indicator className={indicator}>
<CheckmarkIcon size={size === 'lg' ? 'sm' : 'xs'} />
</CheckboxPrimitive.Indicator>
)

Expand Down Expand Up @@ -55,7 +50,7 @@ export const Checkbox = forwardRef(
ref={ref}
{...rest}
>
<Indicator />
<Indicator size={size} />
</CheckboxPrimitive.Root>
</Field>
)
Expand Down
23 changes: 8 additions & 15 deletions src/components/Checkbox/styles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const checkboxVariants = recipe({
borderWidth: 'thin',
borderStyle: 'solid',
borderColor: 'borderFocus',
background: 'transparent',
opacity: {
base: '100',
hover: '80',
Expand All @@ -32,19 +33,11 @@ export const checkboxVariants = recipe({

export type CheckboxVariants = RecipeVariants<typeof checkboxVariants>

export const indicatorVariants = recipe({
base: atoms({
color: 'text100',
background: 'text50',
borderRadius: 'xs',
}),

variants: {
size: {
sm: [{ height: 20, width: 20 }],
lg: [{ height: 28, width: 28 }],
},
},
export const indicator = atoms({
color: 'text100',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: 'full',
height: 'full',
})

export type IndicatorVariants = RecipeVariants<typeof indicatorVariants>
1 change: 1 addition & 0 deletions src/components/RadioGroup/styles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const radioItemVariants = recipe({
disabled: 'default',
},
opacity: {
hover: '80',
disabled: '50',
},
}),
Expand Down

0 comments on commit 94000aa

Please sign in to comment.