Skip to content

Commit

Permalink
chore: refactor slider tokens to follow best practices
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 546940817
  • Loading branch information
AndrewJakubowicz authored and copybara-github committed Jul 10, 2023
1 parent 7d91950 commit 4ac1f76
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions tokens/_md-comp-slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,50 @@
@use './md-sys-state';
@use './md-sys-typescale';
@use './v0_172/md-comp-slider';
@use './values';
// go/keep-sorted end

$supported-tokens: (
// go/keep-sorted start
'active-track-color',
'active-track-height',
'active-track-shape',
'disabled-active-track-color',
'disabled-active-track-opacity',
'disabled-handle-color',
'disabled-handle-elevation',
'disabled-inactive-track-color',
'disabled-inactive-track-opacity',
'focus-handle-color',
'handle-color',
'handle-elevation',
'handle-height',
'handle-shadow-color',
'handle-shape',
'handle-width',
'hover-handle-color',
'hover-state-layer-color',
'hover-state-layer-opacity',
'inactive-track-color',
'inactive-track-height',
'inactive-track-shape',
'label-container-color',
'label-container-height',
'label-label-text-color',
'label-label-text-type',
'pressed-handle-color',
'pressed-state-layer-color',
'pressed-state-layer-opacity',
'state-layer-size',
'with-overlap-handle-outline-color',
'with-overlap-handle-outline-width',
'with-tick-marks-active-container-color',
'with-tick-marks-container-size',
'with-tick-marks-disabled-container-color',
'with-tick-marks-inactive-container-color',
// go/keep-sorted end
);

$_default: (
'md-sys-color': md-sys-color.values-light(),
'md-sys-elevation': md-sys-elevation.values(),
Expand Down Expand Up @@ -44,8 +86,11 @@ $_unsupported-tokens: (
);

@function values($deps: $_default, $exclude-hardcoded-values: false) {
$tokens: md-comp-slider.values($deps, $exclude-hardcoded-values);
$tokens: map.remove($tokens, $_unsupported-tokens...);
$tokens: values.validate(
md-comp-slider.values($deps, $exclude-hardcoded-values),
$supported-tokens: $supported-tokens,
$unsupported-tokens: $_unsupported-tokens
);

// TODO(b/271876162): remove when tokens compiler emits typescale tokens
$tokens: map.merge(
Expand All @@ -55,5 +100,6 @@ $_unsupported-tokens: (
map.get($deps, 'md-sys-typescale', 'label-medium'),
)
);

@return $tokens;
}

0 comments on commit 4ac1f76

Please sign in to comment.