mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
27 lines
892 B
TypeScript
27 lines
892 B
TypeScript
import type { CustomImage, CustomTheme } from '@/old-interface/types/CustomThemes';
|
|
import { settingsState } from '@/seqta/utils/listeners/SettingsState';
|
|
import { applyCustomCSS } from './Themes';
|
|
|
|
|
|
export const applyTheme = async (theme: CustomTheme, reEnable?: boolean) => {
|
|
let CustomCSS = '';
|
|
let CustomImages: CustomImage[] = [];
|
|
|
|
if (theme?.CustomCSS) CustomCSS = theme.CustomCSS;
|
|
if (theme?.CustomImages) CustomImages = theme.CustomImages;
|
|
if (theme?.forceDark != undefined) {
|
|
if (!reEnable) settingsState.originalDarkMode = settingsState.DarkMode
|
|
|
|
settingsState.DarkMode = theme.forceDark
|
|
}
|
|
|
|
// Apply custom CSS
|
|
applyCustomCSS(CustomCSS);
|
|
|
|
// Apply custom images
|
|
CustomImages.forEach((image) => {
|
|
const imageUrl = URL.createObjectURL(image.blob);
|
|
document.documentElement.style.setProperty('--' + image.variableName, `url(${imageUrl})`);
|
|
});
|
|
};
|