Skip to content

Commit

Permalink
fix(checkbox): make checkbox sizes variants match ui kit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Lee committed Aug 24, 2022
1 parent f56bdc4 commit 5c5d663
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 65 deletions.
20 changes: 10 additions & 10 deletions src/components/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export const Checked: StoryObj<Args> = {
render: (args) => <CheckboxExample {...args} checked={true} />,
};

export const Small: StoryObj<Args> = {
render: (args) => <CheckboxExample {...args} size="sm" />,
export const Medium: StoryObj<Args> = {
render: (args) => <CheckboxExample {...args} size="md" />,
};

export const SmallChecked: StoryObj<Args> = {
render: (args) => <CheckboxExample {...args} checked={true} size="sm" />,
export const MediumChecked: StoryObj<Args> = {
render: (args) => <CheckboxExample {...args} checked={true} size="md" />,
};

export const Indeterminate: StoryObj<Args> = {
Expand Down Expand Up @@ -122,9 +122,9 @@ export const LongLabels = {
return (
<div className={styles['longlabels--grid']}>
<Checkbox label={label} readOnly />
<Checkbox label={label} readOnly size="sm" />
<Checkbox label={label} readOnly size="md" />
<Checkbox disabled label={label} />
<Checkbox disabled label={label} size="sm" />
<Checkbox disabled label={label} size="md" />
</div>
);
},
Expand All @@ -144,7 +144,7 @@ export const LabelsOnly: StoryObj = {
<CheckboxLabel
htmlFor="sm-label"
{...args}
size="sm"
size="md"
text="Small label"
/>
<br />
Expand All @@ -157,7 +157,7 @@ export const LabelsOnly: StoryObj = {
<CheckboxLabel
{...args}
htmlFor="long-sm-label"
size="sm"
size="md"
text="Long small label lorem ipsum dolor sit amet, consectetur adipiscing elit"
/>
<br />
Expand All @@ -172,7 +172,7 @@ export const LabelsOnly: StoryObj = {
{...args}
disabled
htmlFor="sm-disabled-label"
size="sm"
size="md"
text="Small disabled"
/>
<br />
Expand All @@ -187,7 +187,7 @@ export const LabelsOnly: StoryObj = {
{...args}
disabled
htmlFor="long-sm-disabled-label"
size="sm"
size="md"
text="Long small disabled label lorem ipsum dolor sit amet, consectetur adipiscing elit"
/>
</>
Expand Down
8 changes: 2 additions & 6 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type CheckboxProps = Omit<CheckboxInputProps, 'id'> & {
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
(props, ref) => {
// All remaining props are passed to the `input` element
const { className, id, label, size = 'md', disabled, ...other } = props;
const { className, id, label, size = 'lg', disabled, ...other } = props;

// When possible, use a visible label through the `label` prop instead.
// In rare cases where there's no visible label, you must provide an
Expand All @@ -59,11 +59,7 @@ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
const generatedId = useUID();
const checkboxId = id || generatedId;

const componentClassName = clsx(
styles['checkbox'],
styles[`checkbox--${size}`],
className,
);
const componentClassName = clsx(styles['checkbox'], className);

return (
<div className={componentClassName}>
Expand Down
Loading

0 comments on commit 5c5d663

Please sign in to comment.