made theme debug easier by making it an actual option
This commit is contained in:
parent
eed05f1380
commit
f9e407de63
|
@ -353,18 +353,20 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
|
|
||||||
await setConfig({ store })
|
await setConfig({ store })
|
||||||
|
|
||||||
const { customTheme, customThemeSource, forceThemeRecompilation } = store.state.config
|
const { customTheme, customThemeSource, forceThemeRecompilation, themeDebug } = store.state.config
|
||||||
const { theme } = store.state.instance
|
const { theme } = store.state.instance
|
||||||
const customThemePresent = customThemeSource || customTheme
|
const customThemePresent = customThemeSource || customTheme
|
||||||
|
|
||||||
if (!forceThemeRecompilation && tryLoadCache()) {
|
console.log('DEBUG INITIAL', themeDebug, forceThemeRecompilation)
|
||||||
|
|
||||||
|
if (!forceThemeRecompilation && !themeDebug && tryLoadCache()) {
|
||||||
store.commit('setThemeApplied')
|
store.commit('setThemeApplied')
|
||||||
} else {
|
} else {
|
||||||
if (customThemePresent) {
|
if (customThemePresent) {
|
||||||
if (customThemeSource && customThemeSource.themeEngineVersion === CURRENT_VERSION) {
|
if (customThemeSource && customThemeSource.themeEngineVersion === CURRENT_VERSION) {
|
||||||
applyTheme(customThemeSource)
|
applyTheme(customThemeSource, () => {}, themeDebug)
|
||||||
} else {
|
} else {
|
||||||
applyTheme(customTheme)
|
applyTheme(customTheme, () => {}, themeDebug)
|
||||||
}
|
}
|
||||||
store.commit('setThemeApplied')
|
store.commit('setThemeApplied')
|
||||||
} else if (theme) {
|
} else if (theme) {
|
||||||
|
|
|
@ -142,6 +142,22 @@
|
||||||
{{ $t('settings.hide_wallpaper') }}
|
{{ $t('settings.hide_wallpaper') }}
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path="forceThemeRecompilation"
|
||||||
|
:expert="1"
|
||||||
|
>
|
||||||
|
{{ $t('settings.force_theme_recompilation_debug') }}
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path="themeDebug"
|
||||||
|
:expert="1"
|
||||||
|
>
|
||||||
|
{{ $t('settings.theme_debug') }}
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -148,14 +148,6 @@
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<h2>{{ $t('settings.post_look_feel') }}</h2>
|
<h2>{{ $t('settings.post_look_feel') }}</h2>
|
||||||
<ul class="setting-list">
|
<ul class="setting-list">
|
||||||
<li>
|
|
||||||
<BooleanSetting
|
|
||||||
path="forceThemeRecompilation"
|
|
||||||
:expert="1"
|
|
||||||
>
|
|
||||||
{{ $t('settings.force_theme_recompilation_debug') }}
|
|
||||||
</BooleanSetting>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<ChoiceSetting
|
<ChoiceSetting
|
||||||
id="conversationDisplay"
|
id="conversationDisplay"
|
||||||
|
|
|
@ -391,6 +391,7 @@
|
||||||
"forced_roundness_mode_sharp": "Force sharp edges",
|
"forced_roundness_mode_sharp": "Force sharp edges",
|
||||||
"forced_roundness_mode_nonsharp": "Force not-so-sharp (1px roundness) edges",
|
"forced_roundness_mode_nonsharp": "Force not-so-sharp (1px roundness) edges",
|
||||||
"forced_roundness_mode_round": "Force round edges",
|
"forced_roundness_mode_round": "Force round edges",
|
||||||
|
"theme_debug": "Show what background theme engine assumes when dealing with transparancy (DEBUG)",
|
||||||
"scale_and_layout": "Interface scale and layout",
|
"scale_and_layout": "Interface scale and layout",
|
||||||
"mfa": {
|
"mfa": {
|
||||||
"otp": "OTP",
|
"otp": "OTP",
|
||||||
|
|
|
@ -147,6 +147,7 @@ export const defaultState = {
|
||||||
maxDepthInThread: undefined, // instance default
|
maxDepthInThread: undefined, // instance default
|
||||||
autocompleteSelect: undefined, // instance default
|
autocompleteSelect: undefined, // instance default
|
||||||
closingDrawerMarksAsSeen: undefined, // instance default
|
closingDrawerMarksAsSeen: undefined, // instance default
|
||||||
|
themeDebug: false,
|
||||||
unseenAtTop: undefined, // instance default
|
unseenAtTop: undefined, // instance default
|
||||||
ignoreInactionableSeen: undefined // instance default
|
ignoreInactionableSeen: undefined // instance default
|
||||||
}
|
}
|
||||||
|
@ -274,9 +275,16 @@ const config = {
|
||||||
applyConfig(state)
|
applyConfig(state)
|
||||||
break
|
break
|
||||||
case 'customTheme':
|
case 'customTheme':
|
||||||
case 'customThemeSource':
|
case 'customThemeSource': {
|
||||||
applyTheme(value)
|
const { themeDebug } = state
|
||||||
|
applyTheme(value, () => {}, themeDebug)
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
case 'themeDebug': {
|
||||||
|
const { customTheme, customThemeSource } = state
|
||||||
|
applyTheme(customTheme || customThemeSource, () => {}, value)
|
||||||
|
break
|
||||||
|
}
|
||||||
case 'interfaceLanguage':
|
case 'interfaceLanguage':
|
||||||
messages.setLanguage(this.getters.i18n, value)
|
messages.setLanguage(this.getters.i18n, value)
|
||||||
dispatch('loadUnicodeEmojiData', value)
|
dispatch('loadUnicodeEmojiData', value)
|
||||||
|
|
|
@ -383,16 +383,16 @@ const instance = {
|
||||||
.then(themeData => {
|
.then(themeData => {
|
||||||
commit('setInstanceOption', { name: 'themeData', value: themeData })
|
commit('setInstanceOption', { name: 'themeData', value: themeData })
|
||||||
// No need to apply theme if there's user theme already
|
// No need to apply theme if there's user theme already
|
||||||
const { customTheme } = rootState.config
|
const { customTheme, themeDebug } = rootState.config
|
||||||
const { themeApplied } = rootState.interface
|
const { themeApplied } = rootState.interface
|
||||||
if (customTheme || themeApplied) return
|
if (customTheme || themeApplied) return
|
||||||
|
|
||||||
// New theme presets don't have 'theme' property, they use 'source'
|
// New theme presets don't have 'theme' property, they use 'source'
|
||||||
const themeSource = themeData.source
|
const themeSource = themeData.source
|
||||||
if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) {
|
if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) {
|
||||||
applyTheme(themeSource)
|
applyTheme(themeSource, null, themeDebug)
|
||||||
} else {
|
} else {
|
||||||
applyTheme(themeData.theme)
|
applyTheme(themeData.theme, null, themeDebug)
|
||||||
}
|
}
|
||||||
commit('setThemeApplied')
|
commit('setThemeApplied')
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { getCssRules } from '../theme_data/css_utils.js'
|
||||||
import { defaultState } from '../../modules/config.js'
|
import { defaultState } from '../../modules/config.js'
|
||||||
import { chunk } from 'lodash'
|
import { chunk } from 'lodash'
|
||||||
|
|
||||||
export const generateTheme = async (input, callbacks) => {
|
export const generateTheme = async (input, callbacks, debug) => {
|
||||||
const {
|
const {
|
||||||
onNewRule = (rule, isLazy) => {},
|
onNewRule = (rule, isLazy) => {},
|
||||||
onLazyFinished = () => {},
|
onLazyFinished = () => {},
|
||||||
|
@ -22,9 +22,11 @@ export const generateTheme = async (input, callbacks) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assuming that "worst case scenario background" is panel background since it's the most likely one
|
// Assuming that "worst case scenario background" is panel background since it's the most likely one
|
||||||
const themes3 = init(extraRules, extraRules[0].directives['--bg'].split('|')[1].trim())
|
const themes3 = init(extraRules, extraRules[0].directives['--bg'].split('|')[1].trim(), debug)
|
||||||
|
|
||||||
getCssRules(themes3.eager, themes3.staticVars).forEach(rule => {
|
console.log('DEBUG 2 IS', debug)
|
||||||
|
|
||||||
|
getCssRules(themes3.eager, debug).forEach(rule => {
|
||||||
// Hacks to support multiple selectors on same component
|
// Hacks to support multiple selectors on same component
|
||||||
if (rule.match(/::-webkit-scrollbar-button/)) {
|
if (rule.match(/::-webkit-scrollbar-button/)) {
|
||||||
const parts = rule.split(/[{}]/g)
|
const parts = rule.split(/[{}]/g)
|
||||||
|
@ -54,7 +56,7 @@ export const generateTheme = async (input, callbacks) => {
|
||||||
const processChunk = () => {
|
const processChunk = () => {
|
||||||
const chunk = chunks[counter]
|
const chunk = chunks[counter]
|
||||||
Promise.all(chunk.map(x => x())).then(result => {
|
Promise.all(chunk.map(x => x())).then(result => {
|
||||||
getCssRules(result.filter(x => x), themes3.staticVars).forEach(rule => {
|
getCssRules(result.filter(x => x), debug).forEach(rule => {
|
||||||
if (rule.match(/\.modal-view/)) {
|
if (rule.match(/\.modal-view/)) {
|
||||||
const parts = rule.split(/[{}]/g)
|
const parts = rule.split(/[{}]/g)
|
||||||
const newRule = [
|
const newRule = [
|
||||||
|
@ -113,12 +115,14 @@ export const tryLoadCache = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const applyTheme = async (input, onFinish = (data) => {}) => {
|
export const applyTheme = async (input, onFinish = (data) => {}, debug) => {
|
||||||
const styleSheet = new CSSStyleSheet()
|
const styleSheet = new CSSStyleSheet()
|
||||||
const styleArray = []
|
const styleArray = []
|
||||||
const lazyStyleSheet = new CSSStyleSheet()
|
const lazyStyleSheet = new CSSStyleSheet()
|
||||||
const lazyStyleArray = []
|
const lazyStyleArray = []
|
||||||
|
|
||||||
|
console.log('DEBUG IS', debug)
|
||||||
|
|
||||||
const { lazyProcessFunc } = await generateTheme(
|
const { lazyProcessFunc } = await generateTheme(
|
||||||
input,
|
input,
|
||||||
{
|
{
|
||||||
|
@ -140,7 +144,8 @@ export const applyTheme = async (input, onFinish = (data) => {}) => {
|
||||||
onFinish(cache)
|
onFinish(cache)
|
||||||
localStorage.setItem('pleroma-fe-theme-cache', JSON.stringify(cache))
|
localStorage.setItem('pleroma-fe-theme-cache', JSON.stringify(cache))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
debug
|
||||||
)
|
)
|
||||||
|
|
||||||
setTimeout(lazyProcessFunc, 0)
|
setTimeout(lazyProcessFunc, 0)
|
||||||
|
|
|
@ -2,11 +2,6 @@ import { convert } from 'chromatism'
|
||||||
|
|
||||||
import { hex2rgb, rgba2css } from '../color_convert/color_convert.js'
|
import { hex2rgb, rgba2css } from '../color_convert/color_convert.js'
|
||||||
|
|
||||||
// This changes what backgrounds are used to "stacked" solid colors so you can see
|
|
||||||
// what theme engine "thinks" is actual background color is for purposes of text color
|
|
||||||
// generation and for when --stacked variable is used
|
|
||||||
const DEBUG = false
|
|
||||||
|
|
||||||
export const parseCssShadow = (text) => {
|
export const parseCssShadow = (text) => {
|
||||||
const dimensions = /(\d[a-z]*\s?){2,4}/.exec(text)?.[0]
|
const dimensions = /(\d[a-z]*\s?){2,4}/.exec(text)?.[0]
|
||||||
const inset = /inset/.exec(text)?.[0]
|
const inset = /inset/.exec(text)?.[0]
|
||||||
|
@ -66,7 +61,10 @@ export const getCssShadowFilter = (input) => {
|
||||||
.join(' ')
|
.join(' ')
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCssRules = (rules) => rules.map(rule => {
|
// `debug` changes what backgrounds are used to "stacked" solid colors so you can see
|
||||||
|
// what theme engine "thinks" is actual background color is for purposes of text color
|
||||||
|
// generation and for when --stacked variable is used
|
||||||
|
export const getCssRules = (rules, debug) => rules.map(rule => {
|
||||||
let selector = rule.selector
|
let selector = rule.selector
|
||||||
if (!selector) {
|
if (!selector) {
|
||||||
selector = 'html'
|
selector = 'html'
|
||||||
|
@ -93,7 +91,7 @@ export const getCssRules = (rules) => rules.map(rule => {
|
||||||
].join(';\n ')
|
].join(';\n ')
|
||||||
}
|
}
|
||||||
case 'background': {
|
case 'background': {
|
||||||
if (DEBUG) {
|
if (debug) {
|
||||||
return `
|
return `
|
||||||
--background: ${getCssColorString(rule.dynamicVars.stacked)};
|
--background: ${getCssColorString(rule.dynamicVars.stacked)};
|
||||||
background-color: ${getCssColorString(rule.dynamicVars.stacked)};
|
background-color: ${getCssColorString(rule.dynamicVars.stacked)};
|
||||||
|
|
|
@ -149,7 +149,7 @@ const ruleToSelector = genericRuleToSelector(components)
|
||||||
|
|
||||||
export const getEngineChecksum = () => engineChecksum
|
export const getEngineChecksum = () => engineChecksum
|
||||||
|
|
||||||
export const init = (extraRuleset, ultimateBackgroundColor) => {
|
export const init = (extraRuleset, ultimateBackgroundColor, debug) => {
|
||||||
const staticVars = {}
|
const staticVars = {}
|
||||||
const stacked = {}
|
const stacked = {}
|
||||||
const computed = {}
|
const computed = {}
|
||||||
|
|
Loading…
Reference in a new issue