(react) add Radio component

Implement Radio input based on designed sketches.
This commit is contained in:
Nathan Vasse
2023-04-20 14:58:06 +02:00
committed by NathanVss
parent 43096e2bab
commit f5cb2e791e
14 changed files with 727 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
import React, { InputHTMLAttributes, PropsWithChildren } from "react";
import classNames from "classnames";
import { Field, FieldProps } from "components/Forms/Field";
type Props = InputHTMLAttributes<HTMLInputElement> &
FieldProps & {
label?: string;
};
export const Radio = ({ label, text, state, ...props }: Props) => {
return (
<label
className={classNames("c__checkbox", "c__radio", {
"c__checkbox--disabled": props.disabled,
})}
>
<Field text={text} compact={true} state={state}>
<div className="c__checkbox__container">
<input type="radio" {...props} />
{label && <div className="c__checkbox__label">{label}</div>}
</div>
</Field>
</label>
);
};
export const RadioGroup = ({
children,
state,
text,
rightText,
}: PropsWithChildren & FieldProps) => {
return (
<Field
className="c__radio__group c__checkbox__group"
state={state}
text={text}
rightText={rightText}
compact={true}
>
<div className="c__checkbox__group__list">{children}</div>
</Field>
);
};