diff --git a/src/components/Checkbox/Checkbox.module.css b/src/components/Checkbox/Checkbox.module.css index 14676cfe..6c454f17 100644 --- a/src/components/Checkbox/Checkbox.module.css +++ b/src/components/Checkbox/Checkbox.module.css @@ -1,6 +1,13 @@ .container { + display: flex; + align-items: center; + gap: var(--size-spacing-xs); user-select: none; - font-size: 12px; + cursor: pointer; +} + +.container:has(input:disabled) { + cursor: initial; } .checkbox { @@ -14,14 +21,43 @@ } .checkIconContainer { - display: inline-block; - width: 16px; - height: 16px; - margin-right: 6px; - border: 2px solid var(--color-primary); - border-radius: 4px; - font-size: 12px; + display: flex; + align-items: center; + justify-content: center; + border: 2px solid var(--color-ubie-black-400); + border-radius: var(--radius-sm); transition: background-color 200ms; + box-sizing: border-box; +} + +.container.medium { + font-size: var(--text-body-md-tight-size); + line-height: var(--text-body-md-tight-line); +} + +.container.small { + font-size: var(--text-body-sm-tight-size); + line-height: var(--text-body-sm-tight-line); +} + +.medium .checkIconContainer { + width: 1.5rem; + height: 1.5rem; +} + +.small .checkIconContainer { + width: 1.25rem; + height: 1.25rem; +} + +@media (pointer: fine) { + .container:hover .checkIconContainer { + border-color: var(--color-primary); + } + + .container:hover input:disabled + .checkIconContainer { + border-color: var(--color-text-disabled); + } } .checkIcon { @@ -29,14 +65,32 @@ color: #fff; } -.container input:checked + .checkIconContainer { +.medium .checkIcon { + font-size: 1.25rem; +} + +.small .checkIcon { + font-size: 1rem; +} + +input:checked + .checkIconContainer { background-color: var(--color-primary); + border-color: var(--color-primary); } -.container input:checked + .checkIconContainer .checkIcon { +input:checked + .checkIconContainer .checkIcon { visibility: initial; } -.container input:focus-visible + .checkIconContainer { +input:focus-visible + .checkIconContainer { outline: solid var(--color-accent) 2px; } + +input:disabled + .checkIconContainer { + border-color: var(--color-text-disabled); +} + +input:disabled:checked + .checkIconContainer { + border: none; + background-color: var(--color-text-disabled); +} diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index 55f0ad8b..8d3237be 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -1,17 +1,19 @@ 'use client'; import { CheckAIcon } from '@ubie/ubie-icons'; -import { FC, ReactNode } from 'react'; +import clsx from 'clsx'; +import { FC, InputHTMLAttributes } from 'react'; import styles from './Checkbox.module.css'; type Props = { - children: ReactNode; -}; + size?: 'medium' | 'small'; +} & Required, 'value' | 'children'>> & + Omit, 'size'>; -export const Checkbox: FC = ({ children }) => { +export const Checkbox: FC = ({ size = 'medium', children, ...otherProps }) => { return ( -