Compare commits

...

4 commits

Author SHA1 Message Date
Henry Jameson
11072e5fc8 Merge branch 'themes3-grand-finale-maybe' into shigusegubu-themes3 2024-12-04 15:55:09 +02:00
Henry Jameson
b348d22a2b saving "first style palette" stuff 2024-12-04 15:54:20 +02:00
Henry Jameson
3f331b53db proper highlight 2024-12-04 14:57:28 +02:00
Henry Jameson
1ffbd02c87 when switching to new style, use "native" palette, also show it in appearance tab 2024-12-04 14:32:25 +02:00
3 changed files with 30 additions and 16 deletions

View file

@ -27,6 +27,10 @@ import {
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(
faGlobe
)
@ -137,11 +141,12 @@ const AppearanceTab = {
cOrange = '#E3FF00'
] = v
palette = { key, name, bg, fg, text, link, cRed, cBlue, cGreen, cOrange }
this.bundledPalettes.push()
} else {
palette = { key, ...v }
}
this.bundledPalettes.push(palette)
if (!palette.key.startsWith('style.')) {
this.bundledPalettes.push(palette)
}
}))
})
@ -210,6 +215,7 @@ const AppearanceTab = {
const result = {
name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
key: `style.${variant.toLowerCase().replace(/ /g, '_')}`,
bg,
fg,
text,
@ -317,16 +323,13 @@ const AppearanceTab = {
}
},
isThemeActive (key) {
const { theme } = this.mergedConfig
return key === theme
return key === (this.mergedConfig.theme || this.$store.state.instance.theme)
},
isStyleActive (key) {
const { style } = this.mergedConfig
return key === style
return key === (this.mergedConfig.style || this.$store.state.instance.style)
},
isPaletteActive (key) {
const { palette } = this.mergedConfig
return key === palette
return key === (this.mergedConfig.palette || this.$store.state.instance.palette)
},
setStyle (name) {
this.$store.dispatch('setStyle', name)

View file

@ -54,7 +54,7 @@
:key="style.key"
:data-theme-key="style.key"
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)"
>
<!-- eslint-disable vue/no-v-text-v-html-on-component -->
@ -115,7 +115,7 @@
:key="p.name"
class="btn button-default palette-entry"
:class="{ toggled: isPaletteActive(p.key) }"
@click="() => setPaletteCustom(p)"
@click="() => setPalette(p.key, p)"
>
<div class="palette-label">
<label>

View file

@ -13,6 +13,7 @@ const defaultState = {
themeVersion: 'v3',
styleNameUsed: null,
styleDataUsed: null,
useStylePalette: false, // hack for applying styles from appearance tab
paletteNameUsed: null,
paletteDataUsed: null,
themeNameUsed: null,
@ -265,23 +266,29 @@ const interfaceMod = {
return Promise.resolve({})
}
},
setStyle ({ dispatch, commit }, value) {
setStyle ({ dispatch, commit, state }, value) {
dispatch('resetThemeV3')
dispatch('resetThemeV2')
dispatch('resetThemeV3Palette')
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('resetThemeV2')
dispatch('resetThemeV3Palette')
commit('setOption', { name: 'styleCustomData', value })
dispatch('applyTheme', { recompile: true })
state.useStylePalette = true
dispatch('applyTheme', { recompile: true }).then(() => {
state.useStylePalette = false
})
},
async fetchThemesIndex ({ commit, state }) {
try {
@ -475,7 +482,7 @@ const interfaceMod = {
return { name: x.variant, ...cleanDirectives }
})
.forEach(palette => {
const key = 'style.' + palette.name.toLowerCase().replace(/ /, '_')
const key = 'style.' + palette.name.toLowerCase().replace(/ /g, '_')
if (!firstStylePaletteName) firstStylePaletteName = key
palettesIndex[key] = () => Promise.resolve(palette)
})
@ -484,9 +491,13 @@ const interfaceMod = {
'palette',
palettesIndex,
userPaletteCustomData,
userPaletteName || firstStylePaletteName || instancePaletteName
state.useStylePalette ? firstStylePaletteName : (userPaletteName || instancePaletteName)
)
if (state.useStylePalette) {
commit('setOption', { name: 'palette', value: firstStylePaletteName })
}
state.paletteNameUsed = palette.nameUsed
state.paletteDataUsed = palette.dataUsed