Skip to content

Commit

Permalink
fix(labs): add card support for high contrast mode
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 591038474
  • Loading branch information
asyncLiz authored and copybara-github committed Dec 14, 2023
1 parent 6eb9fe6 commit 53ec44b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions labs/card/internal/_outlined-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
}
}

.container {
border: var(--_outline-width) solid var(--_outline-color);
.outline {
border-color: var(--_outline-color);
border-width: var(--_outline-width);
}
}
21 changes: 17 additions & 4 deletions labs/card/internal/_shared.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,31 @@
z-index: 0;
}

// Separate element will be needed for disabled opacities (b/307361748)
.container {
background: var(--_container-color);
md-elevation,
.background,
.outline {
border-radius: inherit;
inset: 0;
position: absolute;
}

// Separate element will be needed for disabled opacities (b/307361748)
.background {
background: var(--_container-color);
// Place behind content.
z-index: -1;
}

// Separate element needed to overlay on top of content as opposed to
// background, which is behind content. All cards have an outline for HCM.
.outline {
// A default transparent border that is visible in HCM
border: 1px solid transparent;
// Outline should be placed on top of content, such as images.
z-index: 1;
}

md-elevation {
border-radius: inherit;
// Place behind content.
z-index: -1;

Expand Down
3 changes: 2 additions & 1 deletion labs/card/internal/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export class Card extends LitElement {
protected override render() {
return html`
<md-elevation part="elevation"></md-elevation>
<div class="container"></div>
<div class="background"></div>
<slot></slot>
<div class="outline"></div>
`;
}
}

0 comments on commit 53ec44b

Please sign in to comment.