Skip to content

Commit

Permalink
feat(focus-ring, button): Match focus ring shape to button shape
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Button shape properties are now of the form `--md-text-button-container-shape-start-start`

PiperOrigin-RevId: 497196760
  • Loading branch information
dfreedm authored and copybara-github committed Dec 22, 2022
1 parent 10af36a commit 7fad3a5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
6 changes: 6 additions & 0 deletions button/lib/_elevated-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../../sass/resolvers';
@use '../../sass/theme';
@use '../../sass/typography';
@use '../../sass/shape';
@use '../../tokens';
@use './elevation';
@use './shared';
Expand Down Expand Up @@ -53,5 +54,10 @@ $_custom-property-prefix: 'elevated-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}
6 changes: 6 additions & 0 deletions button/lib/_filled-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../../sass/resolvers';
@use '../../sass/theme';
@use '../../sass/typography';
@use '../../sass/shape';
@use '../../tokens';
@use './elevation';
@use './shared';
Expand Down Expand Up @@ -49,5 +50,10 @@ $_custom-property-prefix: 'filled-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}
11 changes: 10 additions & 1 deletion button/lib/_outlined-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../../sass/resolvers';
@use '../../sass/theme';
@use '../../sass/typography';
@use '../../sass/shape';
@use '../../tokens';
@use './shared';

Expand Down Expand Up @@ -51,7 +52,10 @@ $_custom-property-prefix: 'outlined-button';
position: absolute;
box-sizing: border-box;
border-color: var(--_outline-color);
border-radius: var(--_container-shape);
border-start-start-radius: var(--_container-shape-start-start);
border-start-end-radius: var(--_container-shape-start-end);
border-end-start-radius: var(--_container-shape-end-start);
border-end-end-radius: var(--_container-shape-end-end);

.md3-button:active & {
border-color: var(--_pressed-outline-color);
Expand Down Expand Up @@ -83,5 +87,10 @@ $_custom-property-prefix: 'outlined-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return $tokens;
}
22 changes: 16 additions & 6 deletions button/lib/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@use '../../sass/dom';
@use '../../sass/typography';
@use '../../sass/resolvers';
@use '../../focus/focus-ring';

@mixin styles() {
:host {
Expand All @@ -35,16 +36,22 @@
pressed-state-layer-opacity: var(--_pressed-state-layer-opacity),
)
);

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

:host([disabled]) {
cursor: default;
pointer-events: none;

border-start-start-radius: var(
--md-comp-button-shape-start-start,
var(--md-comp-button-shape)
);
}

.md3-button {
Expand Down Expand Up @@ -108,7 +115,10 @@

.md3-button,
.md3-button__ripple {
border-radius: var(--_container-shape);
border-start-start-radius: var(--_container-shape-start-start);
border-start-end-radius: var(--_container-shape-start-end);
border-end-start-radius: var(--_container-shape-end-start);
border-end-end-radius: var(--_container-shape-end-end);
}

md-elevation,
Expand Down
6 changes: 6 additions & 0 deletions button/lib/_text-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../../sass/resolvers';
@use '../../sass/theme';
@use '../../sass/typography';
@use '../../sass/shape';
@use '../../tokens';
@use './shared';

Expand Down Expand Up @@ -54,5 +55,10 @@ $_custom-property-prefix: 'text-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return $tokens;
}
6 changes: 6 additions & 0 deletions button/lib/_tonal-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@use '../../sass/resolvers';
@use '../../sass/theme';
@use '../../sass/typography';
@use '../../sass/shape';
@use '../../tokens';
@use './elevation';
@use './shared';
Expand Down Expand Up @@ -52,5 +53,10 @@ $_custom-property-prefix: 'tonal-button';
map.get(resolvers.$material, 'typography'),
'label-text'
);
$tokens: shape.resolve-theme(
$tokens,
map.get(resolvers.$material, 'shape'),
'container-shape'
);
@return elevation.resolve-tokens($tokens);
}

0 comments on commit 7fad3a5

Please sign in to comment.