Skip to content

Commit

Permalink
feat(checkbox): adjust spacing and add more stories
Browse files Browse the repository at this point in the history
  • Loading branch information
anitavincent committed Nov 21, 2023
1 parent 8e0ea11 commit e18e2b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/components/src/checkbox/checkbox-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const CheckboxGroup = forwardRef<HTMLInputElement, CheckboxGroupProps>(
} = props

const id = useId(defaultId)
const stackGap = direction === 'column' ? '$space-4' : '$space-5'

return (
<Field
Expand All @@ -30,7 +31,9 @@ export const CheckboxGroup = forwardRef<HTMLInputElement, CheckboxGroupProps>(
{...otherProps}
>
<FieldLabel htmlFor={id}>{label}</FieldLabel>
<Stack direction={direction}>{children}</Stack>
<Stack direction={direction} space={stackGap}>
{children}
</Stack>
<FieldMessage error={error} helpText={helpText} errorText={errorText} />
</Field>
)
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/checkbox/stories/checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export function AsField() {
<CheckboxField helpText="By clicking you agree with terms and conditions">
Terms and conditions
</CheckboxField>
<CheckboxField
helpText="By clicking you agree with terms and conditions"
errorText="Something wrong"
error
>
Terms and conditions
</CheckboxField>
<CheckboxField defaultChecked disabled>
Disabled
</CheckboxField>
Expand Down Expand Up @@ -91,6 +98,14 @@ export function Group() {
<Checkbox>All at once</Checkbox>
<Checkbox disabled>None</Checkbox>
</CheckboxGroup>
<CheckboxGroup error label="Options" errorText="Bad choice">
<Checkbox error>Everything</Checkbox>
<Checkbox error>Everywhere</Checkbox>
<Checkbox error>All at once</Checkbox>
<Checkbox error disabled>
None
</Checkbox>
</CheckboxGroup>
<CheckboxGroup
error
label={
Expand All @@ -99,6 +114,7 @@ export function Group() {
<IconInfoFill />
</>
}
helpText="Choose one of these"
errorText="Bad choice"
>
<Checkbox error>Everything</Checkbox>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/field/field.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[data-sl-field][data-variant='control'] {
--sl-element-template-areas: 'input label' '- message';
--sl-element-label-color: var(--sl-fg);
--sl-element-vertical-gap: var(--sl-space-0);
--sl-element-vertical-gap: calc(var(--sl-space-05) / 2);;
--sl-element-horizontal-gap: var(--sl-space-2);
}

Expand Down

0 comments on commit e18e2b4

Please sign in to comment.