Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
14 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js
index 013d595327..0ed980d983 100644
--- a/src/components/settings_modal/tabs/appearance_tab.js
+++ b/src/components/settings_modal/tabs/appearance_tab.js
@@ -99,6 +99,7 @@ const AppearanceTab = {
'cBlue',
'cOrange',
],
+ stylePalettes: [],
userPalette: {},
intersectionObserver: null,
backgroundUploading: false,
@@ -227,6 +228,12 @@ const AppearanceTab = {
paletteDataUsed() {
this.userPalette = this.paletteDataUsed || {}
},
+ selectedStyleDataFetcher: {
+ immediate: true,
+ handler() {
+ this.updateStylePalettes()
+ },
+ },
},
computed: {
isDefaultBackground() {
@@ -244,44 +251,27 @@ const AppearanceTab = {
availablePalettes() {
return [...this.bundledPalettes, ...this.stylePalettes]
},
- stylePalettes() {
- const ruleset = useInterfaceStore().styleDataUsed || []
- if (ruleset.length === 0) return
- const meta = ruleset.find((x) => x.component === '@meta')
- const result = ruleset
- .filter((x) => x.component.startsWith('@palette'))
- .map((x) => {
- const { variant, directives } = x
- const {
- bg,
- fg,
- text,
- link,
- accent,
- cRed,
- cBlue,
- cGreen,
- cOrange,
- wallpaper,
- } = directives
+ selectedStyleDataFetcher() {
+ if (this.configSource.styleCustomData) {
+ return () => Promise.resolve(this.configSource.styleCustomData)
+ } else if (this.configSource.style) {
+ return useInstanceStore().stylesIndex[this.configSource.style]
+ } else {
+ return () => Promise.resolve([])
+ }
+ },
+ autoPalettes() {
+ const palettesSet = this.stylePalettes.length > 0
+ ? this.stylePalettes
+ : this.bundledPalettes
- const result = {
- name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
- key: `style.${variant.toLowerCase().replaceAll(' ', '_')}`,
- bg,
- fg,
- text,
- link,
- accent,
- cRed,
- cBlue,
- cGreen,
- cOrange,
- wallpaper,
- }
- return Object.fromEntries(Object.entries(result).filter(([, v]) => v))
- })
- return result
+ return [
+ palettesSet.find(x => /dark/i.test(x.name)) ?? palettesSet[0],
+ palettesSet.find(x => /light/i.test(x.name)) ?? palettesSet[0],
+ ]
+ },
+ autoIsDarkLight() {
+ return this.autoPalettes?.[0]?.name !== this.autoPalettes?.[1]?.name
},
noIntersectionObserver() {
return !window.IntersectionObserver
@@ -307,6 +297,24 @@ const AppearanceTab = {
const { styleCustomData } = this.configSource
return styleCustomData != null
},
+ isStyleDefined() {
+ if (this.defaultSource === 'local') {
+ return Object.hasOwn(useLocalConfigStore().mergedConfig, 'style')
+ } else if (this.defaultSource === 'admin') {
+ return Object.hasOwn(useAdminSettingsStore().frontendConfig ?? {}, 'style')
+ } else {
+ return true
+ }
+ },
+ isPaletteDefined() {
+ if (this.defaultSource === 'local') {
+ return Object.hasOwn(useLocalConfigStore().mergedConfig, 'palette')
+ } else if (this.defaultSource === 'admin') {
+ return Object.hasOwn(useAdminSettingsStore().frontendConfig ?? {}, 'palette')
+ } else {
+ return true
+ }
+ },
// Data access
configSource() {
switch (this.defaultSource) {
@@ -331,6 +339,48 @@ const AppearanceTab = {
return deserialize(file)
}
},
+ async updateStylePalettes() {
+ this.stylePalettes = []
+
+ const style = await this.selectedStyleDataFetcher()
+ const ruleset = style || []
+ if (ruleset.length === 0) return
+ const meta = ruleset.find((x) => x.component === '@meta')
+ const result = ruleset
+ .filter((x) => x.component.startsWith('@palette'))
+ .map((x) => {
+ const { variant, directives } = x
+ const {
+ bg,
+ fg,
+ text,
+ link,
+ accent,
+ cRed,
+ cBlue,
+ cGreen,
+ cOrange,
+ wallpaper,
+ } = directives
+
+ const result = {
+ name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`,
+ key: `style.${variant.toLowerCase().replaceAll(' ', '_')}`,
+ bg,
+ fg,
+ text,
+ link,
+ accent,
+ cRed,
+ cBlue,
+ cGreen,
+ cOrange,
+ wallpaper,
+ }
+ return Object.fromEntries(Object.entries(result).filter(([, v]) => v))
+ })
+ this.stylePalettes = result
+ },
onImport(parsed, filename) {
if (filename.endsWith('.json')) {
useInterfaceStore().setThemeCustom(parsed.source || parsed.theme, this.defaultSource)
@@ -368,6 +418,10 @@ const AppearanceTab = {
setStyle(name) {
useInterfaceStore().setStyle(name, this.defaultSource)
},
+ unsetStyle() {
+ useInterfaceStore().resetThemeV3(this.defaultSource)
+ useInterfaceStore().resetThemeV2(this.defaultSource)
+ },
setTheme(name) {
useInterfaceStore().setTheme(name, this.defaultSource)
},
@@ -379,6 +433,9 @@ const AppearanceTab = {
useInterfaceStore().setPaletteCustom(data, this.defaultSource)
this.userPalette = data
},
+ unsetPalette() {
+ useInterfaceStore().resetThemeV3Palette(this.defaultSource)
+ },
resetTheming() {
useInterfaceStore().setStyle('stock', this.defaultSource)
},
diff --git a/src/components/settings_modal/tabs/appearance_tab.scss b/src/components/settings_modal/tabs/appearance_tab.scss
index 4737360904..e699104230 100644
--- a/src/components/settings_modal/tabs/appearance_tab.scss
+++ b/src/components/settings_modal/tabs/appearance_tab.scss
@@ -145,6 +145,7 @@
gap: 0.5em;
padding: 0.5em;
width: 100%;
+ place-items: stretch;
h5 {
grid-column: 1 / span 2;
@@ -158,7 +159,6 @@
align-items: center;
justify-content: space-between;
padding: 0 0.5em;
- height: max-content;
.palette-label {
height: auto;
@@ -211,6 +211,16 @@
margin: 0.5em 0;
}
+ .palette-preview-slice {
+ position: relative;
+
+ .palette-preview:last-child {
+ position: absolute;
+ inset: 0;
+ mask: linear-gradient(to top right, transparent 50%, white 51%) bottom no-repeat;
+ }
+ }
+
.theme-list {
list-style: none;
display: flex;
diff --git a/src/components/settings_modal/tabs/appearance_tab.vue b/src/components/settings_modal/tabs/appearance_tab.vue
index dc645d70ce..3eca643dc2 100644
--- a/src/components/settings_modal/tabs/appearance_tab.vue
+++ b/src/components/settings_modal/tabs/appearance_tab.vue
@@ -17,6 +17,21 @@
role="list"
:aria-label="$t('settings.style.themes3.styles')"
>
+ <button
+ v-if="defaultSource !== 'sync'"
+ class="button-default theme-preview"
+ data-theme-key="undefined"
+ :class="{ toggled: !isStyleDefined, disabled: switchInProgress }"
+ :disabled="switchInProgress"
+ @click="unsetStyle"
+ role="listitem"
+ :aria-label="$t('settings.style.stock_theme_used')"
+ >
+ <preview id="theme-preview-default" />
+ <span class="theme-name">
+ {{ $t('settings.style.default_theme_used') }}
+ </span>
+ </button>
<button
class="button-default theme-preview"
data-theme-key="stock"
@@ -92,6 +107,65 @@
class="palettes-container"
aria-labelledby="palette-header"
>
+ <h5
+ id="special-palettes-header">
+ {{ $t('settings.style.themes3.palette.special') }}
+ </h5>
+ <div
+ class="palettes"
+ role="list"
+ aria-labelledby="special-palettes-header"
+ >
+ <button
+ v-if="defaultSource !== 'sync'"
+ class="btn button-default palette-entry"
+ :class="{ toggled: !isPaletteDefined, disabled: switchInProgress }"
+ :disabled="switchInProgress"
+ @click="unsetPalette"
+ role="listitem"
+ >
+ <div class="palette-label">
+ <label>
+ {{$t('settings.style.themes3.palette.no_override')}}
+ </label>
+ </div>
+ </button>
+ <button
+ class="btn button-default palette-entry"
+ :class="{ toggled: isPaletteDefined && isPaletteActive(undefined), disabled: switchInProgress }"
+ :disabled="switchInProgress"
+ @click="() => setPalette(undefined)"
+ role="listitem"
+ >
+ <div class="palette-label">
+ <label>
+ {{
+ autoIsDarkLight
+ ? $t('settings.style.themes3.palette.auto_dark_light')
+ : $t('settings.style.themes3.palette.auto')
+ }}
+ </label>
+ </div>
+ <div class="palette-preview-slice">
+ <div v-if="autoPalettes[0]" class="palette-preview">
+ <span
+ v-for="c in palettesKeys"
+ :key="c"
+ class="palette-square"
+ :style="{ backgroundColor: autoPalettes[0][c], border: '1px solid ' + (autoPalettes[0][c] ?? 'var(--text)') }"
+ />
+ </div>
+ <div v-if="autoPalettes[1]" class="palette-preview">
+ <span
+ v-for="c in palettesKeys"
+ :key="c"
+ class="palette-square"
+ :style="{ backgroundColor: autoPalettes[1][c], border: '1px solid ' + (autoPalettes[1][c] ?? 'var(--text)') }"
+ />
+ </div>
+ </div>
+ </button>
+ </div>
<h5
v-if="stylePalettes?.length > 0"
id="style-palettes-header"
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 69b80bf374..b5ce31f7c4 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -939,6 +939,7 @@
"custom_theme_used": "(Custom theme)",
"custom_style_used": "(Custom style)",
"stock_theme_used": "(Stock theme)",
+ "default_theme_used": "(Default / No override)",
"themes2_outdated": "Editor for Themes V2 is being phased out and will eventually be replaced with a new one that takes advantage of new Themes V3 engine. It should still work but experience might be degraded and inconsistent.",
"appearance_tab_note": "Changes on this tab do not affect the theme used, so exported theme will be different from what seen in the UI",
"visual_tweaks_section_note": "Changes in this section do not affect the theme used, exported theme will be different from what seen in the UI",
@@ -965,7 +966,11 @@
"v2_unsupported": "Older v2 themes don't support palettes. Switch to v3 theme to make use of palettes",
"bundled": "Bundled palettes",
"style": "Palettes provided by selected style",
+ "special": "Special palettes",
"user": "Custom palette",
+ "auto": "(Automatic)",
+ "auto_dark_light": "(Automatic Dark/Light)",
+ "no_override": "(Default / No override)",
"imported": "Imported"
},
"editor": {
diff --git a/src/stores/interface.js b/src/stores/interface.js
index ced47f65d5..0fbb203bb1 100644
--- a/src/stores/interface.js
+++ b/src/stores/interface.js
@@ -1,4 +1,4 @@
-import { cloneDeep, set } from 'lodash-es'
+import { cloneDeep, set, unset } from 'lodash-es'
import { defineStore } from 'pinia'
import {
@@ -390,6 +390,32 @@ export const useInterfaceStore = defineStore('interface', {
}
}
},
+ async unsetPreference({ path, value, store }) {
+ switch(store) {
+ case 'sync':
+ return useSyncConfigStore().setPreference({ path: `simple.${path}`, value: undefined })
+ case 'local':
+ return useLocalConfigStore().unset({ path, value })
+ // Copypasta from setting.js
+ case 'fe-admin': {
+ const prefix = [
+ ':pleroma',
+ ':frontend_configurations',
+ ':pleroma_fe',
+ ]
+ const settings = cloneDeep(useAdminSettingsStore().frontendConfig)
+ unset(settings, path)
+ const formatted = Object.fromEntries(
+ Object.entries(settings).map(([k, v]) => [`:${k}`, v]),
+ )
+
+ return useAdminSettingsStore().pushAdminSetting({
+ path: prefix.join('.'),
+ value: formatted,
+ })
+ }
+ }
+ },
async pushPreferences({ store }) {
if (store === 'sync') {
return useSyncConfigStore().pushSyncConfig()
@@ -469,7 +495,7 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV3Palette(store)
this.setPreference({
- path: 'simple.styleCustomData',
+ path: 'styleCustomData',
value,
store,
})
@@ -516,35 +542,30 @@ export const useInterfaceStore = defineStore('interface', {
this.applyTheme({ recompile: true, store })
},
resetThemeV3(store) {
- this.setPreference({ path: 'style', value: undefined, store })
- this.setPreference({
+ this.unsetPreference({ path: 'style', store })
+ this.unsetPreference({
path: 'styleCustomData',
- value: undefined,
store,
})
},
resetThemeV3Palette(store) {
- this.setPreference({
+ this.unsetPreference({
path: 'palette',
- value: undefined,
store,
})
- this.setPreference({
+ this.unsetPreference({
path: 'paletteCustomData',
- value: undefined,
store,
})
},
resetThemeV2(store) {
- this.setPreference({ path: 'theme', value: undefined })
- this.setPreference({
+ this.unsetPreference({ path: 'theme' })
+ this.unsetPreference({
path: 'customTheme',
- value: undefined,
store,
})
- this.setPreference({
+ this.unsetPreference({
path: 'customThemeSource',
- value: undefined,
store,
})
},

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 18, 1:15 PM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1840462
Default Alt Text
(14 KB)

Event Timeline