Skip to content

Commit

Permalink
Feat(web): Switch Slider component to v3 design tokens #DS-1449
Browse files Browse the repository at this point in the history
  • Loading branch information
crishpeen committed Sep 17, 2024
1 parent 2b069f1 commit 0b51161
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $_field-name: 'UNSTABLE_Slider';
--slider-track-background: #{theme.$track-background-hover};
--slider-track-lower-background: #{theme.$track-lower-background-hover};
--slider-thumb-border-color: #{theme.$thumb-border-color-hover};
--slider-thumb-background-image: #{svg.escape(theme.$thumb-background-image-hover)};
--slider-thumb-background-color: #{svg.escape(theme.$thumb-background-color-hover)};
--slider-thumb-box-shadow: #{theme.$thumb-box-shadow-hover};
}
}
Expand All @@ -55,7 +55,7 @@ $_field-name: 'UNSTABLE_Slider';
--slider-track-background: #{theme.$track-background-active};
--slider-track-lower-background: #{theme.$track-lower-background-active};
--slider-thumb-border-color: #{theme.$thumb-border-color-active};
--slider-thumb-background-image: #{svg.escape(theme.$thumb-background-image-active)};
--slider-thumb-background-color: #{svg.escape(theme.$thumb-background-color-active)};
--slider-thumb-box-shadow: #{theme.$thumb-box-shadow-active};
}

Expand Down Expand Up @@ -146,6 +146,7 @@ $_field-name: 'UNSTABLE_Slider';
--slider-track-lower-background: #{theme.$track-lower-background-disabled};
--slider-thumb-border-width: #{theme.$thumb-border-width-disabled};
--slider-thumb-border-color: #{theme.$thumb-border-color-disabled};
--slider-thumb-background-color: #{svg.escape(theme.$thumb-background-color-disabled)};
--slider-thumb-background-image: #{svg.escape(theme.$thumb-background-image-disabled)};
--slider-thumb-box-shadow: #{theme.$thumb-box-shadow-disabled};

Expand Down
68 changes: 35 additions & 33 deletions packages/web/src/scss/components/UNSTABLE_Slider/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
@use '@tokens' as tokens;
@use '@global' as global-tokens;
@use '../../settings/globals';
@use '../../settings/transitions';

$padding: tokens.$space-400;
$row-gap: tokens.$space-600;
$padding: global-tokens.$space-500;
$row-gap: global-tokens.$space-700;
$transition-duration: transitions.$duration-100;
$transition-timing: transitions.$timing-eased-out;

