Skip to content
Snippets Groups Projects
Commit 6747c4aa authored by Eryk Mika's avatar Eryk Mika
Browse files

fix: support for floats

parent 240f8714
No related branches found
No related tags found
1 merge request!2Devel
......@@ -14,19 +14,21 @@ export default function NumberWithUnit({
const splitValues = function (fontSize) {
if (!fontSize) {
return {size: "0", unit: "px"};
return { size: "0", unit: "px" };
}
const match = fontSize.match(/^(\d+)([a-z%]+)$/i);
const match = fontSize.match(/^(\d*\.?\d+)([a-z%]+)$/i);
if (!match) {
return {size: "16", unit: "px"};
return { size: "16", unit: "px" };
}
return {
size: match[1],
unit: match[2]
};
}
};
const [unit, setUnit] = useState(splitValues(value).unit);
const [size, setSize] = useState(splitValues(value).size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment