| 1 |
const generateBgStyles = ({ controlName, attributes }) => { |
| 2 |
const { |
| 3 |
[`${controlName}bgType`]: bgType = 'classic', |
| 4 |
[`${controlName}bgColor`]: bgColor, |
| 5 |
[`${controlName}bgGradient`]: bgGradient |
| 6 |
} = attributes; |
| 7 |
|
| 8 |
let bgStyle; |
| 9 |
if (bgType === 'classic' && bgColor !== undefined && bgColor !== '') { |
| 10 |
bgStyle = bgColor |
| 11 |
? `background-color: ${bgColor}; |
| 12 |
` |
| 13 |
: ''; |
| 14 |
} else if (bgType === 'gradient' && bgGradient !== undefined && bgGradient !== '') { |
| 15 |
bgStyle = bgGradient |
| 16 |
? `background-image: ${bgGradient}; |
| 17 |
` |
| 18 |
: ''; |
| 19 |
} else { |
| 20 |
bgStyle = ''; |
| 21 |
} |
| 22 |
|
| 23 |
return { |
| 24 |
bgStyle |
| 25 |
}; |
| 26 |
}; |
| 27 |
|
| 28 |
export default generateBgStyles; |
| 29 |
|