$track-height: tokens.$space-300;
$track-border-radius: tokens.$radius-100;
$track-background: tokens.$border-primary-default;
$track-background-hover: tokens.$border-primary-hover;
$track-background-active: tokens.$border-primary-active;
$track-background-disabled: tokens.$border-primary-disabled;
$track-lower-background: tokens.$action-primary-default;
$track-lower-background-hover: tokens.$action-primary-hover;
$track-lower-background-active: tokens.$action-primary-active;
$track-lower-background-disabled: tokens.$action-primary-disabled;
$track-height: global-tokens.$space-300;
$track-border-radius: global-tokens.$radius-100;
$track-background: var(--#{globals.$prefix}color-border-interactive-default);
$track-background-hover: var(--#{globals.$prefix}color-border-interactive-hover);
$track-background-active: var(--#{globals.$prefix}color-border-interactive-active);
$track-background-disabled: var(--#{globals.$prefix}color-disabled-background);
$track-lower-background: var(--#{globals.$prefix}color-selected-default);
$track-lower-background-hover: var(--#{globals.$prefix}color-selected-default);
$track-lower-background-active: var(--#{globals.$prefix}color-selected-default);
$track-lower-background-disabled: var(--#{globals.$prefix}color-disabled-foreground);

$thumb-width: tokens.$space-700;
$thumb-height: tokens.$space-900;
$thumb-border-width: tokens.$border-width-200;
$thumb-border-width-disabled: tokens.$border-width-100;
$thumb-border-style: tokens.$border-style-100;
$thumb-border-color: tokens.$action-primary-default;
$thumb-border-color-hover: tokens.$action-primary-hover;
$thumb-border-color-active: tokens.$action-primary-active;
$thumb-border-color-disabled: tokens.$action-primary-disabled;
$thumb-border-radius: tokens.$radius-100;
$thumb-background-color: tokens.$background-basic;
$thumb-background-image: url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{$thumb-border-color}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>');
$thumb-background-image-hover: url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{$thumb-border-color-hover}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>');
$thumb-background-image-active: url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{$thumb-border-color-active}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>');
$thumb-background-image-disabled: url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{$thumb-border-color-disabled}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>');
$thumb-background-size: tokens.$space-400 tokens.$space-600;
$thumb-box-shadow: tokens.$shadow-100;
$thumb-box-shadow-hover: tokens.$shadow-200;
$thumb-box-shadow-active: tokens.$shadow-200;
$thumb-width: global-tokens.$space-900;
$thumb-height: global-tokens.$space-1100;
$thumb-border-width: global-tokens.$border-width-200;
$thumb-border-width-disabled: global-tokens.$border-width-100;
$thumb-border-style: solid;
$thumb-border-color: var(--#{globals.$prefix}color-form-field-border-default);
$thumb-border-color-hover: var(--#{globals.$prefix}color-form-field-border-hover);
$thumb-border-color-active: var(--#{globals.$prefix}color-selected-default);
$thumb-border-color-disabled: var(--#{globals.$prefix}color-disabled-foreground);
$thumb-border-radius: global-tokens.$radius-200;
$thumb-background-color: var(--#{globals.$prefix}color-form-field-default);
$thumb-background-color-hover: var(--#{globals.$prefix}color-form-field-hover);
$thumb-background-color-active: var(--#{globals.$prefix}color-form-field-active);
$thumb-background-color-disabled: var(--#{globals.$prefix}color-disabled-background);
$thumb-background-image: var(--#{globals.$prefix}slider-thumb-background-image-url);
$thumb-background-image-disabled: var(--#{globals.$prefix}slider-thumb-disabled-background-image-url);
$thumb-background-size: global-tokens.$space-500 global-tokens.$space-700;
$thumb-box-shadow: global-tokens.$shadow-100;
$thumb-box-shadow-hover: global-tokens.$shadow-200;
$thumb-box-shadow-active: global-tokens.$shadow-200;
$thumb-box-shadow-disabled: none;
$thumb-box-shadow-focus: tokens.$focus;
$thumb-box-shadow-focus: global-tokens.$focus;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
border: var(--slider-thumb-border-width, #{theme.$thumb-border-width}) theme.$thumb-border-style
var(--slider-thumb-border-color, #{theme.$thumb-border-color});
border-radius: theme.$thumb-border-radius;
background: theme.$thumb-background-color
background: var(--slider-thumb-background-color, #{svg.escape(theme.$thumb-background-color)})
var(--slider-thumb-background-image, #{svg.escape(theme.$thumb-background-image)}) no-repeat center /
theme.$thumb-background-size;
box-shadow: var(--slider-thumb-box-shadow, #{theme.$thumb-box-shadow});
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/scss/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
@forward 'UNSTABLE_Avatar';
@forward 'UNSTABLE_EmptyState';
@forward 'UNSTABLE_Section';
@forward 'UNSTABLE_Slider';

// @forward 'UNSTABLE_Slider';
// @forward 'UNSTABLE_Toggle';
8 changes: 1 addition & 7 deletions packages/web/src/scss/tools/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@

// Slider
--#{globals.$prefix}slider-thumb-background-image-url: #{svg.escape(
url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{map.get($themed-tokens, colors, border, interactive, default)}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>')
)};
--#{globals.$prefix}slider-thumb-hover-background-image-url: #{svg.escape(
url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{map.get($themed-tokens, colors, border, interactive, hover)}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>')
)};
--#{globals.$prefix}slider-thumb-active-background-image-url: #{svg.escape(
url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{map.get($themed-tokens, colors, border, interactive, selected)}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>')
url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{map.get($themed-tokens, colors, neutral, content-basic)}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>')
)};
--#{globals.$prefix}slider-thumb-disabled-background-image-url: #{svg.escape(
url('data:image/svg+xml,<svg width="8" height="16" viewBox="0 0 8 16" fill="#{map.get($themed-tokens, colors, disabled, foreground)}" xmlns="http://www.w3.org/2000/svg"><rect x="0" width="8" height="1" rx="0.5" /><rect x="0" y="5" width="8" height="1" rx="0.5" /><rect x="0" y="10" width="8" height="1" rx="0.5" /><rect x="0" y="15" width="8" height="1" rx="0.5" /></svg>')
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/demo-components-compare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const IGNORED_TESTS: string[] = [
'TextArea',
'Toast',
'Tooltip',
'UNSTABLE_Slider',
'UNSTABLE_Toggle',
'UNSTABLE_Truncate',
];
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0b51161

Please sign in to comment.