Skip to content

Commit

Permalink
chore(button): remove shape resolver
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 527359555
  • Loading branch information
asyncLiz authored and copybara-github committed Apr 26, 2023
1 parent 5934de0 commit 969cd24
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 78 deletions.
41 changes: 35 additions & 6 deletions button/lib/_elevated-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@
//

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

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

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

@if $value {
--md-elevated-button-#{$token}: #{$value};
}
}
}

Expand All @@ -27,7 +38,25 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-elevated-button-#{$token}, #{$value});
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-elevated-button-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-elevated-button-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-elevated-button-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-elevated-button-container-shape-end-start,
var(--_container-shape)
);
}
}
38 changes: 35 additions & 3 deletions button/lib/_filled-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@
// go/keep-sorted end

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

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

@if $value {
--md-filled-button-#{$token}: #{$value};
}
}
}

Expand All @@ -24,7 +38,25 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-filled-button-#{$token}, #{$value});
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-filled-button-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-filled-button-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-filled-button-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-filled-button-container-shape-end-start,
var(--_container-shape)
);
}
}
41 changes: 35 additions & 6 deletions button/lib/_outlined-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@
//

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

// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

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

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

@if $value {
--md-outlined-button-#{$token}: #{$value};
}
}
}

Expand All @@ -30,8 +41,26 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-outlined-button-#{$token}, #{$value});
}

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

.md3-button__outline {
Expand Down
41 changes: 35 additions & 6 deletions button/lib/_text-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../../sass/theme';
@use '../../tokens';
// go/keep-sorted end

$_custom-property-prefix: 'text-button';

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

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

@if $value {
--md-text-button-#{$token}: #{$value};
}
}
}

Expand All @@ -26,11 +37,29 @@ $_custom-property-prefix: 'text-button';

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-text-button-#{$token}, #{$value});
}

--_container-color: none;
--_disabled-container-color: none;
--_disabled-container-opacity: 0;

// Support logical shape properties
--_container-shape-start-start: var(
--md-text-button-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-text-button-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-text-button-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-text-button-container-shape-end-start,
var(--_container-shape)
);
}
}
41 changes: 34 additions & 7 deletions button/lib/_tonal-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@
@use 'sass:map';
// go/keep-sorted end
// go/keep-sorted start
@use '../../sass/shape';
@use '../../sass/theme';
@use '../../tokens';
// go/keep-sorted end

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

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

@if $value {
--md-tonal-button-#{$token}: #{$value};
}
}
}

Expand All @@ -28,7 +37,25 @@

:host {
@each $token, $value in $tokens {
--_#{$token}: #{$value};
--_#{$token}: var(--md-tonal-button-#{$token}, #{$value});
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-tonal-button-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-tonal-button-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-tonal-button-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-tonal-button-container-shape-end-start,
var(--_container-shape)
);
}
}
9 changes: 0 additions & 9 deletions tokens/_md-comp-elevated-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,5 @@ $_default: (
)
);

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

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
10 changes: 0 additions & 10 deletions tokens/_md-comp-filled-button.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 @@ -105,14 +104,5 @@ $_default: (
)
);

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

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
11 changes: 0 additions & 11 deletions tokens/_md-comp-filled-tonal-button.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 @@ -105,15 +104,5 @@ $_default: (
)
);

@each $token, $value in $tokens {
// TODO: change to filled-tonal-button
$tokens: map.set(
$tokens,
$token,
var(--md-tonal-button-#{$token}, #{$value})
);
}

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
10 changes: 0 additions & 10 deletions tokens/_md-comp-outlined-button.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-shape';
@use './md-sys-state';
Expand Down Expand Up @@ -101,14 +100,5 @@ $_default: (
)
);

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

$tokens: shape.resolve-tokens($tokens, 'container-shape');
@return $tokens;
}
Loading

0 comments on commit 969cd24

Please sign in to comment.