Skip to content

Commit

Permalink
fix: Focus ring radius
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 559992320
  • Loading branch information
material-web-copybara authored and copybara-github committed Aug 25, 2023
1 parent 0270229 commit be42690
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/mdc-button/_button-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
}
}

.mdc-button__focus-ring {
#{focus-ring.$focus-target} {
@include focus-ring.focus-ring($query: $query);
@include feature-targeting.targets($feat-structure) {
display: none;
}
}

@include ripple-theme.focus {
.mdc-button__focus-ring {
#{focus-ring.$focus-target} {
@include dom.forced-colors-mode($exclude-ie11: true) {
@include feature-targeting.targets($feat-structure) {
display: block;
Expand Down
14 changes: 14 additions & 0 deletions packages/mdc-button/_button-shared-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,20 @@ $disabled-container-color: rgba(
$query: $query
);

$radius-value: $radius;
@if custom-properties.is-custom-prop($radius) {
$radius-value: custom-properties.get-declaration-value($radius);
}

@if $radius-value != 0 and type-of($radius-value) == 'number' {
#{focus-ring.$focus-target} {
@include focus-ring.focus-ring-radius(
$ring-radius: $radius-value,
$query: $query
);
}
}

#{button-ripple.$ripple-target} {
@include shape-mixins.radius(
$radius,
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-focus-ring/_focus-ring.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
@use '@material/rtl/rtl';
@use '@material/dom/dom';

$focus-target: '.mdc-button__focus-ring';

$ring-radius-default: 8px !default;
$inner-ring-width-default: 2px !default;
$inner-ring-color-default: transparent !default;
Expand Down Expand Up @@ -70,7 +72,7 @@ $container-outer-padding-default: 2px !default;
@include feature-targeting.targets($feat-structure) {
pointer-events: none;
border: $inner-ring-width solid $inner-ring-color;
border-radius: $ring-radius - $outer-ring-width;
border-radius: calc($ring-radius - $outer-ring-width);
box-sizing: content-box;
position: absolute;
top: 50%;
Expand Down Expand Up @@ -133,7 +135,7 @@ $container-outer-padding-default: 2px !default;
$feat-structure: feature-targeting.create-target($query, structure);

@include feature-targeting.targets($feat-structure) {
border-radius: $ring-radius - $outer-ring-width;
border-radius: calc($ring-radius - $outer-ring-width);

&::after {
border-radius: $ring-radius;
Expand Down

0 comments on commit be42690

Please sign in to comment.