Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: style for the checkbox component #351

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/forms/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { checkbox, cn } from '@/tailwind'
export interface Comp extends React.ElementRef<typeof CheckboxPrimitive.Root> {}
export type Props = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> & VariantProps<typeof checkbox>

const Checkbox = React.forwardRef<Comp, Props>(({ className, color, rounded, ...props }, ref) => (
const Checkbox = React.forwardRef<Comp, Props>(({ className, variant, rounded, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(checkbox({ color, rounded }), className)}
className={cn(checkbox({ variant, rounded }), className)}
{...props}
>
<CheckboxPrimitive.Indicator>
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/components/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { cva } from 'class-variance-authority'
*/
export const checkbox = cva('peer size-4 shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', {
variants: {
color: {
variant: {
default: 'data-[state=checked]:bg-default data-[state=checked]:text-default-foreground border border-default',
primary: 'data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground border border-primary',
success: 'data-[state=checked]:bg-success data-[state=checked]:text-success-foreground border border-success',
Expand All @@ -23,9 +23,15 @@ export const checkbox = cva('peer size-4 shrink-0 focus-visible:outline-none foc
md: 'rounded-medium',
lg: 'rounded-large',
},
size: {
sm: 'size-4',
md: 'size-5',
lg: 'size-6',
},
},
defaultVariants: {
color: 'default',
variant: 'default',
rounded: 'sm',
size: 'sm',
},
})
Loading