From 1224e7c992053f366d75b58540024f574dd50be5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 3 Jun 2020 14:55:41 +0200 Subject: [PATCH] add url property for setting the theme --- apps/remix-ide/src/app/tabs/theme-module.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 0535941bad..4073b68c56 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -1,5 +1,6 @@ import { Plugin } from '@remixproject/engine' import { EventEmitter } from 'events' +import QueryParams from '../../lib/query-params' import * as packageJson from '../../../package.json' import yo from 'yo-yo' @@ -38,7 +39,9 @@ export class ThemeModule extends Plugin { config: registry.get('config').api } this.themes = themes.reduce((acc, theme) => ({ ...acc, [theme.name]: theme }), {}) - this.active = this._deps.config.get('settings/theme') ? this._deps.config.get('settings/theme') : 'Dark' + const theme = (new QueryParams()).get().theme + this.active = theme || this._deps.config.get('settings/theme') || 'Dark' + this.forced = theme !== undefined } /** Return the active theme */ @@ -76,7 +79,7 @@ export class ThemeModule extends Plugin { } const next = themeName || this.active // Name const nextTheme = this.themes[next] // Theme - this._deps.config.set('settings/theme', next) + if (!this.forced) this._deps.config.set('settings/theme', next) document.getElementById('theme-link').setAttribute('href', nextTheme.url) document.documentElement.style.setProperty('--theme', nextTheme.quality) if (themeName) this.active = themeName