Skip to content

Commit

Permalink
feat(list): Add list elevation overlay and overlay color/opacity to t…
Browse files Browse the repository at this point in the history
…heme API.

PiperOrigin-RevId: 468704392
  • Loading branch information
joyzhong authored and copybara-github committed Aug 19, 2022
1 parent d2a1b2e commit ebb9a4b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions list/_list-item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

@forward './lib/listitem/list-item-theme' show
theme;
7 changes: 7 additions & 0 deletions list/_list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

@forward './lib/list-theme' show
theme;
15 changes: 14 additions & 1 deletion list/lib/_list-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
//

@use 'sass:map';
@use '@material/web/elevation/lib/elevation-theme';
@use '@material/web/sass/theme';
@use '@material/web/tokens' as m3-tokens;
@use './tokens';
@use './divider/list-divider-theme';

Expand All @@ -15,6 +17,9 @@ $light-theme: (
map.get(tokens.md-comp-list-values(), 'list-divider-color'),
list-divider-height:
map.get(tokens.md-comp-list-values(), 'list-divider-height'),
container-surface-tint-layer-color:
map.get(m3-tokens.md-sys-color-values-light-dynamic(), 'surface-tint'),
container-elevation-overlay-opacity: 0,
);

@mixin theme($theme) {
Expand All @@ -28,11 +33,19 @@ $light-theme: (
$theme: theme.validate-theme-styles($light-theme, $theme);
$theme: theme.create-theme-vars($theme, list);

background-color: map.get($theme, 'container-color');
@include list-divider-theme.theme(
(
list-divider-color: map.get($theme, 'list-divider-color'),
list-divider-height: map.get($theme, 'list-divider-height'),
)
);
@include elevation-theme.theme-styles(
(
surface-tint-layer-color:
map.get($theme, 'container-surface-tint-layer-color'),
overlay-opacity: map.get($theme, 'container-elevation-overlay-opacity'),
)
);

background-color: map.get($theme, 'container-color');
}
11 changes: 11 additions & 0 deletions list/lib/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
// stylelint-disable selector-class-pattern --
// Selector '.md3-*' should only be used in this project.

@use '@material/web/elevation/lib/elevation-overlay';

@mixin static-styles() {
@include elevation-overlay.static-styles();

:host {
@include host-root;
}

.md3-list {
@include root;

.md3-elevation-overlay {
z-index: 0;
}
}
}

Expand All @@ -27,4 +35,7 @@
min-width: 300px;
outline: none;
padding: 8px 0;
// Add position so the elevation overlay (which is absolutely positioned)
// can be positioned relative to the list root.
position: relative;
}
3 changes: 2 additions & 1 deletion list/lib/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class List extends LitElement {
@action=${this.handleAction}
@keydown=${this.handleKeydown}
>
<slot></slot>
<span><slot></slot></span>
<div class="md3-elevation-overlay"></div>
</ul>
`;
}
Expand Down

0 comments on commit ebb9a4b

Please sign in to comment.