feat: add support for loading custom themes from files (#2218)

* feat: add support for loading custom themes from files

---------

Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
Louis Dalibard
2026-07-19 04:27:09 +02:00
committed by GitHub
parent 2cab569c23
commit f152e03ae7
14 changed files with 1018 additions and 30 deletions
+42
View File
@@ -0,0 +1,42 @@
import { ipcRenderer } from 'electron';
export interface CustomTheme {
app?: Record<string, unknown>;
colors?: Record<string, unknown>;
error?: string;
extends?: string;
filename: string;
id: string;
label: string;
mantineOverride?: Record<string, unknown>;
mode: 'dark' | 'light';
stylesheetContents?: string[];
warnings?: string[];
}
const get = async (): Promise<CustomTheme[]> => {
return ipcRenderer.invoke('custom-themes-get');
};
const reload = async (): Promise<CustomTheme[]> => {
return ipcRenderer.invoke('custom-themes-reload');
};
const openFolder = async (): Promise<boolean> => {
return ipcRenderer.invoke('custom-themes-open-folder');
};
const onUpdate = (cb: (themes: CustomTheme[]) => void) => {
const listener = (_event: Electron.IpcRendererEvent, themes: CustomTheme[]) => cb(themes);
ipcRenderer.on('custom-themes-updated', listener);
return () => ipcRenderer.removeListener('custom-themes-updated', listener);
};
export const customThemes = {
get,
onUpdate,
openFolder,
reload,
};
export type CustomThemes = typeof customThemes;
+2
View File
@@ -2,6 +2,7 @@ import { contextBridge, webUtils } from 'electron';
import { autodiscover } from './autodiscover';
import { browser } from './browser';
import { customThemes } from './custom-themes';
import { discordRpc } from './discord-rpc';
import { ipc } from './ipc';
import { localSettings } from './local-settings';
@@ -16,6 +17,7 @@ import { visualizer } from './visualizer';
const api = {
autodiscover,
browser,
customThemes,
discordRpc,
getPathForFile: webUtils.getPathForFile,
ipc,