Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 6fcd8d4

Browse files
feat(focusring): Extra bottom offset for inward focus ring
PiperOrigin-RevId: 509181976
1 parent 4d62de7 commit 6fcd8d4

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

packages/mdc-focus/_focus-ring-inward-theme.scss

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,33 @@
99
@use './focus-ring-shared-theme';
1010

1111
$_custom-property-prefix: 'focus-ring-inward';
12+
$_ring-extra-offset-bottom-key: 'extra-offset-bottom';
13+
14+
$default-inward-theme: map.merge(
15+
focus-ring-shared-theme.$default-shared-theme,
16+
(
17+
// Extra offset to bottom of focus ring in addition to default ring offset
18+
$_ring-extra-offset-bottom-key: 0px
19+
)
20+
);
1221

1322
/// Generates CSS custom properties that are consumed by the focus ring styles.
1423
/// Intended to be used directly by Material Design customers, as the only
1524
/// formally supported means of customizing the focus ring.
1625
///
17-
/// @param {Map} $theme - A map with one or more of the keys of $default-theme.
26+
/// @param {Map} $theme - A map with one or more of the keys of $default-inward-theme.
1827
@mixin theme($theme) {
19-
$theme: validate.theme(focus-ring-shared-theme.$default-theme, $theme);
28+
$theme: validate.theme($default-inward-theme, $theme);
2029
@include keys.declare-custom-properties($theme, $_custom-property-prefix);
2130
}
2231

23-
@mixin theme-styles($theme: focus-ring-shared-theme.$default-theme) {
24-
$theme: validate.theme-styles(focus-ring-shared-theme.$default-theme, $theme);
32+
@mixin theme-styles($theme: $default-inward-theme) {
33+
$theme: validate.theme-styles($default-inward-theme, $theme);
2534
$theme: keys.create-theme-vars($theme, $_custom-property-prefix);
2635

2736
$ring-color: map.get($theme, focus-ring-shared-theme.$ring-color-key);
2837
$ring-offset: map.get($theme, focus-ring-shared-theme.$ring-offset-key);
38+
$ring-extra-offset-bottom: map.get($theme, $_ring-extra-offset-bottom-key);
2939
$track-width: map.get($theme, focus-ring-shared-theme.$track-width-key);
3040
$target-shape: map.get($theme, focus-ring-shared-theme.$target-shape-key);
3141

@@ -34,7 +44,8 @@ $_custom-property-prefix: 'focus-ring-inward';
3444
/// https://screenshot.googleplex.com/3cYw8Pi8WQNa3h8.png
3545
border: $track-width solid $ring-color;
3646
border-radius: calc($target-shape + $track-width + $ring-offset);
37-
inset-block: calc(-1 * ($ring-offset + $track-width));
47+
inset-block: calc(-1 * ($ring-offset + $track-width))
48+
calc(-1 * ($ring-offset + $track-width + $ring-extra-offset-bottom));
3849
inset-inline: calc(-1 * ($ring-offset + $track-width));
3950

4051
@include _focus-ring-animation-keyframes();

packages/mdc-focus/_focus-ring-outward-theme.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010

1111
$_custom-property-prefix: 'focus-ring-outward';
1212

13+
$default-outward-theme: focus-ring-shared-theme.$default-shared-theme;
14+
1315
/// Generates CSS custom properties that are consumed by the focus ring styles.
1416
/// Intended to be used directly by Material Design customers, as the only
1517
/// formally supported means of customizing the focus ring.
1618
///
17-
/// @param {Map} $theme - A map with one or more of the keys of $default-theme.
19+
/// @param {Map} $theme - A map with one or more of the keys of $default-outward-theme.
1820
@mixin theme($theme) {
19-
$theme: validate.theme(focus-ring-shared-theme.$default-theme, $theme);
21+
$theme: validate.theme($default-outward-theme, $theme);
2022
@include keys.declare-custom-properties($theme, $_custom-property-prefix);
2123
}
2224

23-
@mixin theme-styles($theme: focus-ring-shared-theme.$default-theme) {
24-
$theme: validate.theme-styles(focus-ring-shared-theme.$default-theme, $theme);
25+
@mixin theme-styles($theme: $default-outward-theme) {
26+
$theme: validate.theme-styles($default-outward-theme, $theme);
2527
$theme: keys.create-theme-vars($theme, $_custom-property-prefix);
2628

2729
$ring-color: map.get($theme, focus-ring-shared-theme.$ring-color-key);

packages/mdc-focus/_focus-ring-shared-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $_animation-timing: cubic-bezier(0.2, 0, 0, 1);
1212

1313
$_color-sys: tokens.md-sys-color-values-light();
1414

15-
$default-theme: (
15+
$default-shared-theme: (
1616
$ring-offset-key: 2px,
1717
$track-width-key: 3px,
1818
$ring-color-key: map.get($_color-sys, secondary),

packages/mdc-focus/test/focus-ring-inward-theme.test.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'offset': 2px,
2525
'track-width': 3px,
2626
'target-shape': 5px,
27+
'extra-offset-bottom': 4px,
2728
)
2829
);
2930
}
@@ -33,6 +34,7 @@
3334
--mdc-focus-ring-inward-offset: 2px;
3435
--mdc-focus-ring-inward-track-width: 3px;
3536
--mdc-focus-ring-inward-target-shape: 5px;
37+
--mdc-focus-ring-inward-extra-offset-bottom: 4px;
3638
}
3739
}
3840
}
@@ -50,6 +52,7 @@
5052
'offset': 2px,
5153
'track-width': 3px,
5254
'target-shape': 5px,
55+
'extra-offset-bottom': 0px,
5356
)
5457
);
5558
}
@@ -63,9 +66,14 @@
6366
var(--mdc-focus-ring-inward-offset, 2px)
6467
);
6568
inset-block: calc(
66-
-1 * (var(--mdc-focus-ring-inward-offset, 2px) +
67-
var(--mdc-focus-ring-inward-track-width, 3px))
68-
);
69+
-1 * (var(--mdc-focus-ring-inward-offset, 2px) +
70+
var(--mdc-focus-ring-inward-track-width, 3px))
71+
)
72+
calc(
73+
-1 * (var(--mdc-focus-ring-inward-offset, 2px) +
74+
var(--mdc-focus-ring-inward-track-width, 3px) +
75+
var(--mdc-focus-ring-inward-extra-offset-bottom, 0px))
76+
);
6977
inset-inline: calc(
7078
-1 * (var(--mdc-focus-ring-inward-offset, 2px) +
7179
var(--mdc-focus-ring-inward-track-width, 3px))

0 commit comments

Comments
 (0)