Better Disabled buttons support. Mammal theme fixes. Implemented proper

context-aware `mod` argument - now checks lightness of "variant" color. needs
retesting tho
This commit is contained in:
Henry Jameson 2020-02-07 01:25:26 +02:00
parent e46bb94226
commit 611da13a4b
7 changed files with 89 additions and 34 deletions

View file

@ -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') {