mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
* added storybook * added avatar component * added button story * added dropdown button story * removed unused ellipsis component * cleaned up modal path * reorganized enroll secrets table file * added flash story; removed unused persistent flash * added fleet ace story * added checkbox story * added dropdown story * added input story * fixed storybook build * fixed avatar * added input with icon story * added radio button story * added select targets dropdown story * added slider story * added tooltip story * added info banner story * removed unused loaders; added spinner story * added modal story * removed unused NumberPill * added pagination story * lint fixes * added documentation to run * modified documentation * fixed corelayout test * fixed format for date-fns * fixed date format that breaks tests * wait for page
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import React from "react";
|
|
import classnames from "classnames";
|
|
|
|
const baseClass = "radio";
|
|
|
|
export interface IRadioProps {
|
|
label: string;
|
|
value: string;
|
|
id: string;
|
|
onChange: (value: string) => void;
|
|
checked?: boolean;
|
|
name?: string;
|
|
className?: string;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
const Radio = ({
|
|
className,
|
|
id,
|
|
name,
|
|
value,
|
|
checked,
|
|
disabled,
|
|
label,
|
|
onChange,
|
|
}: IRadioProps): JSX.Element => {
|
|
const wrapperClasses = classnames(baseClass, className);
|
|
|
|
const radioControlClass = classnames({
|
|
[`disabled`]: disabled,
|
|
});
|
|
|
|
return (
|
|
<label htmlFor={id} className={`${wrapperClasses} ${radioControlClass}`}>
|
|
<span className={`${baseClass}__input`}>
|
|
<input
|
|
type="radio"
|
|
id={id}
|
|
disabled={disabled}
|
|
name={name}
|
|
value={value}
|
|
checked={checked}
|
|
onChange={(event) => onChange(event.target.value)}
|
|
/>
|
|
<span className={`${baseClass}__control`} />
|
|
</span>
|
|
<span className={`${baseClass}__label`}>{label}</span>
|
|
</label>
|
|
);
|
|
};
|
|
|
|
export default Radio;
|