Merge things

This commit is contained in:
David Ralph
2020-11-03 19:15:28 +00:00
10 changed files with 199 additions and 42 deletions

View File

@@ -6,9 +6,9 @@ export default class Background extends React.PureComponent {
const { type, angle, gradient } = gradientSettings;
let style = `background: ${gradient[0].colour};`;
if (gradient.length > 1) {
//Note: Append the gradient for additional browser support.
// Note: Append the gradient for additional browser support.
const stepStyles = gradient.map(g => ` ${g.colour} ${g.stop}%`).join();
style += ` background: ${type}-gradient(${angle}deg,${stepStyles})`;
style += ` background: ${type}-gradient(${(type === 'linear' ? (`${angle}deg,`) : '')}${stepStyles})`;
}
return style;
}
@@ -20,7 +20,7 @@ export default class Background extends React.PureComponent {
} catch (e) {
const hexColorRegex = /#[0-9a-fA-F]{6}/s;
if (hexColorRegex.exec(colour)) {
//colour use to be simply a hex colour or a NULL value before it was a JSON object. This automatically upgrades the hex colour value to the new standard. (NULL would not trigger an exception)
// Colour use to be simply a hex colour or a NULL value before it was a JSON object. This automatically upgrades the hex colour value to the new standard. (NULL would not trigger an exception)
gradientSettings = { "type": "linear", "angle": "180", "gradient": [{ "colour": colour, "stop": 0 }] };
localStorage.setItem('customBackgroundColour', JSON.stringify(gradientSettings));
}