multiple fixes to make style switcher not die. Made shadows work, incuding compatibility
This commit is contained in:
parent
6a3714fcc6
commit
6e1c538e41
5 changed files with 94 additions and 59 deletions
|
@ -291,8 +291,8 @@ export const generateShadows = (input, colors, mod) => {
|
|||
const shadows = Object.entries({
|
||||
...DEFAULT_SHADOWS,
|
||||
...(input.shadows || {})
|
||||
}).reduce((shadowsAcc, [slotName, shadowdefs]) => {
|
||||
const newShadow = shadowdefs.reduce((shadowAcc, def) => [
|
||||
}).reduce((shadowsAcc, [slotName, shadowDefs]) => {
|
||||
const newShadow = shadowDefs.reduce((shadowAcc, def) => [
|
||||
...shadowAcc,
|
||||
{
|
||||
...def,
|
||||
|
@ -380,6 +380,25 @@ export const getThemes = () => {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* This handles compatibility issues when importing v2 theme's shadows to current format
|
||||
*
|
||||
* Back in v2 shadows allowed you to use dynamic colors however those used pure CSS3 variables
|
||||
*/
|
||||
export const shadows2to3 = (shadows) => {
|
||||
return Object.entries(shadows).reduce((shadowsAcc, [slotName, shadowDefs]) => {
|
||||
const isDynamic = ({ color }) => console.log(color) || color.startsWith('--')
|
||||
const newShadow = shadowDefs.reduce((shadowAcc, def) => [
|
||||
...shadowAcc,
|
||||
{
|
||||
...def,
|
||||
alpha: isDynamic(def) ? 1 : def.alpha
|
||||
}
|
||||
], [])
|
||||
return { ...shadowsAcc, [slotName]: newShadow }
|
||||
}, {})
|
||||
}
|
||||
|
||||
export const setPreset = (val, commit) => {
|
||||
return getThemes()
|
||||
.then((themes) => themes[val] ? themes[val] : themes['pleroma-dark'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue