improve theme selection + bug fixes

This commit is contained in:
SethBurkart123
2024-05-29 08:01:44 +10:00
parent 4e5a912cbb
commit 026033ad57
7 changed files with 64 additions and 26 deletions
-8
View File
@@ -1,4 +1,3 @@
import browser from 'webextension-polyfill';
import { CustomImage, CustomTheme } from '../../../interface/types/CustomThemes';
import { applyCustomCSS } from './Themes';
@@ -6,20 +5,13 @@ 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);