better typecheck for them input

This commit is contained in:
Jon McClure 2023-07-11 17:00:48 +01:00
parent 32183b9758
commit b301a37e7d

View file

@ -5,7 +5,7 @@ import ColourPicker from './ColourPicker.jsx';
const Input = ({ value, onChange }) => {
// Number type
if (!isNaN(value)) return <input type="number" value={value} onChange={(e) => onChange(Number(e.target.value))}/>;
if ((value || value === 0) && !isNaN(value)) return <input type="number" value={value} onChange={(e) => onChange(Number(e.target.value))}/>;
// Colour type
if (!/var\(.*\)/i.test(value) && CSS.supports('color', value)) return (
<ColourPicker colour={value} onChange={onChange} />