_slider-theme.scss 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. //
  2. // Copyright 2020 Google Inc.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. // stylelint-disable selector-class-pattern --
  23. // Selector '.mdc-*' should only be used in this project.
  24. @use 'sass:color';
  25. @use 'sass:map';
  26. @use '@material/elevation/elevation-theme';
  27. @use '@material/elevation/mixins' as elevation-mixins;
  28. @use '@material/feature-targeting/feature-targeting';
  29. @use '@material/ripple/ripple-theme';
  30. @use '@material/theme/keys';
  31. @use '@material/theme/map-ext';
  32. @use '@material/theme/state';
  33. @use '@material/theme/theme';
  34. @use '@material/theme/theme-color';
  35. @use '@material/tokens/resolvers';
  36. @use '@material/typography/typography';
  37. /// Default color for slider (track, thumb, ripple).
  38. $color: primary;
  39. $disabled-color: on-surface;
  40. $disabled-slider-opacity: 0.38;
  41. // Thumb variables.
  42. $value-indicator-color: #000;
  43. $value-indicator-opacity: 0.6;
  44. $value-indicator-text-color: on-primary;
  45. // Track variables.
  46. $track-inactive-opacity: 0.24;
  47. $tick-mark-active-color: on-primary;
  48. $tick-mark-inactive-color: primary;
  49. $tick-mark-opacity: 0.6;
  50. $_custom-property-prefix: 'slider';
  51. $light-theme: (
  52. active-track-color: $color,
  53. active-track-height: 6px,
  54. active-track-shape: 9999px,
  55. disabled-active-track-color: $disabled-color,
  56. disabled-handle-color: $disabled-color,
  57. disabled-handle-elevation: null,
  58. disabled-inactive-track-color: $disabled-color,
  59. focus-handle-color: $color,
  60. handle-color: $color,
  61. handle-elevation: 1,
  62. handle-height: 20px,
  63. handle-shadow-color: black,
  64. handle-shape: 50%,
  65. handle-width: 20px,
  66. hover-handle-color: $color,
  67. inactive-track-color: $color,
  68. inactive-track-height: 4px,
  69. inactive-track-shape: 9999px,
  70. label-container-color:
  71. color.mix(
  72. $value-indicator-color,
  73. theme-color.prop-value(on-primary),
  74. $value-indicator-opacity * 100%
  75. ),
  76. label-container-elevation: null,
  77. label-container-height: null,
  78. label-label-text-color: $value-indicator-text-color,
  79. label-label-text-font: typography.get-font(subtitle2),
  80. label-label-text-size: typography.get-size(subtitle2),
  81. label-label-text-line-height: typography.get-line-height(subtitle2),
  82. label-label-text-tracking: typography.get-tracking(subtitle2),
  83. label-label-text-weight: typography.get-weight(subtitle2),
  84. pressed-handle-color: null,
  85. track-elevation: null,
  86. with-overlap-handle-outline-color: #fff,
  87. with-overlap-handle-outline-width: 1px,
  88. with-tick-marks-active-container-color: $tick-mark-active-color,
  89. with-tick-marks-active-container-opacity: $tick-mark-opacity,
  90. with-tick-marks-container-shape: 50%,
  91. with-tick-marks-container-size: 2px,
  92. with-tick-marks-disabled-container-color: $disabled-color,
  93. with-tick-marks-inactive-container-color: $tick-mark-inactive-color,
  94. with-tick-marks-inactive-container-opacity: $tick-mark-opacity,
  95. focus-state-layer-opacity: null,
  96. hover-state-layer-color: null,
  97. hover-state-layer-opacity: null,
  98. pressed-state-layer-opacity: null,
  99. );
  100. @mixin theme($theme, $resolvers: resolvers.$material) {
  101. @include theme.validate-theme($light-theme, $theme);
  102. $theme: _resolve-theme-elevation-keys($theme, $resolvers: $resolvers);
  103. @include keys.declare-custom-properties($theme, $_custom-property-prefix);
  104. }
  105. @mixin theme-styles(
  106. $theme,
  107. $query: feature-targeting.all(),
  108. $resolvers: resolvers.$material
  109. ) {
  110. $feat-color: feature-targeting.create-target($query, color);
  111. $feat-structure: feature-targeting.create-target($query, structure);
  112. $feat-typography: feature-targeting.create-target($query, typography);
  113. @include theme.validate-theme-styles($light-theme, $theme);
  114. $theme: keys.create-theme-properties($theme, $_custom-property-prefix);
  115. @include thumb-color(
  116. $color-or-map: (
  117. default: map.get($theme, 'handle-color'),
  118. disabled: map.get($theme, 'disabled-handle-color'),
  119. ),
  120. $query: $query
  121. );
  122. @include thumb-ripple-color(
  123. $color: map.get($theme, 'handle-color'),
  124. $query: $query
  125. );
  126. @include track-active-color(
  127. $color-or-map: (
  128. default: map.get($theme, 'active-track-color'),
  129. disabled: map.get($theme, 'disabled-active-track-color'),
  130. ),
  131. $query: $query
  132. );
  133. @include track-inactive-color(
  134. $color-or-map: (
  135. default: map.get($theme, 'inactive-track-color'),
  136. disabled: map.get($theme, 'disabled-inactive-track-color'),
  137. ),
  138. $query: $query
  139. );
  140. @include tick-mark-active-color(
  141. $color-or-map: (
  142. default: map.get($theme, 'with-tick-marks-active-container-color'),
  143. disabled: map.get($theme, 'with-tick-marks-active-container-color'),
  144. ),
  145. $opacity: map.get($theme, 'with-tick-marks-active-container-opacity'),
  146. $query: $query
  147. );
  148. @include tick-mark-inactive-color(
  149. $color-or-map: (
  150. default: map.get($theme, 'with-tick-marks-inactive-container-color'),
  151. disabled: map.get($theme, 'with-tick-marks-disabled-container-color'),
  152. ),
  153. $opacity: map.get($theme, 'with-tick-marks-inactive-container-opacity'),
  154. $query: $query
  155. );
  156. @include value-indicator-color(
  157. $color: map.get($theme, 'label-container-color'),
  158. $opacity: 1,
  159. $query: $query
  160. );
  161. @include value-indicator-text-color(
  162. $color: map.get($theme, 'label-label-text-color'),
  163. $query: $query
  164. );
  165. .mdc-slider__track {
  166. @include feature-targeting.targets($feat-structure) {
  167. @include theme.property(height, map.get($theme, 'inactive-track-height'));
  168. }
  169. }
  170. .mdc-slider__track--active {
  171. @include feature-targeting.targets($feat-structure) {
  172. @include theme.property(height, map.get($theme, 'active-track-height'));
  173. @include theme.property(
  174. top,
  175. // Using 'xactive' because string replace finds 'active' in 'inactive'
  176. 'calc((inactive-track-height - xactive-track-height) / 2)',
  177. $replace: (
  178. 'inactive-track-height': map.get($theme, 'inactive-track-height'),
  179. 'xactive-track-height': map.get($theme, 'active-track-height')
  180. )
  181. );
  182. }
  183. }
  184. .mdc-slider__track--active_fill {
  185. @include feature-targeting.targets($feat-structure) {
  186. // Use border rather than background-color to fill track, for HCM.
  187. @include theme.property(
  188. border-top-width,
  189. map.get($theme, 'active-track-height')
  190. );
  191. }
  192. }
  193. .mdc-slider__track--inactive {
  194. @include feature-targeting.targets($feat-structure) {
  195. @include theme.property(height, map.get($theme, 'inactive-track-height'));
  196. }
  197. }
  198. .mdc-slider__tick-mark--active,
  199. .mdc-slider__tick-mark--inactive {
  200. @include feature-targeting.targets($feat-structure) {
  201. @include theme.property(
  202. height,
  203. map.get($theme, 'with-tick-marks-container-size')
  204. );
  205. @include theme.property(
  206. width,
  207. map.get($theme, 'with-tick-marks-container-size')
  208. );
  209. }
  210. }
  211. @include disabled-slider-opacity($disabled-slider-opacity, $query);
  212. @include _value-indicator-typography($theme, $feat-typography);
  213. @include _slider-shape($theme, $feat-structure);
  214. @include _slider-elevation($theme, $resolvers, $query);
  215. @include _thumb-activated-theme-color($theme, $query);
  216. @include _thumb-overlap($theme, $query);
  217. @include _thumb-state-layer($theme);
  218. }
  219. /// Customizes active track color, using a Color or state Map.
  220. /// - To set only the default color, provide a single Color.
  221. /// - To set one or more state colors, provide a state Map with optional keys.
  222. /// - Supported state Map keys: `default`, `disabled`.
  223. ///
  224. /// @example
  225. /// @include track-active-color(blue);
  226. /// @include track-active-color((disabled: gray));
  227. ///
  228. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  229. @mixin track-active-color($color-or-map, $query: feature-targeting.all()) {
  230. @include _set-track-active-color(
  231. state.get-default-state($color-or-map),
  232. $query
  233. );
  234. $_disabled-color: state.get-disabled-state($color-or-map);
  235. @if $_disabled-color {
  236. &.mdc-slider--disabled {
  237. @include _set-track-active-color($_disabled-color, $query);
  238. }
  239. }
  240. }
  241. @mixin _set-track-active-color($color, $query) {
  242. $feat-color: feature-targeting.create-target($query, color);
  243. .mdc-slider__track--active_fill {
  244. @include feature-targeting.targets($feat-color) {
  245. @include theme.property(border-color, $color);
  246. }
  247. }
  248. }
  249. /// Customizes inactive track color, using a Color or state Map.
  250. /// - To set only the default color, provide a single Color.
  251. /// - To set one or more state colors, provide a state Map with optional keys.
  252. /// - Supported state Map keys: `default`, `disabled`.
  253. ///
  254. /// @example
  255. /// @include track-inactive-color(blue);
  256. /// @include track-inactive-color((disabled: gray));
  257. ///
  258. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  259. @mixin track-inactive-color(
  260. $color-or-map,
  261. $opacity: $track-inactive-opacity,
  262. $query: feature-targeting.all()
  263. ) {
  264. @include _set-track-inactive-color(
  265. state.get-default-state($color-or-map),
  266. $opacity,
  267. $query
  268. );
  269. $_disabled-color: state.get-disabled-state($color-or-map);
  270. @if $_disabled-color {
  271. &.mdc-slider--disabled {
  272. @include _set-track-inactive-color($_disabled-color, $opacity, $query);
  273. }
  274. }
  275. }
  276. @mixin _set-track-inactive-color($color, $opacity, $query) {
  277. $feat-color: feature-targeting.create-target($query, color);
  278. .mdc-slider__track--inactive {
  279. @include feature-targeting.targets($feat-color) {
  280. @include theme.property(background-color, $color);
  281. opacity: $opacity;
  282. }
  283. }
  284. }
  285. /// Customizes thumb color, using a Color or state Map.
  286. /// - To set only the default color, provide a single Color.
  287. /// - To set one or more state colors, provide a state Map with optional keys.
  288. /// - Supported state Map keys: `default`, `disabled`.
  289. ///
  290. /// @example
  291. /// @include thumb-color(blue);
  292. /// @include thumb-color((disabled: gray));
  293. ///
  294. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  295. @mixin thumb-color($color-or-map, $query: feature-targeting.all()) {
  296. @include _set-thumb-color(state.get-default-state($color-or-map), $query);
  297. $_disabled-color: state.get-disabled-state($color-or-map);
  298. @if $_disabled-color {
  299. &.mdc-slider--disabled {
  300. @include _set-thumb-color($_disabled-color, $query);
  301. }
  302. }
  303. }
  304. @mixin _set-thumb-color($color, $query) {
  305. $feat-color: feature-targeting.create-target($query, color);
  306. @include feature-targeting.targets($feat-color) {
  307. .mdc-slider__thumb-knob {
  308. @include theme.property(background-color, $color);
  309. @include theme.property(border-color, $color);
  310. }
  311. .mdc-slider__thumb--top {
  312. .mdc-slider__thumb-knob,
  313. &.mdc-slider__thumb:hover .mdc-slider__thumb-knob,
  314. &.mdc-slider__thumb--focused .mdc-slider__thumb-knob {
  315. border-color: #fff;
  316. }
  317. }
  318. }
  319. }
  320. ///
  321. /// Customizes thumb ripple color.
  322. /// @param {Color | String} $color Either a valid color value or a key from
  323. /// `$theme-variables.property-values`.
  324. ///
  325. @mixin thumb-ripple-color($color, $query: feature-targeting.all()) {
  326. .mdc-slider__thumb {
  327. @include ripple-theme.states($color: $color, $query: $query);
  328. }
  329. }
  330. /// Customizes thumb color when thumb is activated (hover, focused, or pressed
  331. /// state).
  332. ///
  333. /// @param {Color} $color - The thumb's color
  334. @mixin thumb-activated-color($color, $query: feature-targeting.all()) {
  335. $feat-color: feature-targeting.create-target($query, color);
  336. .mdc-slider__thumb:hover,
  337. .mdc-slider__thumb--focused {
  338. @include _set-thumb-color($color, $query);
  339. }
  340. }
  341. /// Customizes color of active tick marks, using a Color or state Map.
  342. /// - To set only the default color, provide a single Color.
  343. /// - To set one or more state colors, provide a state Map with optional keys.
  344. /// - Supported state Map keys: `default`, `disabled`.
  345. ///
  346. /// @example
  347. /// @include tick-mark-active-color(blue);
  348. /// @include tick-mark-active-color((disabled: gray));
  349. ///
  350. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  351. @mixin tick-mark-active-color(
  352. $color-or-map,
  353. $opacity: $tick-mark-opacity,
  354. $query: feature-targeting.all()
  355. ) {
  356. @include _set-tick-mark-active-color(
  357. state.get-default-state($color-or-map),
  358. $opacity,
  359. $query
  360. );
  361. $_disabled-color: state.get-disabled-state($color-or-map);
  362. @if $_disabled-color {
  363. &.mdc-slider--disabled {
  364. @include _set-tick-mark-active-color($_disabled-color, $opacity, $query);
  365. }
  366. }
  367. }
  368. @mixin _set-tick-mark-active-color($color, $opacity, $query) {
  369. $feat-color: feature-targeting.create-target($query, color);
  370. .mdc-slider__tick-mark--active {
  371. @include feature-targeting.targets($feat-color) {
  372. @include theme.property(background-color, $color);
  373. @include theme.property(opacity, $opacity);
  374. }
  375. }
  376. }
  377. /// Customizes color of inactive tick marks, using a Color or state Map.
  378. /// - To set only the default color, provide a single Color.
  379. /// - To set one or more state colors, provide a state Map with optional keys.
  380. /// - Supported state Map keys: `default`, `disabled`.
  381. ///
  382. /// @example
  383. /// @include tick-mark-inactive-color(blue);
  384. /// @include tick-mark-inactive-color((disabled: gray));
  385. ///
  386. /// @param {Color | Map} $color-or-map - The label's color or a state Map
  387. @mixin tick-mark-inactive-color(
  388. $color-or-map,
  389. $opacity: $tick-mark-opacity,
  390. $query: feature-targeting.all()
  391. ) {
  392. @include _set-tick-mark-inactive-color(
  393. state.get-default-state($color-or-map),
  394. $opacity,
  395. $query
  396. );
  397. $_disabled-color: state.get-disabled-state($color-or-map);
  398. @if $_disabled-color {
  399. &.mdc-slider--disabled {
  400. @include _set-tick-mark-inactive-color(
  401. $_disabled-color,
  402. $opacity,
  403. $query
  404. );
  405. }
  406. }
  407. }
  408. @mixin _set-tick-mark-inactive-color($color, $opacity, $query) {
  409. $feat-color: feature-targeting.create-target($query, color);
  410. .mdc-slider__tick-mark--inactive {
  411. @include feature-targeting.targets($feat-color) {
  412. @include theme.property(background-color, $color);
  413. @include theme.property(opacity, $opacity);
  414. }
  415. }
  416. }
  417. ///
  418. /// Customizes color and opacity of the value indicator.
  419. /// @param {Color | String} $color Either a valid color value or a key from
  420. /// `$theme-variables.property-values`.
  421. /// @param {number} $opacity
  422. ///
  423. @mixin value-indicator-color(
  424. $color,
  425. $opacity,
  426. $query: feature-targeting.all()
  427. ) {
  428. $feat-color: feature-targeting.create-target($query, color);
  429. .mdc-slider__value-indicator {
  430. @include feature-targeting.targets($feat-color) {
  431. @include theme.property(background-color, $color);
  432. opacity: $opacity;
  433. }
  434. }
  435. // Caret.
  436. .mdc-slider__value-indicator::before {
  437. @include feature-targeting.targets($feat-color) {
  438. @include theme.property(border-top-color, $color);
  439. }
  440. }
  441. }
  442. ///
  443. /// Customizes color of the value indicator text.
  444. /// @param {Color | String} $color Either a valid color value or a key from
  445. /// `$theme-variables.property-values`.
  446. ///
  447. @mixin value-indicator-text-color($color, $query: feature-targeting.all()) {
  448. $feat-color: feature-targeting.create-target($query, color);
  449. .mdc-slider__value-indicator {
  450. @include feature-targeting.targets($feat-color) {
  451. @include theme.property(color, $color);
  452. }
  453. }
  454. }
  455. @mixin disabled-slider-opacity($opacity, $query: feature-targeting.all()) {
  456. $feat-color: feature-targeting.create-target($query, color);
  457. &.mdc-slider--disabled {
  458. @include feature-targeting.targets($feat-color) {
  459. @include theme.property(opacity, $opacity);
  460. }
  461. }
  462. }
  463. @mixin _value-indicator-typography($theme, $query: feature-targeting.all()) {
  464. $font: map.get($theme, 'label-label-text-font');
  465. $size: map.get($theme, 'label-label-text-size');
  466. $tracking: map.get($theme, 'label-label-text-tracking');
  467. $weight: map.get($theme, 'label-label-text-weight');
  468. $line-height: map.get($theme, 'label-label-text-line-height');
  469. .mdc-slider__value-indicator-text {
  470. @include feature-targeting.targets($query) {
  471. @include theme.property(letter-spacing, $tracking);
  472. @include theme.property(font-size, $size);
  473. @include theme.property(font-family, $font);
  474. @include theme.property(font-weight, $weight);
  475. @include theme.property(line-height, $line-height);
  476. }
  477. }
  478. }
  479. @mixin _slider-shape($theme, $query: feature-targeting.all()) {
  480. $active-track-radius: map.get($theme, 'active-track-shape');
  481. $inactive-track-radius: map.get($theme, 'inactive-track-shape');
  482. $thumb-radius: map.get($theme, 'handle-shape');
  483. $thumb-width: map.get($theme, 'handle-width');
  484. $thumb-height: map.get($theme, 'handle-height');
  485. $with-tick-marks-radius: map.get($theme, 'with-tick-marks-container-shape');
  486. .mdc-slider__track--active {
  487. @include feature-targeting.targets($query) {
  488. // Set border-radius on the outer `track--active` element, and apply
  489. // transform: scale(...) to the inner `track--active_fill` element,
  490. // such that the track grows/shrinks as needed, but the border-radius
  491. // is not affected by the scaling.
  492. @include theme.property(border-radius, $active-track-radius);
  493. }
  494. }
  495. .mdc-slider__track--inactive {
  496. @include feature-targeting.targets($query) {
  497. @include theme.property(border-radius, $inactive-track-radius);
  498. }
  499. }
  500. .mdc-slider__thumb-knob {
  501. @include feature-targeting.targets($query) {
  502. @include theme.property(border-radius, $thumb-radius);
  503. @include theme.property(width, $thumb-width);
  504. @include theme.property(height, $thumb-height);
  505. @include theme.property(border-style, solid);
  506. // Use border rather than background-color to fill thumb, for HCM.
  507. @include theme.property(
  508. border-width,
  509. 'calc(thumb-height / 2) calc(thumb-width / 2)',
  510. $replace: (thumb-height: $thumb-height, thumb-width: $thumb-width)
  511. );
  512. }
  513. }
  514. .mdc-slider__tick-mark--active,
  515. .mdc-slider__tick-mark--inactive {
  516. @include feature-targeting.targets($query) {
  517. @include theme.property(border-radius, $with-tick-marks-radius);
  518. }
  519. }
  520. }
  521. @mixin _slider-elevation($theme, $resolver, $query: feature-targeting.all()) {
  522. $thumb-elevation: map.get($theme, 'handle-elevation');
  523. $thumb-shadow-color: map.get($theme, 'handle-shadow-color');
  524. $value-indicator-elevation: keys.resolve(
  525. map.get($theme, 'label-container-elevation')
  526. );
  527. $track-elevation: keys.resolve(map.get($theme, 'track-elevation'));
  528. $disabled-thumb-elevation: keys.resolve(
  529. map.get($theme, 'disabled-handle-elevation')
  530. );
  531. .mdc-slider__thumb-knob {
  532. @include elevation-theme.with-resolver(
  533. map.get($resolver, elevation),
  534. $query,
  535. $elevation: $thumb-elevation,
  536. $shadow-color: $thumb-shadow-color
  537. );
  538. }
  539. .mdc-slider__value-indicator {
  540. @include elevation-mixins.elevation(
  541. $z-value: $value-indicator-elevation,
  542. $query: $query
  543. );
  544. }
  545. .mdc-slider__track {
  546. @include elevation-mixins.elevation(
  547. $z-value: $track-elevation,
  548. $query: $query
  549. );
  550. }
  551. &.mdc-slider--disabled .mdc-slider__thumb-knob {
  552. @include elevation-mixins.elevation(
  553. $z-value: $disabled-thumb-elevation,
  554. $query: $query
  555. );
  556. }
  557. }
  558. @mixin _thumb-activated-theme-color($theme, $query: feature-targeting.all()) {
  559. $hover-color: map.get($theme, 'hover-handle-color');
  560. $focus-color: map.get($theme, 'focus-handle-color');
  561. $pressed-color: map.get($theme, 'pressed-handle-color');
  562. .mdc-slider__thumb {
  563. &:hover {
  564. @include _set-thumb-color($hover-color, $query);
  565. }
  566. &--focused {
  567. @include _set-thumb-color($focus-color, $query);
  568. }
  569. @include ripple-theme.pressed() {
  570. @include _set-thumb-color($pressed-color, $query);
  571. }
  572. }
  573. }
  574. @mixin _thumb-overlap($theme, $query: feature-targeting.all()) {
  575. $feat-color: feature-targeting.create-target($query, color);
  576. $overlap-outline-color: map.get($theme, 'with-overlap-handle-outline-color');
  577. $overlap-outline-width: map.get($theme, 'with-overlap-handle-outline-width');
  578. @include feature-targeting.targets($feat-color) {
  579. .mdc-slider__thumb--top {
  580. .mdc-slider__thumb-knob,
  581. &.mdc-slider__thumb:hover .mdc-slider__thumb-knob,
  582. &.mdc-slider__thumb--focused .mdc-slider__thumb-knob {
  583. @include theme.property(border-color, $overlap-outline-color);
  584. @include theme.property(border-width, $overlap-outline-width);
  585. }
  586. }
  587. }
  588. }
  589. @function _resolve-theme-elevation-keys($theme, $resolvers) {
  590. $elevation-resolver: map.get($resolvers, elevation);
  591. $elevation: map.get($theme, handle-elevation);
  592. $shadow-color: map.get($theme, thumb-shadow-color);
  593. @if $elevation-resolver == null or $elevation == null or $shadow-color == null
  594. {
  595. @return $theme;
  596. }
  597. $resolved-value: meta.call(
  598. $resolver,
  599. $elevation: $elevation,
  600. $shadow-color: $shadow-color
  601. );
  602. @return map.set($theme, $key, $resolved-value);
  603. }
  604. @mixin _thumb-state-layer($theme) {
  605. .mdc-slider__thumb {
  606. @include ripple-theme.theme-styles(
  607. (
  608. focus-state-layer-opacity: map.get($theme, 'focus-state-layer-opacity'),
  609. hover-state-layer-color: map.get($theme, 'hover-state-layer-color'),
  610. hover-state-layer-opacity: map.get($theme, 'hover-state-layer-opacity'),
  611. pressed-state-layer-opacity:
  612. map.get($theme, 'pressed-state-layer-opacity'),
  613. )
  614. );
  615. }
  616. }