PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.3
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.3
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
sureforms / src / srfm-controls / maybeGetColorForVariable.js
maybeGetColorForVariable.js
24 lines 666 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const maybeGetColorForVariable = ( color ) => {
2 // This external condition handles the following color format:
3 // `var(--paletteColor7)`
4 if ( color && color.includes( 'var' ) ) {
5 const style = window.getComputedStyle( document.body );
6
7 // Slice off `var(` and the slice off the `)` bracket at the end.
8 color = color.slice( 4 ).slice( 0, -1 );
9
10 // This nested condition handles the following color format:
11 // `var(--paletteColor7, #FBFBFB)`
12 if ( color.includes( ',' ) ) {
13 color = color.split( ',' ).pop().trim();
14
15 return color;
16 }
17
18 color = style.getPropertyValue( color ).trim();
19 }
20 return color;
21 };
22
23 export default maybeGetColorForVariable;
24