Skip to content

Commit

Permalink
chore(chips): remove shape resolver
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 527361614
  • Loading branch information
asyncLiz authored and copybara-github committed Apr 26, 2023
1 parent 969cd24 commit 39acf68
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 60 deletions.
40 changes: 37 additions & 3 deletions chips/lib/_assist-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@
//

// go/keep-sorted start
@use '../../sass/theme';
@use 'sass:list';
// go/keep-sorted end
// go/keep-sorted start
@use '../../tokens';
// go/keep-sorted end

@mixin theme($tokens) {
$tokens: theme.validate-theme(tokens.md-comp-assist-chip-values(), $tokens);
$supported-tokens: list.join(
tokens.$md-comp-assist-chip-supported-tokens,
(
'container-shape-start-start',
'container-shape-start-end',
'container-shape-end-end',
'container-shape-end-start'
)
);

@each $token, $value in $tokens {
--md-assist-chip-#{$token}: #{$value};
@if list.index($supported-tokens, $token) == null {
@error 'Token `#{$token}` is not a supported token.';
}

@if $value {
--md-assist-chip-#{$token}: #{$value};
}
}
}

Expand All @@ -23,5 +39,23 @@
@each $token, $value in $tokens {
--_#{$token}: #{$value};
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-checkbox-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-checkbox-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-checkbox-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-checkbox-shape-end-start,
var(--_container-shape)
);
}
}
40 changes: 37 additions & 3 deletions chips/lib/_filter-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,33 @@
// SPDX-License-Identifier: Apache-2.0
//

// go/keep-sorted start
@use 'sass:list';
// go/keep-sorted end
// go/keep-sorted start
@use '../../ripple/ripple';
@use '../../sass/theme';
@use '../../tokens';
// go/keep-sorted end

@mixin theme($tokens) {
$tokens: theme.validate-theme(tokens.md-comp-filter-chip-values(), $tokens);
$supported-tokens: list.join(
tokens.$md-comp-filter-chip-supported-tokens,
(
'container-shape-start-start',
'container-shape-start-end',
'container-shape-end-end',
'container-shape-end-start'
)
);

@each $token, $value in $tokens {
--md-filter-chip-#{$token}: #{$value};
@if list.index($supported-tokens, $token) == null {
@error 'Token `#{$token}` is not a supported token.';
}

@if $value {
--md-filter-chip-#{$token}: #{$value};
}
}
}

Expand All @@ -24,6 +40,24 @@
@each $token, $value in $tokens {
--_#{$token}: #{$value};
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-checkbox-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-checkbox-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-checkbox-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-checkbox-shape-end-start,
var(--_container-shape)
);
}

.selected {
Expand Down
21 changes: 10 additions & 11 deletions chips/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//

// go/keep-sorted start
@use 'sass:list';
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
Expand Down Expand Up @@ -31,6 +32,15 @@
'pressed-opacity': var(--_pressed-state-layer-opacity),
)
);

@include focus-ring.theme(
(
'shape-start-start': var(--_container-shape-start-start),
'shape-start-end': var(--_container-shape-start-end),
'shape-end-end': var(--_container-shape-end-end),
'shape-end-start': var(--_container-shape-end-start),
)
);
}

.container {
Expand Down Expand Up @@ -135,17 +145,6 @@
opacity: var(--_elevated-disabled-container-opacity);
}

md-focus-ring {
@include focus-ring.theme(
(
'shape-start-start': var(--_container-shape-start-start),
'shape-start-end': var(--_container-shape-start-end),
'shape-end-end': var(--_container-shape-end-end),
'shape-end-start': var(--_container-shape-end-start),
)
);
}

md-ripple {
border-radius: inherit;
}
Expand Down
41 changes: 36 additions & 5 deletions chips/lib/_suggestion-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@
//

// go/keep-sorted start
@use '../../sass/theme';
@use 'sass:list';
// go/keep-sorted end
// go/keep-sorted start
@use '../../tokens';
// go/keep-sorted end

@mixin theme($tokens) {
$tokens: theme.validate-theme(
tokens.md-comp-suggestion-chip-values(),
$tokens
$supported-tokens: list.join(
tokens.$md-comp-suggestion-chip-supported-tokens,
(
'container-shape-start-start',
'container-shape-start-end',
'container-shape-end-end',
'container-shape-end-start'
)
);

@each $token, $value in $tokens {
--md-suggestion-chip-#{$token}: #{$value};
@if list.index($supported-tokens, $token) == null {
@error 'Token `#{$token}` is not a supported token.';
}

@if $value {
--md-suggestion-chip-#{$token}: #{$value};
}
}
}

Expand All @@ -26,5 +39,23 @@
@each $token, $value in $tokens {
--_#{$token}: #{$value};
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-checkbox-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-checkbox-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-checkbox-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-checkbox-shape-end-start,
var(--_container-shape)
);
}
}
9 changes: 0 additions & 9 deletions tokens/_md-comp-assist-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../sass/shape';
@use './md-sys-color';
@use './md-sys-elevation';
@use './md-sys-shape';
Expand Down Expand Up @@ -116,13 +115,5 @@ $_default: (
)
);

@each $token, $value in $tokens {
$tokens: map.set(
$tokens,
$token,
var(--md-assist-chip-#{$token}, #{$value})
);
}
$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
10 changes: 0 additions & 10 deletions tokens/_md-comp-filter-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../sass/shape';
@use './md-sys-color';
@use './md-sys-elevation';
@use './md-sys-shape';
Expand Down Expand Up @@ -225,14 +224,5 @@ $_default: (
)
);

@each $token, $value in $tokens {
$tokens: map.set(
$tokens,
$token,
var(--md-filter-chip-#{$token}, #{$value})
);
}

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
10 changes: 0 additions & 10 deletions tokens/_md-comp-input-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../sass/shape';
@use './md-sys-color';
@use './md-sys-elevation';
@use './md-sys-shape';
Expand Down Expand Up @@ -200,14 +199,5 @@ $_default: (
)
);

@each $token, $value in $tokens {
$tokens: map.set(
$tokens,
$token,
var(--md-input-chip-#{$token}, #{$value})
);
}

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
9 changes: 0 additions & 9 deletions tokens/_md-comp-suggestion-chip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../sass/shape';
@use './md-sys-color';
@use './md-sys-elevation';
@use './md-sys-shape';
Expand Down Expand Up @@ -119,13 +118,5 @@ $_default: (
)
);

@each $token, $value in $tokens {
$tokens: map.set(
$tokens,
$token,
var(--md-suggestion-chip-#{$token}, #{$value})
);
}
$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}

0 comments on commit 39acf68

Please sign in to comment.