🐛(react) fix Radio, Checkbox fullWidth

The fullWidth was buggy for those components, the label was floating
in the middle of the empty space where it feels correct to keep it
aligned on the left.
This commit is contained in:
Nathan Vasse
2023-09-07 17:07:59 +02:00
committed by NathanVss
parent 9de9a9735d
commit 8fd34add8a
6 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@openfun/cunningham-react": patch
---
fix Radio, Checkbox fullWidth

View File

@@ -125,4 +125,12 @@
color: var(--c--theme--colors--greyscale-600);
}
}
&--full-width {
width: 100%;
.c__field {
align-items: flex-start;
}
}
}

View File

@@ -68,6 +68,17 @@ export const WithTexts = {
},
};
export const FullWidth = {
render: Template,
args: {
checked: true,
fullWidth: true,
label: "Label",
text: "This is an optional text",
},
};
export const Disabled = {
render: Template,

View File

@@ -37,6 +37,7 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
<label
className={classNames("c__checkbox", {
"c__checkbox--disabled": props.disabled,
"c__checkbox--full-width": props.fullWidth,
})}
>
<Field compact={true} {...props}>

View File

@@ -59,6 +59,17 @@ export const WithText = {
},
};
export const FullWidth = {
render: Template,
args: {
checked: true,
fullWidth: true,
label: "Label",
text: "This is an optional text",
},
};
export const Disabled = {
render: Template,

View File

@@ -17,6 +17,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>(
<label
className={classNames("c__checkbox", "c__radio", {
"c__checkbox--disabled": props.disabled,
"c__checkbox--full-width": props.fullWidth,
})}
>
<Field compact={true} {...props}>