Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/landing/ui/field/color/src/internal/ |
Upload File : |
const matcher = /^(var\()?((--[\w\d-]*?)(-opacity_([\d_]+)?)?)\)?$/i; export function isCssVar(css: string): boolean { return !!css.trim().match(matcher); } type cssVar = { full: string, name: string, opacity: number, }; export function parseCssVar(css: string): ?cssVar { const matches = css.trim().match(matcher); if (!!matches) { const cssVar = { full: matches[2], name: matches[3], }; if (matches[3]) { const cssVarWithOpacity = '--primary-opacity-0_'; const cssVarWithOpacity0 = '--primary-opacity-0'; if (matches[3].startsWith(cssVarWithOpacity0) && !matches[3].startsWith(cssVarWithOpacity)) { cssVar.opacity = 0; } if (matches[3].startsWith(cssVarWithOpacity)) { let newOpacity = matches[3].substr(cssVarWithOpacity.length); if (newOpacity.length === 1 && newOpacity !== 0) { newOpacity = newOpacity / 10; } if (newOpacity.length === 2) { newOpacity = newOpacity / 100; } cssVar.opacity = newOpacity; } } if(matches[5]) { cssVar.opacity = +parseFloat(matches[5].replace('_', '.')).toFixed(1); } return cssVar; } return null; }