diff --git a/packages/components/checkbox/src/Checkbox.stories.mdx b/packages/components/checkbox/src/Checkbox.stories.mdx index ce4614e79..30f0e2714 100644 --- a/packages/components/checkbox/src/Checkbox.stories.mdx +++ b/packages/components/checkbox/src/Checkbox.stories.mdx @@ -36,3 +36,6 @@ import { Checkbox } from "@spark-ui/checkbox" + + + diff --git a/packages/components/checkbox/src/Checkbox.stories.tsx b/packages/components/checkbox/src/Checkbox.stories.tsx index cbd72cbe5..e8d57a9d5 100644 --- a/packages/components/checkbox/src/Checkbox.stories.tsx +++ b/packages/components/checkbox/src/Checkbox.stories.tsx @@ -2,13 +2,13 @@ import { ReactLiveBlock } from '@docs/helpers/ReactLiveBlock' import { Checkbox } from './Checkbox' -export const Default = ({ id = 'c1', ...rest }) => ( +export const Default = () => (
- + @@ -16,6 +16,44 @@ export const Default = ({ id = 'c1', ...rest }) => ( ) -export const Disabled = () => +export const Disabled = () => ( + +
+ + +
+
+) + +export const DefaultChecked = () => ( + +
+ + +
+
+) +const colors = ['primary', 'secondary', 'success', 'alert', 'error', 'info', 'neutral'] -export const DefaultChecked = () => +export const Colors = () => ( + + {colors.map(color => { + return ( +
+ + +
+ ) + })} +
+) diff --git a/packages/components/checkbox/src/Checkbox.tsx b/packages/components/checkbox/src/Checkbox.tsx index 705291164..eddb2cb04 100644 --- a/packages/components/checkbox/src/Checkbox.tsx +++ b/packages/components/checkbox/src/Checkbox.tsx @@ -38,8 +38,8 @@ export interface CheckboxProps export const Checkbox = React.forwardRef< React.ElementRef, CheckboxProps ->(({ ...props }, ref) => ( - +>(({ intent, ...props }, ref) => ( + diff --git a/packages/components/checkbox/src/Checkbox.variants.tsx b/packages/components/checkbox/src/Checkbox.variants.tsx index b3b34b989..22aaa1ccf 100644 --- a/packages/components/checkbox/src/Checkbox.variants.tsx +++ b/packages/components/checkbox/src/Checkbox.variants.tsx @@ -1,12 +1,33 @@ import { cva, VariantProps } from 'class-variance-authority' -export const styles = cva([ - 'peer h-[20px] w-[20px] rounded-sm border-md border-outline bg-transparent items-center justify-center', - 'radix-state-checked:bg-primary radix-state-checked:border-primary', - 'radix-state-indeterminate:bg-primary radix-state-indeterminate:border-primary', - 'focus:outline-none focus:ring-2 focus:ring focus:ring-offset-0 focus:ring-[#000000]', - 'hover:outline-none hover:ring-2 hover:ring hover:ring-offset-0', - 'radix-disabled:opacity-50 radix-disabled:cursor-not-allowed radix-disabled:hover:ring-0', -]) +const defaultVariants = { + intent: 'primary', +} as const + +export const styles = cva( + [ + 'peer h-[20px] w-[20px] rounded-sm border-md border-outline bg-transparent items-center justify-center', + 'radix-state-unchecked:border-outline', + 'radix-disabled:opacity-dim-3 radix-disabled:cursor-not-allowed radix-disabled:hover:ring-0', + 'radix-state-checked:bg-primary radix-state-checked:border-primary', + 'radix-state-indeterminate:bg-primary radix-state-indeterminate:border-primary', + 'focus:outline-none focus:ring-2 focus:ring focus:ring-offset-0 focus:ring-[#000000]', + 'hover:outline-none hover:ring-2 hover:ring hover:ring-offset-0', + ], + { + variants: { + intent: { + primary: ['border-primary', 'radix-state-checked:bg-primary'], + secondary: ['border-secondary', 'radix-state-checked:bg-secondary'], + success: ['border-success', 'radix-state-checked:bg-success'], + alert: ['border-alert', 'radix-state-checked:bg-alert'], + error: ['border-error', 'radix-state-checked:bg-error'], + info: ['border-info', 'radix-state-checked:bg-info'], + neutral: ['border-neutral', 'radix-state-checked:bg-neutral'], + }, + }, + defaultVariants, + } +) export type StylesProps = VariantProps