♻️(react) improve props propagation

Before we had to edit input components using Field when adding new props
to the latter.
This commit is contained in:
Nathan Vasse
2023-08-30 11:40:35 +02:00
committed by NathanVss
parent b530e966ae
commit 051c79fd6f
5 changed files with 16 additions and 84 deletions

View File

@@ -9,18 +9,7 @@ export type SwitchProps = InputHTMLAttributes<HTMLInputElement> &
};
export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
(
{
label,
text,
textItems,
state,
fullWidth,
labelSide = "left",
...props
}: SwitchProps,
ref,
) => {
({ label, labelSide = "left", ...props }: SwitchProps, ref) => {
return (
<label
className={classNames(
@@ -29,17 +18,11 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
"c__switch--" + labelSide,
{
"c__checkbox--disabled": props.disabled,
"c__switch--full-width": fullWidth,
"c__switch--full-width": props.fullWidth,
},
)}
>
<Field
text={text}
textItems={textItems}
compact={true}
state={state}
fullWidth={fullWidth}
>
<Field compact={true} {...props}>
<div className="c__checkbox__container">
{label && <div className="c__checkbox__label">{label}</div>}
<div className="c__switch__rail__wrapper">