Can someone help me convert the linear-gradient
value into an object
with keys and values?
Here is the initial value:
linear-gradient(10deg,#111,rgba(111,111,11,0.4),rgba(255,255,25,0.1))
I would like it to be structured like this:
linear-gradient: {
angle: '10deg',
color1: '#111',
color2: 'rgba(111,11,11,0.4)',
color3: 'rgba(255,255,25,0.1)',
}
UPDATE: Unfortunately, my attempt at coding did not work as expected:
var str = 'linear-gradient(10deg,#111,rgba(111,111,11,0.4),rgba(255,255,25,0.1)';
str = str.match("gradient\((.*)\)");
str = str[1].split(',');
console.log( str );