separate thems into separate files

This commit is contained in:
SethBurkart123
2024-04-05 09:36:59 +11:00
parent 38c31b88e6
commit f1346ab86e
15 changed files with 340 additions and 295 deletions
+28
View File
@@ -0,0 +1,28 @@
import browser from 'webextension-polyfill';
import { CustomImage, CustomTheme } from '../../../interface/types/CustomThemes';
import { applyCustomCSS } from './Themes';
export const applyTheme = async (theme: CustomTheme) => {
let CustomCSS = '';
let CustomImages: CustomImage[] = [];
let defaultColour = '';
if (theme?.CustomCSS) CustomCSS = theme.CustomCSS;
if (theme?.CustomImages) CustomImages = theme.CustomImages;
if (theme?.defaultColour) defaultColour = theme.defaultColour;
// Apply custom CSS
applyCustomCSS(CustomCSS);
// Apply default color
if (defaultColour !== '') {
browser.storage.local.set({ selectedColor: defaultColour });
}
// Apply custom images
CustomImages.forEach((image) => {
const imageUrl = URL.createObjectURL(image.blob);
document.documentElement.style.setProperty('--' + image.variableName, `url(${imageUrl})`);
});
};