-
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 video web component to list
PiperOrigin-RevId: 461910693
- Loading branch information
1 parent
e7924eb
commit 261b6ef
Showing
7 changed files
with
134 additions
and
3 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,36 @@ | ||
// | ||
// Copyright 2022 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
@use 'sass:map'; | ||
@use '@material/web/sass/theme'; | ||
@use '@material/web/sass/map-ext'; | ||
@use '../tokens'; | ||
|
||
$light-theme: map-ext.pick( | ||
tokens.md-comp-list-values(), | ||
( | ||
list-item-leading-video-height, | ||
list-item-leading-video-width, | ||
list-item-leading-video-shape | ||
) | ||
); | ||
|
||
$_custom-property-prefix: 'list-item-video'; | ||
|
||
@mixin theme($theme) { | ||
$theme: theme.validate-theme($light-theme, $theme); | ||
$theme: theme.create-theme-vars($theme, $_custom-property-prefix); | ||
|
||
@include theme.emit-theme-vars($theme); | ||
} | ||
|
||
@mixin theme-styles($theme) { | ||
$theme: theme.validate-theme($light-theme, $theme); | ||
$theme: theme.create-theme-vars($theme, $_custom-property-prefix); | ||
|
||
height: map.get($theme, list-item-leading-video-height); | ||
width: map.get($theme, list-item-leading-video-width); | ||
border-radius: map.get($theme, list-item-leading-video-shape); | ||
} |
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__video { | ||
display: inline-flex; | ||
object-fit: cover; | ||
} | ||
} |
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-video'; | ||
@use './list-item-video-theme'; | ||
|
||
:host { | ||
@include list-item-video.static-styles(); | ||
|
||
.md3-list-item__video { | ||
@include list-item-video-theme.theme-styles( | ||
list-item-video-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,24 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {html, LitElement, TemplateResult} from 'lit'; | ||
import {property} from 'lit/decorators'; | ||
import {ifDefined} from 'lit/directives/if-defined'; | ||
|
||
/** @soyCompatible */ | ||
export class ListItemVideo extends LitElement { | ||
@property({type: String, reflect: true}) media = 'video'; | ||
@property({type: String, reflect: true}) video = ''; | ||
@property({type: String, reflect: true}) altText?: string; | ||
|
||
/** @soyTemplate */ | ||
override render(): TemplateResult { | ||
return html` | ||
<img src="${this.video}" alt="${ifDefined(this.altText)}" | ||
class="md3-list-item__video" /> | ||
`; | ||
} | ||
} |
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 {ListItemVideo} from './lib/video/list-item-video'; | ||
import {styles} from './lib/video/list-item-video-styles.css'; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'md-list-item-video': MdListItemVideo; | ||
} | ||
} | ||
|
||
/** | ||
* @soyCompatible | ||
* @final | ||
* @suppress {visibility} | ||
*/ | ||
@customElement('md-list-item-video') | ||
export class MdListItemVideo extends ListItemVideo { | ||
static override styles = [styles]; | ||
} |