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 = [
|
||||
{
|
||||
id: 'pride',
|
||||
@ -59,6 +60,11 @@ const makeLinearGradientSvg = (id, colors, opacity, transform) => {
|
||||
</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 => {
|
||||
const svg_html = makeLinearGradientSvg(flag.id, flag.colors, flag.opacity ?? '0.8', flag.transform ?? 'rotate(0)');
|
||||
const container = document.createElement('div');
|
||||
@ -85,12 +91,10 @@ fetch(OC.generateUrl('/apps/pride_flags/settings'))
|
||||
document.head.prepend(node);
|
||||
}
|
||||
const style_settings = document.querySelector('head > style#pride_flag_settings');
|
||||
style_settings.textContent = `
|
||||
body {
|
||||
--image-background-pride-button: var(--image-background-pride-${buttonVariant});
|
||||
--image-background-pride-folder: var(--image-background-pride-${folderVariant});
|
||||
--image-background-pride-button-gradient: var(--image-background-pride-gradient-${buttonVariant});
|
||||
--image-background-pride-folder-gradient: var(--image-background-pride-gradient-${folderVariant});
|
||||
}
|
||||
`;
|
||||
const rules = `body {
|
||||
${(folderVariant !== 'none') ? generateCssBackgroundRules('folder', folderVariant) : ''}
|
||||
${(buttonVariant !== 'none') ? generateCssBackgroundRules('button', buttonVariant) : ''}
|
||||
}`;
|
||||
style_settings.textContent = rules;
|
||||
});
|
||||
})(window);
|
||||
|
Loading…
x
Reference in New Issue
Block a user