| @import '../core/theming/palette'; |
| @import '../core/theming/theming'; |
| @import '../core/typography/typography-utils'; |
| |
| @mixin _mat-slider-inner-content-theme($palette) { |
| .mat-slider-track-fill, |
| .mat-slider-thumb, |
| .mat-slider-thumb-label { |
| background-color: mat-color($palette); |
| } |
| |
| .mat-slider-thumb-label-text { |
| color: mat-color($palette, default-contrast); |
| } |
| |
| .mat-slider-focus-ring { |
| $opacity: 0.2; |
| $color: mat-color($palette, default, $opacity); |
| background-color: $color; |
| |
| // `mat-color` uses `rgba` for the opacity which won't work with |
| // CSS variables so we need to use `opacity` as a fallback. |
| @if (type-of($color) != color) { |
| opacity: $opacity; |
| } |
| } |
| } |
| |
| @mixin mat-slider-color($config-or-theme) { |
| $config: mat-get-color-config($config-or-theme); |
| $primary: map-get($config, primary); |
| $accent: map-get($config, accent); |
| $warn: map-get($config, warn); |
| $background: map-get($config, background); |
| $foreground: map-get($config, foreground); |
| |
| $mat-slider-off-color: mat-color($foreground, slider-off); |
| $mat-slider-off-focused-color: mat-color($foreground, slider-off-active); |
| $mat-slider-disabled-color: mat-color($foreground, slider-off); |
| $mat-slider-labeled-min-value-thumb-color: mat-color($foreground, slider-min); |
| $mat-slider-labeled-min-value-thumb-label-color: mat-color($foreground, slider-off); |
| $mat-slider-tick-opacity: 0.7; |
| $mat-slider-tick-color: mat-color($foreground, base, $mat-slider-tick-opacity); |
| $mat-slider-tick-size: 2px; |
| |
| .mat-slider-track-background { |
| background-color: $mat-slider-off-color; |
| } |
| |
| .mat-primary { |
| @include _mat-slider-inner-content-theme($primary); |
| } |
| |
| .mat-accent { |
| @include _mat-slider-inner-content-theme($accent); |
| } |
| |
| .mat-warn { |
| @include _mat-slider-inner-content-theme($warn); |
| } |
| |
| .mat-slider:hover, |
| .cdk-focused { |
| .mat-slider-track-background { |
| background-color: $mat-slider-off-focused-color; |
| } |
| } |
| |
| .mat-slider-disabled { |
| .mat-slider-track-background, |
| .mat-slider-track-fill, |
| .mat-slider-thumb { |
| background-color: $mat-slider-disabled-color; |
| } |
| |
| &:hover { |
| .mat-slider-track-background { |
| background-color: $mat-slider-disabled-color; |
| } |
| } |
| } |
| |
| .mat-slider-min-value { |
| .mat-slider-focus-ring { |
| $opacity: 0.12; |
| $color: mat-color($foreground, base, $opacity); |
| background-color: $color; |
| |
| // `mat-color` uses `rgba` for the opacity which won't work with |
| // CSS variables so we need to use `opacity` as a fallback. |
| @if (type-of($color) != color) { |
| opacity: $opacity; |
| } |
| } |
| |
| &.mat-slider-thumb-label-showing { |
| .mat-slider-thumb, |
| .mat-slider-thumb-label { |
| background-color: $mat-slider-labeled-min-value-thumb-color; |
| } |
| |
| &.cdk-focused { |
| .mat-slider-thumb, |
| .mat-slider-thumb-label { |
| background-color: $mat-slider-labeled-min-value-thumb-label-color; |
| } |
| } |
| } |
| |
| &:not(.mat-slider-thumb-label-showing) { |
| .mat-slider-thumb { |
| border-color: $mat-slider-off-color; |
| background-color: transparent; |
| } |
| |
| &:hover, |
| &.cdk-focused { |
| .mat-slider-thumb { |
| border-color: $mat-slider-off-focused-color; |
| } |
| |
| &.mat-slider-disabled .mat-slider-thumb { |
| border-color: $mat-slider-disabled-color; |
| } |
| } |
| } |
| } |
| |
| .mat-slider-has-ticks .mat-slider-wrapper::after { |
| border-color: $mat-slider-tick-color; |
| |
| // `mat-color` uses `rgba` for the opacity which won't work with |
| // CSS variables so we need to use `opacity` as a fallback. |
| @if (type-of($mat-slider-tick-color) != color) { |
| opacity: $mat-slider-tick-opacity; |
| } |
| } |
| |
| .mat-slider-horizontal .mat-slider-ticks { |
| background-image: repeating-linear-gradient(to right, $mat-slider-tick-color, |
| $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent); |
| // Firefox doesn't draw the gradient correctly with 'to right' |
| // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1314319). |
| background-image: -moz-repeating-linear-gradient(0.0001deg, $mat-slider-tick-color, |
| $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent); |
| |
| // `mat-color` uses `rgba` for the opacity which won't work with |
| // CSS variables so we need to use `opacity` as a fallback. |
| @if (type-of($mat-slider-tick-color) != color) { |
| opacity: $mat-slider-tick-opacity; |
| } |
| } |
| |
| .mat-slider-vertical .mat-slider-ticks { |
| background-image: repeating-linear-gradient(to bottom, $mat-slider-tick-color, |
| $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent); |
| |
| // `mat-color` uses `rgba` for the opacity which won't work with |
| // CSS variables so we need to use `opacity` as a fallback. |
| @if (type-of($mat-slider-tick-color) != color) { |
| opacity: $mat-slider-tick-opacity; |
| } |
| } |
| } |
| |
| @mixin mat-slider-typography($config-or-theme) { |
| $config: mat-get-typography-config($config-or-theme); |
| .mat-slider-thumb-label-text { |
| font: { |
| family: mat-font-family($config); |
| size: mat-font-size($config, caption); |
| weight: mat-font-weight($config, body-2); |
| } |
| } |
| } |
| |
| @mixin _mat-slider-density($config-or-theme) {} |
| |
| @mixin mat-slider-theme($theme-or-color-config) { |
| $theme: mat-private-legacy-get-theme($theme-or-color-config); |
| @include mat-private-check-duplicate-theme-styles($theme, 'mat-slider') { |
| $color: mat-get-color-config($theme); |
| $density: mat-get-density-config($theme); |
| $typography: mat-get-typography-config($theme); |
| |
| @if $color != null { |
| @include mat-slider-color($color); |
| } |
| @if $density != null { |
| @include _mat-slider-density($density); |
| } |
| @if $typography != null { |
| @include mat-slider-typography($typography); |
| } |
| } |
| } |