aboutsummaryrefslogtreecommitdiff
path: root/src/services/theme_data/theme_data.service.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2020-01-24 00:36:32 +0200
committerHenry Jameson <me@hjkos.com>2020-01-24 00:36:32 +0200
commitb96993e4dd6b2d9197b430af404e8fa652888b51 (patch)
treef8a00c86f05567bf22e8faa25a97453184b2a024 /src/services/theme_data/theme_data.service.js
parent53576df72aff5405ab30764e5cfcf2162bde37bc (diff)
improved selectedMenu again
Diffstat (limited to 'src/services/theme_data/theme_data.service.js')
-rw-r--r--src/services/theme_data/theme_data.service.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js
index ea28481b..c0861a4a 100644
--- a/src/services/theme_data/theme_data.service.js
+++ b/src/services/theme_data/theme_data.service.js
@@ -1,5 +1,5 @@
import { convert, brightness, contrastRatio } from 'chromatism'
-import { alphaBlendLayers, getTextColor } from '../color_convert/color_convert.js'
+import { alphaBlendLayers, getTextColor, relativeLuminance } from '../color_convert/color_convert.js'
import { LAYERS, DEFAULT_OPACITY, SLOT_INHERITANCE } from './pleromafe.js'
/*
@@ -318,13 +318,14 @@ export const getColors = (sourceColors, sourceOpacity, mod) => SLOT_ORDERED.redu
opacity
)
)
+ const isLightOnDark = relativeLuminance(bg) > 127
+ const mod = isLightOnDark ? 1 : -1
+
if (value.textColor === 'bw') {
outputColor = contrastRatio(bg).rgb
} else {
let color = { ...colors[deps[0]] }
if (value.color) {
- const isLightOnDark = convert(bg).hsl.l < convert(color).hsl.l
- const mod = isLightOnDark ? 1 : -1
color = value.color(mod, ...deps.map((dep) => ({ ...colors[dep] })))
}