From ec0b192e58926acd732978ea0a59c00491d4ac62 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 May 2019 11:22:01 +0200 Subject: [PATCH] use registry to get the theme --- src/app.js | 2 +- src/app/tabs/theme-module.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index b2b3101598..a9be45114c 100644 --- a/src/app.js +++ b/src/app.js @@ -338,7 +338,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org registry.put({api: networkModule, name: 'network'}) // ----------------- theme module ---------------------------- - const themeModule = new ThemeModule() + const themeModule = new ThemeModule(registry) registry.put({api: themeModule, name: 'themeModule'}) // ----------------- editor panel ---------------------- diff --git a/src/app/tabs/theme-module.js b/src/app/tabs/theme-module.js index f2091c5198..f32d0d735e 100644 --- a/src/app/tabs/theme-module.js +++ b/src/app/tabs/theme-module.js @@ -1,6 +1,5 @@ import { BaseApi } from 'remix-plugin' import { EventEmitter } from 'events' -const Storage = require('remix-lib').Storage const themes = [ {name: 'Cerulean', quality: 'light', url: 'https://bootswatch.com/4/cerulean/bootstrap.min.css'}, @@ -25,12 +24,14 @@ const profile = { export class ThemeModule extends BaseApi { - constructor () { + constructor (registry) { super(profile) this.events = new EventEmitter() - this.storage = new Storage('style:') + this._deps = { + config: registry.get('config').api + } this.themes = themes.reduce((acc, theme) => ({ ...acc, [theme.name]: theme }), {}) - this.active = this.storage.exists('theme') ? this.storage.get('theme') : 'Cerulean' + this.active = this._deps.config.get('settings/theme') ? this._deps.config.get('settings/theme') : 'Flatly' } /** Return the active theme */ @@ -53,7 +54,7 @@ export class ThemeModule extends BaseApi { } const next = themeName || this.active // Name const nextTheme = this.themes[next] // Theme - this.storage.set('theme', next) + 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