Use global variable for accent color
This commit is contained in:
parent
1acbf88bb4
commit
4463d8bdef
|
@ -15,6 +15,7 @@ import Settings from "./settingsmanager";
|
|||
import DataStore from "./datastore";
|
||||
import DiscordModules from "./discordmodules";
|
||||
|
||||
import IPC from "./ipc";
|
||||
import Editor from "./editor";
|
||||
import Updater from "./updater";
|
||||
|
||||
|
@ -86,6 +87,8 @@ export default new class Core {
|
|||
Modals.showChangelogModal(Changelog);
|
||||
DataStore.setBDData("version", Config.version);
|
||||
}
|
||||
|
||||
DOMManager.injectStyle("bd-os-values", `:root {--os-accent-color: ${await IPC.getSystemAccentColor()}}`);
|
||||
}
|
||||
|
||||
waitForConnection() {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import ipc from "./ipc";
|
||||
|
||||
export default class DOMManager {
|
||||
|
||||
/** Document/window width */
|
||||
|
@ -71,10 +69,10 @@ export default class DOMManager {
|
|||
if (exists) exists.remove();
|
||||
}
|
||||
|
||||
static async injectStyle(id, css) {
|
||||
static injectStyle(id, css) {
|
||||
id = this.escapeID(id);
|
||||
const style = this.getElement(`#${id}`, this.bdStyles) || this.createElement("style", {id});
|
||||
style.textContent = await this.insertCSSCustoms(css);
|
||||
style.textContent = css;
|
||||
this.bdStyles.append(style);
|
||||
}
|
||||
|
||||
|
@ -100,15 +98,15 @@ export default class DOMManager {
|
|||
if (exists) exists.remove();
|
||||
}
|
||||
|
||||
static async injectTheme(id, css) {
|
||||
static injectTheme(id, css) {
|
||||
id = this.escapeID(id);
|
||||
const style = this.getElement(`#${id}`, this.bdThemes) || this.createElement("style", {id});
|
||||
style.textContent = await this.insertCSSCustoms(css);
|
||||
style.textContent = css;
|
||||
this.bdThemes.append(style);
|
||||
}
|
||||
|
||||
static async updateCustomCSS(css) {
|
||||
this.bdCustomCSS.textContent = await this.insertCSSCustoms(css);
|
||||
static updateCustomCSS(css) {
|
||||
this.bdCustomCSS.textContent = css;
|
||||
}
|
||||
|
||||
static removeScript(id) {
|
||||
|
@ -128,18 +126,6 @@ export default class DOMManager {
|
|||
});
|
||||
}
|
||||
|
||||
static async insertCSSCustoms(string) {
|
||||
const customValues = {
|
||||
"-bd-accent-color": `#${await ipc.getSystemAccentColor()}`,
|
||||
};
|
||||
|
||||
for (const [key, value] of Object.entries(customValues)) {
|
||||
string = string.replaceAll(key, value);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
// https://javascript.info/js-animation
|
||||
static animate({timing = _ => _, update, duration}) {
|
||||
const start = performance.now();
|
||||
|
|
Loading…
Reference in New Issue