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
This commit is contained in:
Frank Noirot
2023-07-21 12:48:23 -04:00
committed by GitHub
parent 87aecf7f50
commit 48f1d5e623
9 changed files with 170 additions and 15 deletions

View File

@ -0,0 +1,34 @@
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>
)
}