Compare commits
4 commits
4503bd77d7
...
11072e5fc8
Author | SHA1 | Date | |
---|---|---|---|
|
11072e5fc8 | ||
|
b348d22a2b | ||
|
3f331b53db | ||
|
1ffbd02c87 |
3 changed files with 30 additions and 16 deletions
|
@ -27,6 +27,10 @@ import {
|
||||||
|
|
||||||
import Preview from './theme_tab/theme_preview.vue'
|
import Preview from './theme_tab/theme_preview.vue'
|
||||||
|
|
||||||
|
// helper for debugging
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const toValue = (x) => JSON.parse(JSON.stringify(x === undefined ? 'null' : x))
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
faGlobe
|
faGlobe
|
||||||
)
|
)
|
||||||
|
@ -137,11 +141,12 @@ const AppearanceTab = {
|
||||||
cOrange = '#E3FF00'
|
cOrange = '#E3FF00'
|
||||||
] = v
|
] = v
|
||||||
palette = { key, name, bg, fg, text, link, cRed, cBlue, cGreen, cOrange }
|
palette = { key, name, bg, fg, text, link, cRed, cBlue, cGreen, cOrange }
|
||||||
this.bundledPalettes.push()
|
|
||||||
} else {
|
} else {
|
||||||
palette = { key, ...v }
|
palette = { key, ...v }
|
||||||
}
|
}
|
||||||
this.bundledPalettes.push(palette)
|
if (!palette.key.startsWith('style.')) {
|
||||||
|
this.bundledPalettes.push(palette)
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -210,6 +215,7 @@ const AppearanceTab = {
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
|
name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
|
||||||
|
key: `style.${variant.toLowerCase().replace(/ /g, '_')}`,
|
||||||
bg,
|
bg,
|
||||||
fg,
|
fg,
|
||||||
text,
|
text,
|
||||||
|
@ -317,16 +323,13 @@ const AppearanceTab = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isThemeActive (key) {
|
isThemeActive (key) {
|
||||||
const { theme } = this.mergedConfig
|
return key === (this.mergedConfig.theme || this.$store.state.instance.theme)
|
||||||
return key === theme
|
|
||||||
},
|
},
|
||||||
isStyleActive (key) {
|
isStyleActive (key) {
|
||||||
const { style } = this.mergedConfig
|
return key === (this.mergedConfig.style || this.$store.state.instance.style)
|
||||||
return key === style
|
|
||||||
},
|
},
|
||||||
isPaletteActive (key) {
|
isPaletteActive (key) {
|
||||||
const { palette } = this.mergedConfig
|
return key === (this.mergedConfig.palette || this.$store.state.instance.palette)
|
||||||
return key === palette
|
|
||||||
},
|
},
|
||||||
setStyle (name) {
|
setStyle (name) {
|
||||||
this.$store.dispatch('setStyle', name)
|
this.$store.dispatch('setStyle', name)
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
:key="style.key"
|
:key="style.key"
|
||||||
:data-theme-key="style.key"
|
:data-theme-key="style.key"
|
||||||
class="button-default theme-preview"
|
class="button-default theme-preview"
|
||||||
:class="{ toggled: isThemeActive(style.key) }"
|
:class="{ toggled: isStyleActive(style.key) }"
|
||||||
@click="style.version === 'v2' ? setTheme(style.key) : setStyle(style.key)"
|
@click="style.version === 'v2' ? setTheme(style.key) : setStyle(style.key)"
|
||||||
>
|
>
|
||||||
<!-- eslint-disable vue/no-v-text-v-html-on-component -->
|
<!-- eslint-disable vue/no-v-text-v-html-on-component -->
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
:key="p.name"
|
:key="p.name"
|
||||||
class="btn button-default palette-entry"
|
class="btn button-default palette-entry"
|
||||||
:class="{ toggled: isPaletteActive(p.key) }"
|
:class="{ toggled: isPaletteActive(p.key) }"
|
||||||
@click="() => setPaletteCustom(p)"
|
@click="() => setPalette(p.key, p)"
|
||||||
>
|
>
|
||||||
<div class="palette-label">
|
<div class="palette-label">
|
||||||
<label>
|
<label>
|
||||||
|
|
|
@ -13,6 +13,7 @@ const defaultState = {
|
||||||
themeVersion: 'v3',
|
themeVersion: 'v3',
|
||||||
styleNameUsed: null,
|
styleNameUsed: null,
|
||||||
styleDataUsed: null,
|
styleDataUsed: null,
|
||||||
|
useStylePalette: false, // hack for applying styles from appearance tab
|
||||||
paletteNameUsed: null,
|
paletteNameUsed: null,
|
||||||
paletteDataUsed: null,
|
paletteDataUsed: null,
|
||||||
themeNameUsed: null,
|
themeNameUsed: null,
|
||||||
|
@ -265,23 +266,29 @@ const interfaceMod = {
|
||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setStyle ({ dispatch, commit }, value) {
|
setStyle ({ dispatch, commit, state }, value) {
|
||||||
dispatch('resetThemeV3')
|
dispatch('resetThemeV3')
|
||||||
dispatch('resetThemeV2')
|
dispatch('resetThemeV2')
|
||||||
dispatch('resetThemeV3Palette')
|
dispatch('resetThemeV3Palette')
|
||||||
|
|
||||||
commit('setOption', { name: 'style', value })
|
commit('setOption', { name: 'style', value })
|
||||||
|
state.useStylePalette = true
|
||||||
|
|
||||||
dispatch('applyTheme', { recompile: true })
|
dispatch('applyTheme', { recompile: true }).then(() => {
|
||||||
|
state.useStylePalette = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setStyleCustom ({ dispatch, commit }, value) {
|
setStyleCustom ({ dispatch, commit, state }, value) {
|
||||||
dispatch('resetThemeV3')
|
dispatch('resetThemeV3')
|
||||||
dispatch('resetThemeV2')
|
dispatch('resetThemeV2')
|
||||||
dispatch('resetThemeV3Palette')
|
dispatch('resetThemeV3Palette')
|
||||||
|
|
||||||
commit('setOption', { name: 'styleCustomData', value })
|
commit('setOption', { name: 'styleCustomData', value })
|
||||||
|
|
||||||
dispatch('applyTheme', { recompile: true })
|
state.useStylePalette = true
|
||||||
|
dispatch('applyTheme', { recompile: true }).then(() => {
|
||||||
|
state.useStylePalette = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async fetchThemesIndex ({ commit, state }) {
|
async fetchThemesIndex ({ commit, state }) {
|
||||||
try {
|
try {
|
||||||
|
@ -475,7 +482,7 @@ const interfaceMod = {
|
||||||
return { name: x.variant, ...cleanDirectives }
|
return { name: x.variant, ...cleanDirectives }
|
||||||
})
|
})
|
||||||
.forEach(palette => {
|
.forEach(palette => {
|
||||||
const key = 'style.' + palette.name.toLowerCase().replace(/ /, '_')
|
const key = 'style.' + palette.name.toLowerCase().replace(/ /g, '_')
|
||||||
if (!firstStylePaletteName) firstStylePaletteName = key
|
if (!firstStylePaletteName) firstStylePaletteName = key
|
||||||
palettesIndex[key] = () => Promise.resolve(palette)
|
palettesIndex[key] = () => Promise.resolve(palette)
|
||||||
})
|
})
|
||||||
|
@ -484,9 +491,13 @@ const interfaceMod = {
|
||||||
'palette',
|
'palette',
|
||||||
palettesIndex,
|
palettesIndex,
|
||||||
userPaletteCustomData,
|
userPaletteCustomData,
|
||||||
userPaletteName || firstStylePaletteName || instancePaletteName
|
state.useStylePalette ? firstStylePaletteName : (userPaletteName || instancePaletteName)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (state.useStylePalette) {
|
||||||
|
commit('setOption', { name: 'palette', value: firstStylePaletteName })
|
||||||
|
}
|
||||||
|
|
||||||
state.paletteNameUsed = palette.nameUsed
|
state.paletteNameUsed = palette.nameUsed
|
||||||
state.paletteDataUsed = palette.dataUsed
|
state.paletteDataUsed = palette.dataUsed
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue