Skip to content

Commit

Permalink
feat: release 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Kobzarev committed May 2, 2024
1 parent fb27abc commit 490cb61
Show file tree
Hide file tree
Showing 13 changed files with 2,728 additions and 2,688 deletions.
64 changes: 35 additions & 29 deletions assets/src/admin/scss/lite-yt-embed.scss
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
/**
* @link https://www.youtube.com/about/brand-resources/#logos-icons-colors
*/
.block-editor-page .wp-block-embed.is-type-video .wp-block-embed__wrapper {
background-color: #282828;
cursor: pointer;
}
.block-editor-page .wp-block-embed.is-type-video .wp-block-embed__wrapper:before {
content: '';
padding-bottom: calc(100% / (16 / 9));
display: block;
}
.block-editor-page .wp-block-embed.is-type-video .wp-block-embed__wrapper:after {
content: '';
display: block;
width: 68px;
height: 48px;
position: absolute;
transform: translate3d(-50%, -50%, 0);
top: 50%;
left: 50%;
z-index: 1;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 68 48"><path fill="%23f00" fill-opacity="0.8" d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z"></path><path d="M 45,24 27,14 27,34" fill="%23fff"></path></svg>');
filter: grayscale(100%);
transition: filter .1s cubic-bezier(0, 0, 0.2, 1);
}
.block-editor-page .wp-block-embed.is-type-video .wp-block-embed__wrapper:hover:after {
filter: none;
}
.block-editor-page .wp-block-embed.is-type-video .wp-block-embed__wrapper iframe {
display: none;
}
.wp-block-embed.is-type-video {
.wp-block-embed__wrapper {
background-color: #282828;
cursor: pointer;
}

.wp-block-embed__wrapper:before {
content: '';
padding-bottom: calc(100% / (16 / 9));
display: block;
}

.wp-block-embed__wrapper:after {
content: '';
display: block;
width: 68px;
height: 48px;
position: absolute;
transform: translate3d(-50%, -50%, 0);
top: 50%;
left: 50%;
z-index: 1;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 68 48"><path fill="%23f00" fill-opacity="0.8" d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z"></path><path d="M 45,24 27,14 27,34" fill="%23fff"></path></svg>');
filter: grayscale(100%);
transition: filter .1s cubic-bezier(0, 0, 0.2, 1);
}

.wp-block-embed__wrapper:hover:after {
filter: none;
}

.wp-block-embed__wrapper iframe {
display: none;
}
}
24 changes: 16 additions & 8 deletions assets/src/frontend/js/lite-yt-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LiteYTEmbed extends HTMLElement {
// Gotta encode the untrusted value
// https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#rule-2---attribute-escape-before-inserting-untrusted-data-into-html-common-attributes
this.videoId = encodeURIComponent(this.getAttribute('video-id'));
this.playerParameters = this.getAttribute('player-parameters');
this.playerSrc = this.getAttribute('player-src');

/**
* Lo, the youtube placeholder image! (aka the thumbnail, poster image, etc)
Expand All @@ -35,9 +35,9 @@ class LiteYTEmbed extends HTMLElement {
* - When doing this, apply referrerpolicy (https://github.com/ampproject/amphtml/pull/3940)
* TODO: Consider using webp if supported, falling back to jpg
*/
this.posterUrl = `https://i.ytimg.com/vi/${this.videoId}/hqdefault.jpg`;
//this.posterUrl = `https://i.ytimg.com/vi/${this.videoId}/hqdefault.jpg`;
// Warm the connection for the poster image
LiteYTEmbed.addPrefetch('preload', this.posterUrl, 'image');
//LiteYTEmbed.addPrefetch('preload', this.posterUrl, 'image');
// TODO: support dynamically setting the attribute via attributeChangedCallback
}

Expand Down Expand Up @@ -90,19 +90,27 @@ class LiteYTEmbed extends HTMLElement {
// Not certain if these ad related domains are in the critical path. Could verify with domain-specific throttling.
LiteYTEmbed.addPrefetch('preconnect', 'https://googleads.g.doubleclick.net');
LiteYTEmbed.addPrefetch('preconnect', 'https://static.doubleclick.net');
LiteYTEmbed.addPrefetch('preconnect', 'https://rutube.ru');

LiteYTEmbed.preconnected = true;
}

addIframe(){
const iframeHTML = `
<iframe width="560" height="315" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen
src="https://www.youtube-nocookie.com/embed/${this.videoId}?autoplay=1&${this.playerParameters}"
></iframe>`;
<iframe
width="560"
height="315"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen"
webkitAllowFullScreen
mozallowfullscreen
allowfullscreen
src="${this.playerSrc}"
></iframe>`;
this.insertAdjacentHTML('beforeend', iframeHTML);
this.classList.add('lyt-activated');
}
}
// Register custome element

// Register custom element
customElements.define('lite-youtube', LiteYTEmbed);
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"require": {
"php": ">=7.4",
"latte/latte": "^2.10",
"ext-json": "*"
}
,
Expand Down
Loading

0 comments on commit 490cb61

Please sign in to comment.