Skip to content

Commit

Permalink
feat(slot): added image named slot for poster overrides (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinribeiro authored Nov 14, 2024
1 parent b9334dc commit 0f8039b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
46 changes: 46 additions & 0 deletions demo/slot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"
/>
<title>lite-youtube demo</title>
<script type="module" src="../lite-youtube.js"></script>
<style>
* {
box-sizing: content-box;
}
body {
max-width: 800px;
margin: auto;
}
pre {
width: 100%;
padding: 1em;
overflow-x: scroll;
background-clip: z;
background-color: #eee;
}
.styleIt {
width: 400px;
}
#bigBlock {
height: 600px;
}
</style>
</head>
<body>


&lt;lite-youtube videoid=&quot;guJLfqTFfIw&quot; nocookie&lt;/lite-youtube&gt;
</pre>
<lite-youtube
videoid="guJLfqTFfIw"
>
<img slot="image" src="https://storage.googleapis.com/jdr-public-imgs/pages/page-4-test.jpg">
</lite-youtube>

</body>
</html>
11 changes: 7 additions & 4 deletions lite-youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ export class LiteYTEmbed extends HTMLElement {
cursor: pointer;
}
#fallbackPlaceholder {
#fallbackPlaceholder, slot[name=image]::slotted(*) {
object-fit: cover;
width: 100%;
}
#frame::before {
Expand Down Expand Up @@ -195,9 +196,11 @@ export class LiteYTEmbed extends HTMLElement {
</style>
<div id="frame">
<picture>
<source id="webpPlaceholder" type="image/webp">
<source id="jpegPlaceholder" type="image/jpeg">
<img id="fallbackPlaceholder" referrerpolicy="origin" loading="lazy">
<slot name="image">
<source id="webpPlaceholder" type="image/webp">
<source id="jpegPlaceholder" type="image/jpeg">
<img id="fallbackPlaceholder" referrerpolicy="origin" loading="lazy">
</slot>
</picture>
<button id="playButton"></button>
</div>
Expand Down

0 comments on commit 0f8039b

Please sign in to comment.