refactor(javascript): wrap in IIFE, rebuild to respect none-variant
This commit is contained in:
parent
744077f0fd
commit
9f6ef213a3
20
js/pride.js
20
js/pride.js
@ -1,3 +1,4 @@
|
|||||||
|
(function(window) {
|
||||||
const flags = [
|
const flags = [
|
||||||
{
|
{
|
||||||
id: 'pride',
|
id: 'pride',
|
||||||
@ -59,6 +60,11 @@ const makeLinearGradientSvg = (id, colors, opacity, transform) => {
|
|||||||
</svg>`;
|
</svg>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const generateCssBackgroundRules = (type, variant) => `
|
||||||
|
--image-background-pride-${type}: var(--image-background-pride-${variant});
|
||||||
|
--image-background-pride-${type}-gradient: var(--image-background-pride-gradient-${variant});
|
||||||
|
`;
|
||||||
|
|
||||||
flags.forEach(flag => {
|
flags.forEach(flag => {
|
||||||
const svg_html = makeLinearGradientSvg(flag.id, flag.colors, flag.opacity ?? '0.8', flag.transform ?? 'rotate(0)');
|
const svg_html = makeLinearGradientSvg(flag.id, flag.colors, flag.opacity ?? '0.8', flag.transform ?? 'rotate(0)');
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
@ -85,12 +91,10 @@ fetch(OC.generateUrl('/apps/pride_flags/settings'))
|
|||||||
document.head.prepend(node);
|
document.head.prepend(node);
|
||||||
}
|
}
|
||||||
const style_settings = document.querySelector('head > style#pride_flag_settings');
|
const style_settings = document.querySelector('head > style#pride_flag_settings');
|
||||||
style_settings.textContent = `
|
const rules = `body {
|
||||||
body {
|
${(folderVariant !== 'none') ? generateCssBackgroundRules('folder', folderVariant) : ''}
|
||||||
--image-background-pride-button: var(--image-background-pride-${buttonVariant});
|
${(buttonVariant !== 'none') ? generateCssBackgroundRules('button', buttonVariant) : ''}
|
||||||
--image-background-pride-folder: var(--image-background-pride-${folderVariant});
|
}`;
|
||||||
--image-background-pride-button-gradient: var(--image-background-pride-gradient-${buttonVariant});
|
style_settings.textContent = rules;
|
||||||
--image-background-pride-folder-gradient: var(--image-background-pride-gradient-${folderVariant});
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
});
|
});
|
||||||
|
})(window);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user