Files
modeling-app/src/components/Toggle/Toggle.tsx
Frank Noirot 48f1d5e623 Add unit setting (#183)
* Add Toggle component

* Add default units to settings

* Add defaultBaseUnit, shorten settings names

* Make debug panel use Toggle, fix colors

* add eslint-plugin-css-modules
2023-07-21 12:48:23 -04:00

35 lines
639 B
TypeScript

import styles from './Toggle.module.css'
interface ToggleProps {
className?: string
offLabel?: string
onLabel?: string
name: string
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
checked: boolean
}
export const Toggle = ({
className = '',
offLabel = 'Off',
onLabel = 'On',
name = '',
onChange,
checked,
}: ToggleProps) => {
return (
<label className={`${styles.toggle} ${className}`}>
{offLabel}
<input
type="checkbox"
name={name}
id={name}
checked={checked}
onChange={onChange}
/>
<span></span>
{onLabel}
</label>
)
}