aboutsummaryrefslogtreecommitdiff
path: root/src/services/style_setter/style_setter.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-12-28 17:02:34 +0200
committerHenry Jameson <me@hjkos.com>2019-12-28 17:02:34 +0200
commit1a78461443e4f85461283c1921694a5fb28ea39f (patch)
treefc443910a419617d9886fc3481ef99d60b46db51 /src/services/style_setter/style_setter.js
parente5a34870f0f7154712783fb6d9c20edf4c06ad35 (diff)
fixed import-export
Diffstat (limited to 'src/services/style_setter/style_setter.js')
-rw-r--r--src/services/style_setter/style_setter.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js
index 1e4bc59e..19a06587 100644
--- a/src/services/style_setter/style_setter.js
+++ b/src/services/style_setter/style_setter.js
@@ -148,6 +148,26 @@ const getCssColor = (input, a) => {
return rgb2rgba({ ...rgb, a })
}
+// Generates a "patch" for theme to make it compatible with v2
+export const generateCompat = (input) => {
+ const { colors } = input
+ const v3compat = {
+ colors: {}
+ }
+ const v2colorsPatch = {}
+
+ // # Link became optional in v3
+ if (typeof colors.link === 'undefined') {
+ v2colorsPatch.link = colors.accent
+ v3compat.colors.link = null
+ }
+
+ return {
+ v3compat,
+ colors: v2colorsPatch
+ }
+}
+
const generateColors = (input) => {
const colors = {}
const opacity = Object.assign({
@@ -164,7 +184,10 @@ const generateColors = (input) => {
const inputColors = input.colors || input
const compat = input.v3compat || {}
- const compatColors = compat.colors || {}
+ const compatColors = Object.entries(compat.colors || {}).reduce((acc, [key, value]) => {
+ const newVal = value === null ? undefined : value
+ return { ...acc, [key]: newVal }
+ }, {})
const col = Object.entries({ ...inputColors, ...compatColors }).reduce((acc, [k, v]) => {
if (typeof v === 'object') {
@@ -210,7 +233,7 @@ const generateColors = (input) => {
colors.topBarText = col.topBarText || getTextColor(colors.topBar, colors.fgText)
colors.topBarLink = col.topBarLink || getTextColor(colors.topBar, colors.fgLink)
- colors.faintLink = col.faintLink || Object.assign({}, col.link)
+ colors.faintLink = col.faintLink || Object.assign({}, col.link || col.accent)
colors.linkBg = alphaBlend(colors.link, 0.4, colors.bg)
colors.icon = mixrgb(colors.bg, colors.text)