|
|
@ -2,10 +2,6 @@ import { Plugin } from '@remixproject/engine' |
|
|
|
import { EventEmitter } from 'events' |
|
|
|
import { EventEmitter } from 'events' |
|
|
|
import QueryParams from '../../lib/query-params' |
|
|
|
import QueryParams from '../../lib/query-params' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
import ReactDOM from 'react-dom' |
|
|
|
|
|
|
|
// eslint-disable-next-line no-use-before-define
|
|
|
|
|
|
|
|
import React from 'react' |
|
|
|
|
|
|
|
import yo from 'yo-yo' |
|
|
|
|
|
|
|
const _paq = window._paq = window._paq || [] |
|
|
|
const _paq = window._paq = window._paq || [] |
|
|
|
|
|
|
|
|
|
|
|
const themes = [ |
|
|
|
const themes = [ |
|
|
@ -68,7 +64,11 @@ export class ThemeModule extends Plugin { |
|
|
|
if (this.active) { |
|
|
|
if (this.active) { |
|
|
|
const nextTheme = this.themes[this.active] // Theme
|
|
|
|
const nextTheme = this.themes[this.active] // Theme
|
|
|
|
document.documentElement.style.setProperty('--theme', nextTheme.quality) |
|
|
|
document.documentElement.style.setProperty('--theme', nextTheme.quality) |
|
|
|
const theme = yo`<link rel="stylesheet" href="${nextTheme.url}" id="theme-link"/>` |
|
|
|
|
|
|
|
|
|
|
|
const theme = document.createElement('link') |
|
|
|
|
|
|
|
theme.setAttribute('rel', 'stylesheet') |
|
|
|
|
|
|
|
theme.setAttribute('href', nextTheme.url) |
|
|
|
|
|
|
|
theme.setAttribute('id', 'theme-link') |
|
|
|
theme.addEventListener('load', () => { |
|
|
|
theme.addEventListener('load', () => { |
|
|
|
if (callback) callback() |
|
|
|
if (callback) callback() |
|
|
|
}) |
|
|
|
}) |
|
|
@ -91,9 +91,10 @@ export class ThemeModule extends Plugin { |
|
|
|
if (!this.forced) this._deps.config.set('settings/theme', next) |
|
|
|
if (!this.forced) this._deps.config.set('settings/theme', next) |
|
|
|
document.getElementById('theme-link').remove() |
|
|
|
document.getElementById('theme-link').remove() |
|
|
|
const theme = document.createElement('link') |
|
|
|
const theme = document.createElement('link') |
|
|
|
theme.rel = 'stylesheet' |
|
|
|
|
|
|
|
theme.id = 'theme-link' |
|
|
|
theme.setAttribute('rel', 'stylesheet') |
|
|
|
theme.href = nextTheme.url |
|
|
|
theme.setAttribute('href', nextTheme.url) |
|
|
|
|
|
|
|
theme.setAttribute('id', 'theme-link') |
|
|
|
theme.addEventListener('load', () => { |
|
|
|
theme.addEventListener('load', () => { |
|
|
|
this.emit('themeLoaded', nextTheme) |
|
|
|
this.emit('themeLoaded', nextTheme) |
|
|
|
this.events.emit('themeLoaded', nextTheme) |
|
|
|
this.events.emit('themeLoaded', nextTheme) |
|
|
|