Skip to content

Commit

Permalink
Actually use progressive enhancement with a link rather than button (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongustafson committed Jan 28, 2022
1 parent 79f21ea commit 5dfa1ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lite-yt-embed.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ lite-youtube > iframe {

/* play button */
lite-youtube > .lty-playbtn {
display: block;
width: 68px;
height: 48px;
position: absolute;
Expand Down
3 changes: 2 additions & 1 deletion src/lite-yt-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ class LiteYTEmbed extends HTMLElement {
LiteYTEmbed.preconnected = true;
}

addIframe() {
addIframe(e) {
if (this.classList.contains('lyt-activated')) return;
e.preventDefault();
this.classList.add('lyt-activated');

const params = new URLSearchParams(this.getAttribute('params') || []);
Expand Down
6 changes: 3 additions & 3 deletions variants/pe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<link rel="stylesheet" href="../src/lite-yt-embed.css" />
</head>
<body>
<h1>progressively enhanced</h1>
<h1>Progressively Enhanced</h1>
<p>After 2 seconds, the JS is executed and custom element defined.</p>
<p id="done">...</p>

<lite-youtube videoid="ogfYd705cRs" style="background-image: url('https://i.ytimg.com/vi/ogfYd705cRs/hqdefault.jpg');">
<button type="button" class="lty-playbtn">
<a href="https://youtube.com/watch?v=ogfYd705cRs" class="lty-playbtn" title="Play Video">
<span class="lyt-visually-hidden">Play Video: Keynote (Google I/O '18)</span>
</button>
</a>
</lite-youtube>

<script>
Expand Down

0 comments on commit 5dfa1ab

Please sign in to comment.