diff --git a/lib/components/CheckboxButtons/CheckboxButtons.css.ts b/lib/components/CheckboxButtons/CheckboxButtons.css.ts index b07d23229..3ddd4cb91 100644 --- a/lib/components/CheckboxButtons/CheckboxButtons.css.ts +++ b/lib/components/CheckboxButtons/CheckboxButtons.css.ts @@ -1,9 +1,12 @@ +import { style } from '@vanilla-extract/css'; import { recipe } from '@vanilla-extract/recipes'; +import { tokens } from 'lib/themes/base/tokens'; + import { odStyle, type ODStyle } from '../../styles/sprinkles.css'; const border: ODStyle = { - borderColor: 'light', + borderColor: 'gray', borderStyle: 'solid', borderWidth: '1', }; @@ -15,32 +18,70 @@ const focusOutline: ODStyle = { outlineWidth: { initial: 'none', focusVisible: 'default' }, }; +const buttonBorderRadius = tokens.border.radius['2']; + export const checkboxButton = recipe({ base: [ odStyle({ - background: { initial: 'gray100', hover: 'gray300' }, + background: { + initial: 'white', + hover: 'gray100', + }, ...border, - borderRadius: '2', cursor: { hover: 'pointer' }, display: 'flex', gap: '2', - padding: '2', + paddingX: '4', + paddingY: '3', width: '100%', }), + style({ + selectors: { + ['&+&']: { + borderTopStyle: 'none', + }, + ['&:first-child']: { + borderTopLeftRadius: buttonBorderRadius, + borderTopRightRadius: buttonBorderRadius, + }, + ['&:last-child']: { + borderBottomLeftRadius: buttonBorderRadius, + borderBottomRightRadius: buttonBorderRadius, + }, + }, + }), ], + variants: { + disabled: { + true: style({ + opacity: 0.6, + selectors: { + ['&&']: { + background: 'none', + cursor: 'default', + }, + }, + }), + }, + }, }); export const checkbox = recipe({ base: odStyle({ - size: '6', + alignItems: 'center', ...border, borderRadius: '1', + display: 'flex', + flexShrink: 0, + justifyContent: 'center', ...focusOutline, + size: '6', }), variants: { checked: { true: odStyle({ - background: 'blue800', + background: 'gray900', + borderColor: 'dark', }), false: odStyle({ background: 'white', @@ -51,3 +92,11 @@ export const checkbox = recipe({ }, }, }); + +export const groupLabel = recipe({ + base: odStyle({ + font: 'xxl', + fontWeight: 'bold', + marginBottom: '6', + }), +}); diff --git a/lib/components/CheckboxButtons/CheckboxButtons.stories.tsx b/lib/components/CheckboxButtons/CheckboxButtons.stories.tsx index 6e4b5862e..316a04f02 100644 --- a/lib/components/CheckboxButtons/CheckboxButtons.stories.tsx +++ b/lib/components/CheckboxButtons/CheckboxButtons.stories.tsx @@ -15,7 +15,7 @@ const meta: Meta = { title: 'Components/Checkbox Buttons', component: CheckboxButtons, args: { - label: 'Add something extra', + label: 'Commonly requested extras', children: itemData.map((item, idx) => ( {item[0]} @@ -43,8 +43,8 @@ export const Simple: Story = {}; /** * To acheive the the split-column layout in the checkbox label, use a CheckboxButtons.SplitLabel layout helper - * inside the CheckboxButtons.Item component. Populate the `items` prop on the SplitLabel with a string array - * (content left, content right). + * inside the CheckboxButtons.Item component. Currently supports text only. Populate the `items` prop on the SplitLabel + * with a string array (content left, content right). */ export const SplitLabel: Story = { args: { @@ -55,3 +55,10 @@ export const SplitLabel: Story = { )), }, }; + +export const Disabled: Story = { + args: { + ...SplitLabel.args, + isDisabled: true, + }, +}; diff --git a/lib/components/CheckboxButtons/CheckboxButtons.tsx b/lib/components/CheckboxButtons/CheckboxButtons.tsx index 8c0be741b..ea99c518a 100644 --- a/lib/components/CheckboxButtons/CheckboxButtons.tsx +++ b/lib/components/CheckboxButtons/CheckboxButtons.tsx @@ -2,6 +2,7 @@ import React, { createContext } from 'react'; import { useCheckboxGroup, type AriaCheckboxGroupProps } from 'react-aria'; import { type CheckboxGroupState, useCheckboxGroupState } from 'react-stately'; +import { groupLabel } from './CheckboxButtons.css'; import { CheckboxItem, SplitLabel } from './CheckboxItem'; export interface CheckboxButtonsProps extends AriaCheckboxGroupProps { @@ -43,9 +44,11 @@ export const CheckboxButtons = (props: CheckboxButtonsProps) => { return (
- {label} +
+ {label} +
- {children} +
{children}
{description &&
{description}
}
diff --git a/lib/components/CheckboxButtons/CheckboxItem.tsx b/lib/components/CheckboxButtons/CheckboxItem.tsx index 74f7c1c3d..eda6835be 100644 --- a/lib/components/CheckboxButtons/CheckboxItem.tsx +++ b/lib/components/CheckboxButtons/CheckboxItem.tsx @@ -3,11 +3,11 @@ import { useCheckboxGroupItem, useFocusRing, mergeProps, - VisuallyHidden, type AriaCheckboxGroupItemProps, } from 'react-aria'; import { odStyle } from '../../styles/sprinkles.css'; +import { VisuallyHidden } from '../VisuallyHidden'; import { CheckboxButtonsContext } from './CheckboxButtons'; import { checkbox, checkboxButton } from './CheckboxButtons.css'; @@ -43,10 +43,11 @@ export const CheckboxItem = (props: FilteredCheckboxProps) => { const state = useContext(CheckboxButtonsContext)!; const { inputProps } = useCheckboxGroupItem(props, state, ref); const { isFocusVisible, focusProps } = useFocusRing(); + const isDisabled = state.isDisabled; const isSelected = state.isSelected(props.value); return ( -