diff options
| author | Henry Jameson <me@hjkos.com> | 2020-02-07 01:25:26 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2020-02-07 01:25:26 +0200 |
| commit | 611da13a4b252c10f1613d70d877e2d039ba64b7 (patch) | |
| tree | 8eb14e7855d9d0ba595502a3d2d66d4fa3113a36 /src/services/theme_data/theme_data.service.js | |
| parent | e46bb942260d192beb601727519ed90df5c62494 (diff) | |
Better Disabled buttons support. Mammal theme fixes. Implemented proper
context-aware `mod` argument - now checks lightness of "variant" color. needs
retesting tho
Diffstat (limited to 'src/services/theme_data/theme_data.service.js')
| -rw-r--r-- | src/services/theme_data/theme_data.service.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index 49b99148..e9ed3781 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -255,14 +255,17 @@ export const computeDynamicColor = (sourceColor, getColor, mod) => { } /** - * THE function you want to use. Takes provided colors and opacities, mod + * THE function you want to use. Takes provided colors and opacities * value and uses inheritance data to figure out color needed for the slot. */ -export const getColors = (sourceColors, sourceOpacity, mod) => SLOT_ORDERED.reduce(({ colors, opacity }, key) => { +export const getColors = (sourceColors, sourceOpacity) => SLOT_ORDERED.reduce(({ colors, opacity }, key) => { const value = SLOT_INHERITANCE[key] const isObject = typeof value === 'object' const isString = typeof value === 'string' const sourceColor = sourceColors[key] + const variant = value.variant || value.layer || 'bg' + const isLightOnDark = relativeLuminance(colors[variant] || sourceColors[variant]) < 0.5 + const mod = isLightOnDark ? 1 : -1 let outputColor = null if (sourceColor) { // Color is defined in source color @@ -318,7 +321,7 @@ export const getColors = (sourceColors, sourceOpacity, mod) => SLOT_ORDERED.redu opacity ) ) - const isLightOnDark = relativeLuminance(bg) > 127 + const isLightOnDark = relativeLuminance(bg) > 0.5 const mod = isLightOnDark ? 1 : -1 if (value.textColor === 'bw') { |
