mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
use initialize method
This commit is contained in:
parent
16c97b51ab
commit
992f0ac259
@ -31,32 +31,7 @@ export default class ThemeExtension extends Extension {
|
||||
this.resetDefault()
|
||||
})
|
||||
|
||||
let theme = this.getStoragedTheme()
|
||||
const modifications = this.getStoragedModifications()
|
||||
const variantKey = this.getStoragedVariant()
|
||||
|
||||
if (!theme) {
|
||||
// load default theme
|
||||
theme = this.getDefaultTheme()
|
||||
} else {
|
||||
// load URL and initialize theme
|
||||
}
|
||||
|
||||
// set global theme
|
||||
this.theme = theme
|
||||
|
||||
// override with static vars
|
||||
if (theme.staticVars) {
|
||||
this.update(theme.staticVars)
|
||||
}
|
||||
|
||||
// override theme with modifications
|
||||
if (modifications) {
|
||||
this.update(modifications)
|
||||
}
|
||||
|
||||
// apply variation
|
||||
this.applyVariant(variantKey)
|
||||
await this.initialize()
|
||||
},
|
||||
]
|
||||
|
||||
@ -64,6 +39,36 @@ export default class ThemeExtension extends Extension {
|
||||
return document.documentElement.style.getPropertyValue("--themeVariant")
|
||||
}
|
||||
|
||||
initialize = async () => {
|
||||
let theme = this.getStoragedTheme()
|
||||
|
||||
const modifications = this.getStoragedModifications()
|
||||
const variantKey = this.getStoragedVariant()
|
||||
|
||||
if (!theme) {
|
||||
// load default theme
|
||||
theme = this.getDefaultTheme()
|
||||
} else {
|
||||
// load URL and initialize theme
|
||||
}
|
||||
|
||||
// set global theme
|
||||
this.theme = theme
|
||||
|
||||
// override with static vars
|
||||
if (theme.staticVars) {
|
||||
this.update(theme.staticVars)
|
||||
}
|
||||
|
||||
// override theme with modifications
|
||||
if (modifications) {
|
||||
this.update(modifications)
|
||||
}
|
||||
|
||||
// apply variation
|
||||
this.applyVariant(variantKey)
|
||||
}
|
||||
|
||||
getRootVariables = () => {
|
||||
let attributes = document.documentElement.getAttribute("style").trim().split(";")
|
||||
attributes = attributes.slice(0, (attributes.length - 1))
|
||||
@ -108,7 +113,7 @@ export default class ThemeExtension extends Extension {
|
||||
|
||||
window.app.settings.set("primaryColor", this.theme.staticVars.primaryColor)
|
||||
|
||||
return this.init()
|
||||
this.initialize()
|
||||
}
|
||||
|
||||
update = (update) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user