diff --git a/packages/frosted-ui/.storybook/stories/components/checkbox.stories.tsx b/packages/frosted-ui/.storybook/stories/components/checkbox.stories.tsx index 45918f38..a9961b82 100644 --- a/packages/frosted-ui/.storybook/stories/components/checkbox.stories.tsx +++ b/packages/frosted-ui/.storybook/stories/components/checkbox.stories.tsx @@ -29,21 +29,43 @@ export const Default: Story = { }, render: (args) => ( - {/* TODO: text size matching checkbox size */} + + Default + + + Disabled checked + + + Disabled unchecked + + + ), +}; + +export const Composed: Story = { + args: { + size: checkboxPropDefs.size.default, + color: checkboxPropDefs.color.default, + highContrast: checkboxPropDefs.highContrast.default, + }, + render: (args) => ( + - Default + + Default - Disabled checked + + Disabled checked - Disabled - unchecked + + Disabled unchecked diff --git a/packages/frosted-ui/.storybook/stories/components/radio-group.stories.tsx b/packages/frosted-ui/.storybook/stories/components/radio-group.stories.tsx index 703ac7ae..f7474a7a 100644 --- a/packages/frosted-ui/.storybook/stories/components/radio-group.stories.tsx +++ b/packages/frosted-ui/.storybook/stories/components/radio-group.stories.tsx @@ -24,6 +24,24 @@ type Story = StoryObj; // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args export const Default: Story = { + args: { + size: radioGroupPropDefs.size.default, + color: radioGroupPropDefs.color.default, + variant: radioGroupPropDefs.variant.default, + highContrast: radioGroupPropDefs.highContrast.default, + }, + render: (args) => ( + + + Default + Comfortable + Compact + + + ), +}; + +export const Composed: Story = { args: { size: radioGroupPropDefs.size.default, color: radioGroupPropDefs.color.default, diff --git a/packages/frosted-ui/src/components/checkbox.css b/packages/frosted-ui/src/components/checkbox.css index 6295df8c..ddfc3563 100644 --- a/packages/frosted-ui/src/components/checkbox.css +++ b/packages/frosted-ui/src/components/checkbox.css @@ -86,8 +86,13 @@ @breakpoints { .fui-CheckboxRoot { + user-select: none; &:where(.fui-r-size-1) { --checkbox-size: var(--space-4); + gap: var(--space-2); + font-size: var(--font-size-2); + line-height: var(--line-height-2); + letter-spacing: var(--letter-spacing-2); & :where(.fui-CheckboxButton) { border-radius: var(--radius-2); @@ -100,6 +105,10 @@ } &:where(.fui-r-size-2) { --checkbox-size: calc(var(--space-4) * 1.25); + gap: var(--space-2); + font-size: var(--font-size-3); + line-height: var(--line-height-3); + letter-spacing: var(--letter-spacing-3); & :where(.fui-CheckboxButton) { border-radius: var(--radius-3); @@ -112,6 +121,10 @@ } &:where(.fui-r-size-3) { --checkbox-size: var(--space-5); + gap: var(--space-3); + font-size: var(--font-size-4); + line-height: var(--line-height-4); + letter-spacing: var(--letter-spacing-4); & :where(.fui-CheckboxButton) { border-radius: var(--radius-3); diff --git a/packages/frosted-ui/src/components/checkbox.tsx b/packages/frosted-ui/src/components/checkbox.tsx index 0c2c492d..e085a4dd 100644 --- a/packages/frosted-ui/src/components/checkbox.tsx +++ b/packages/frosted-ui/src/components/checkbox.tsx @@ -96,16 +96,14 @@ CheckboxCheckmarkIcon.displayName = 'CheckboxCheckmarkIcon'; type CheckboxElement = React.ElementRef; type CheckboxOwnProps = GetPropDefTypes; interface CheckboxProps - extends Omit< - PropsWithoutRefOrColor, - 'children' - >, + extends PropsWithoutRefOrColor, MarginProps, CheckboxOwnProps {} const Checkbox = React.forwardRef( (props, forwardedRef) => { const { rest: marginRest, ...marginProps } = extractMarginProps(props); const { + children, className, style, size = checkboxPropDefs.size.default, @@ -113,8 +111,11 @@ const Checkbox = React.forwardRef( highContrast = checkboxPropDefs.highContrast.default, ...checkboxProps } = marginRest; + + const Comp = children ? 'label' : 'span'; + return ( - ( /> - + + {children} + ); }, ); diff --git a/packages/frosted-ui/src/components/radio-group.css b/packages/frosted-ui/src/components/radio-group.css index 7c50755e..c06b70ea 100644 --- a/packages/frosted-ui/src/components/radio-group.css +++ b/packages/frosted-ui/src/components/radio-group.css @@ -4,6 +4,10 @@ vertical-align: top; flex-shrink: 0; height: var(--line-height, var(--radio-group-item-size)); + gap: var(--gap); + font-size: var(--font-size); + line-height: var(--line-height); + letter-spacing: var(--letter-spacing); } .fui-RadioGroupButton { @@ -40,12 +44,24 @@ @breakpoints { .fui-RadioGroupRoot { &:where(.fui-r-size-1) { + --gap: var(--space-2); + --font-size: var(--font-size-2); + --line-height: var(--line-height-2); + --letter-spacing: var(--letter-spacing-2); --radio-group-item-size: calc(var(--space-4) * 0.875); } &:where(.fui-r-size-2) { + --gap: var(--space-2); + --font-size: var(--font-size-3); + --line-height: var(--line-height-3); + --letter-spacing: var(--letter-spacing-3); --radio-group-item-size: var(--space-4); } &:where(.fui-r-size-3) { + --gap: var(--space-3); + --font-size: var(--font-size-4); + --line-height: var(--line-height-4); + --letter-spacing: var(--letter-spacing-4); --radio-group-item-size: calc(var(--space-4) * 1.25); } } diff --git a/packages/frosted-ui/src/components/radio-group.tsx b/packages/frosted-ui/src/components/radio-group.tsx index d0420f17..c0b8d0fb 100644 --- a/packages/frosted-ui/src/components/radio-group.tsx +++ b/packages/frosted-ui/src/components/radio-group.tsx @@ -54,19 +54,19 @@ RadioGroupRoot.displayName = 'RadioGroupRoot'; type RadioGroupItemElement = React.ElementRef; interface RadioGroupItemProps - extends Omit< - React.ComponentPropsWithoutRef, - 'children' - >, + extends React.ComponentPropsWithoutRef, MarginProps {} const RadioGroupItem = React.forwardRef< RadioGroupItemElement, RadioGroupItemProps >((props, forwardedRef) => { const { rest: marginRest, ...marginProps } = extractMarginProps(props); - const { className, style, ...itemProps } = marginRest; + const { children, className, style, ...itemProps } = marginRest; + + const Comp = children ? 'label' : 'span'; + return ( - - + {children} + ); }); RadioGroupItem.displayName = 'RadioGroupItem';