-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): Added avatar web component to list
PiperOrigin-RevId: 461805434
- Loading branch information
1 parent
10c506c
commit 899a4e6
Showing
7 changed files
with
114 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@use 'sass:map'; | ||
@use '@material/web/sass/theme'; | ||
@use '@material/web/sass/map-ext'; | ||
@use '../list-item-theme'; | ||
|
||
$light-theme: map-ext.pick( | ||
list-item-theme.$light-theme, | ||
( | ||
list-item-leading-avatar-color, | ||
list-item-leading-avatar-shape, | ||
list-item-leading-avatar-size | ||
) | ||
); | ||
|
||
@mixin theme-styles($theme) { | ||
$theme: theme.validate-theme($light-theme, $theme); | ||
$theme: theme.create-theme-vars($theme, list); | ||
|
||
@include _shape(map.get($theme, list-item-leading-avatar-shape)); | ||
@include _size(map.get($theme, list-item-leading-avatar-size)); | ||
} | ||
|
||
@mixin _shape($shape) { | ||
border-radius: $shape; | ||
} | ||
|
||
@mixin _size($size) { | ||
height: $size; | ||
width: $size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Copyright 2022 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// stylelint-disable selector-class-pattern -- | ||
// Selector '.md3-*' should only be used in this project. | ||
|
||
@mixin static-styles() { | ||
.md3-list-item__avatar { | ||
display: inline-flex; | ||
margin-inline-start: 16px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Copyright 2022 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
// stylelint-disable selector-class-pattern -- | ||
// Selector '.md3-*' should only be used in this project. | ||
|
||
@use './list-item-avatar'; | ||
@use './list-item-avatar-theme'; | ||
|
||
:host { | ||
@include list-item-avatar.static-styles(); | ||
|
||
.md3-list-item__avatar { | ||
@include list-item-avatar-theme.theme-styles( | ||
list-item-avatar-theme.$light-theme | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {html, LitElement, TemplateResult} from 'lit'; | ||
import {property} from 'lit/decorators'; | ||
|
||
/** @soyCompatible */ | ||
export class ListItemAvatar extends LitElement { | ||
@property({type: String, reflect: true}) avatar = ''; | ||
@property({type: String, reflect: true}) altText = ''; | ||
|
||
/** @soyTemplate */ | ||
override render(): TemplateResult { | ||
return html` | ||
<img src="${this.avatar}" alt="${this.altText}" | ||
class="md3-list-item__avatar" /> | ||
`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {customElement} from 'lit/decorators'; | ||
|
||
import {ListItemAvatar} from './lib/avatar/list-item-avatar'; | ||
import {styles} from './lib/avatar/list-item-avatar-styles.css'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'md-list-item-avatar': MdListItemAvatar; | ||
} | ||
} | ||
|
||
/** | ||
* @soyCompatible | ||
* @final | ||
* @suppress {visibility} | ||
*/ | ||
@customElement('md-list-item-avatar') | ||
export class MdListItemAvatar extends ListItemAvatar { | ||
static override styles = [styles]; | ||
} |