♻️(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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user