Skip to content
Snippets Groups Projects

Devel

Merged Eryk Mika requested to merge devel into main
1 file
+ 6
4
Compare changes
  • Side-by-side
  • Inline
@@ -14,19 +14,21 @@ export default function NumberWithUnit({
@@ -14,19 +14,21 @@ export default function NumberWithUnit({
const splitValues = function (fontSize) {
const splitValues = function (fontSize) {
if (!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) {
if (!match) {
return {size: "16", unit: "px"};
return { size: "16", unit: "px" };
}
}
 
return {
return {
size: match[1],
size: match[1],
unit: match[2]
unit: match[2]
};
};
}
};
 
const [unit, setUnit] = useState(splitValues(value).unit);
const [unit, setUnit] = useState(splitValues(value).unit);
const [size, setSize] = useState(splitValues(value).size);
const [size, setSize] = useState(splitValues(value).size);
Loading