Skip to content

Commit

Permalink
feat(list): add focus indicator in hi-contrast mode
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 317679801
  • Loading branch information
allan-chen authored and copybara-github committed Jun 22, 2020
1 parent 4a1855c commit 8602f1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/mdc-dom/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
/// only visible in high-contrast mode. The target element should be a child of
/// a relatively positioned top-level element (i.e. a ::before pseudo-element).
///
@mixin transparent-border($query: feature-targeting-functions.all()) {
/// @param {number} $border-width - The width of the transparent border.
/// @param {string} $border-style - The style of the transparent border.
///
@mixin transparent-border($border-width: 1px, $border-style: solid, $query: feature-targeting-functions.all()) {
$feat-structure: feature-targeting-functions.create-target($query, structure);

@include feature-targeting-mixins.targets($feat-structure) {
Expand All @@ -37,7 +40,7 @@
height: 100%;
top: 0;
left: 0;
border: 1px solid transparent;
border: $border-width $border-style transparent;
border-radius: inherit;
content: '';
}
Expand Down
10 changes: 10 additions & 0 deletions packages/mdc-list/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@use "sass:list";
@use "sass:map";
@use "@material/density/functions" as density-functions;
@use "@material/dom/mixins" as dom-mixins;
@use "@material/rtl/mixins" as rtl-mixins;
@use "@material/theme/mixins" as theme-mixins;
@use "@material/shape/functions" as shape-functions;
Expand Down Expand Up @@ -84,6 +85,15 @@
@include item-base_;
}

&:not(.mdc-list-item--selected):focus::before {
@include dom-mixins.transparent-border($query: $query);
}

&.mdc-list-item--selected::before {
@include dom-mixins.transparent-border(
$border-width: 3px, $border-style: double, $query: $query);
}

@include list-item-padding-variant(
variables.$textual-variant-config, $query);
@include list-item-height-variant(
Expand Down

0 comments on commit 8602f1b

Please sign in to comment.