@advdominion/css-var

This commit is contained in:
valentinsilyutin committed 2026-02-12 14:55:23 +04:00
1 parent a0074442ae
commit 8f2cae3401
4 files changed
+54

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
export const cssVar = (name, element = document.documentElement) => {
const value = window.getComputedStyle(element).getPropertyValue(name);
const durationRegExp = /(^[\d.]+)(ms|s)$/;
if (durationRegExp.test(value)) {
const [, numericValue, unit] = durationRegExp.exec(value);
return unit === 's' ? numericValue * 1000 : Number(numericValue);
}
return value;
};