From a40363fc5b32c246be12da4b5daf50b64170873b Mon Sep 17 00:00:00 2001 From: Enlcxx Date: Tue, 14 Dec 2021 10:44:09 -0500 Subject: [PATCH] fix(slider): fix slider contrast --- src/lib/slider/slider.ts | 9 +++++---- src/lib/src/style-utils.ts | 4 ++-- src/lib/themes/minima/base.ts | 8 ++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/lib/slider/slider.ts b/src/lib/slider/slider.ts index f810660da..c4b2fda31 100644 --- a/src/lib/slider/slider.ts +++ b/src/lib/slider/slider.ts @@ -46,8 +46,8 @@ export interface LySliderTheme { */ disabled?: StyleCollection<((classes: LyClasses, color: Color) => StyleTemplate)> | ((classes: LyClasses, color: Color) => StyleTemplate); - color?: StyleCollection<((classes: LyClasses, color: Color) => StyleTemplate)> - | ((classes: LyClasses, color: Color) => StyleTemplate); + color?: StyleCollection<((classes: LyClasses, color: Color, contrast: Color) => StyleTemplate)> + | ((classes: LyClasses, color: Color, contrast: Color) => StyleTemplate); appearance?: { standard?: StyleCollection<((classes: LyClasses) => StyleTemplate)> | ((classes: LyClasses) => StyleTemplate); @@ -483,14 +483,15 @@ export class LySlider implements OnChanges, OnInit, OnDestroy, ControlValueAcces const newStyle = (theme: ThemeVariables & LySliderVariables, ref: ThemeRef) => { const color = theme.colorOf(val); + const contrast = theme.colorOf(`${val}:contrast`); const __ = ref.selectorsOf(STYLES); if (theme.slider && theme.slider.color) { const sliderColor = theme.slider.color; if (sliderColor) { return sliderColor instanceof StyleCollection - ? (sliderColor).setTransformer((_) => _(__, color)).css - : sliderColor(__, color); + ? (sliderColor).setTransformer((_) => _(__, color, contrast)).css + : sliderColor(__, color, contrast); } } throw new Error(`${val} not found in theme.slider.color`); diff --git a/src/lib/src/style-utils.ts b/src/lib/src/style-utils.ts index b9dee75b2..3e8271476 100644 --- a/src/lib/src/style-utils.ts +++ b/src/lib/src/style-utils.ts @@ -129,7 +129,7 @@ function get(obj: Object, path: string[] | string, optional?: string): Color { if (obj instanceof Color) { return obj; } else if (optional) { - return obj[optional] || obj['default']; + return obj[optional] ?? obj['default']; } else { return obj['default']; } @@ -167,7 +167,7 @@ export function withMediaInline( const val = str[index]; if (typeof val === 'number' || val === null || val === undefined) { styleCollection.add(transformer(val, null)); - } if (typeof val === 'string') { + } else if (typeof val === 'string') { parseMediaQueryFromString(val).forEach((_) => { styleCollection.add(transformer(_[0], _[1])); }); diff --git a/src/lib/themes/minima/base.ts b/src/lib/themes/minima/base.ts index 64d87da23..530c21edf 100644 --- a/src/lib/themes/minima/base.ts +++ b/src/lib/themes/minima/base.ts @@ -294,10 +294,14 @@ export class MinimaBase extends LyStyleUtils { vertical, thumbVisible, thumbNotVisible, - sliding - }, color) => lyl `{ + sliding, + thumbLabelValue + }, color, contrast) => lyl `{ & ${track}, & ${thumb}, & ${thumbLabel}, & ${bg}, & ${tick} { background-color: ${color} + ${thumbLabelValue} { + color: ${contrast} + } } &:not(${disabled}) ${thumbContentFocused} ${thumb}::before, &:not(${disabled}) ${thumb}:hover::before { box-shadow: 0 0 0 8px ${color.alpha(.13)}