-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
220 additions
and
38 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,46 @@ | ||
.v2-livestream-embed .cookie-message { | ||
aspect-ratio: 16/9; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 16px; | ||
} | ||
|
||
.v2-livestream-embed .cookie-message__title, | ||
.v2-livestream-embed .cookie-message__text { | ||
max-width: var(--text-block-max-width); | ||
margin: 0 auto; | ||
text-align: center; | ||
} | ||
|
||
.v2-livestream-embed .cookie-message__title { | ||
font: var(--f-heading-5-font-size)/var(--f-heading-5-line-height) var(--ff-volvo-novum-medium); | ||
letter-spacing: var(--f-heading-5-letter-spacing); | ||
} | ||
|
||
.v2-livestream-embed .cookie-message__text { | ||
font: var(--f-body-font-size)/var(--f-body-line-height) var(--font-family-body); | ||
} | ||
|
||
.v2-livestream-embed { | ||
border-radius: var(--border-radius); | ||
aspect-ratio: 16/9; | ||
width: 100%; | ||
} | ||
|
||
.v2-livestream-embed iframe { | ||
display: block; | ||
} | ||
|
||
@media screen and (min-width: 1200px) { | ||
.v2-livestream-embed .cookie-message__title { | ||
font-size: var(--f-heading-4-font-size); | ||
line-height: var(--f-heading-4-line-height); | ||
} | ||
|
||
.v2-livestream-embed .cookie-message__text { | ||
font-size: var(--f-body-2-font-size); | ||
line-height: var(--f-body-2-line-height); | ||
} | ||
} |
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,112 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable max-len */ | ||
import { loadScript } from '../../scripts/lib-franklin.js'; | ||
import { createElement, getTextLabel, isExternalVideoAllowed } from '../../scripts/common.js'; | ||
import { updateCookieValue } from '../../scripts/delayed.js'; | ||
|
||
let player; | ||
|
||
function onPlayerReady(event) { | ||
console.log('ready'); | ||
event.target.playVideo(); | ||
} | ||
|
||
function onPlayerError(event) { | ||
console.log(event); | ||
} | ||
|
||
function onPlayerAutoplayBlocked(event) { | ||
console.log(event); | ||
} | ||
|
||
export function playVideo() { | ||
if (player && player.playVideo) { | ||
player.playVideo(); | ||
} | ||
} | ||
|
||
export default function decorate(block) { | ||
loadScript('https://www.youtube.com/iframe_api'); | ||
|
||
let [videoLink] = block.querySelectorAll('a'); | ||
const [, videoId] = videoLink.getAttribute('href').split('/embed/'); | ||
const [videoCode] = videoId.split('?'); | ||
videoLink = videoCode; | ||
|
||
console.log(videoLink); | ||
|
||
if (!videoLink) { | ||
block.innerHTML = ''; | ||
/* eslint-disable-next-line no-console */ | ||
console.warn('V2 Livestream Embed block: There is no video link. Please check the provided URL.'); | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line func-names | ||
window.onYouTubeIframeAPIReady = function () { | ||
console.log('onYouTubeIframeAPIReady'); | ||
|
||
if (window.YT) { | ||
console.log('window.YT available'); | ||
} | ||
|
||
// eslint-disable-next-line no-undef | ||
player = new YT.Player('ytvideo', { | ||
events: { | ||
onReady: onPlayerReady, | ||
onError: onPlayerError, | ||
onAutoplayBlocked: onPlayerAutoplayBlocked, | ||
}, | ||
}); | ||
|
||
console.log(player); | ||
}; | ||
|
||
// if (!isExternalVideoAllowed()) { | ||
// const img = block.querySelector('picture img'); | ||
// block.innerHTML = ''; | ||
|
||
// const cookieMsgContainer = createElement('div', { | ||
// classes: 'cookie-message', | ||
// }); | ||
// cookieMsgContainer.style.background = `linear-gradient(180deg, rgba(0, 0, 0, 0.00) 0%, rgba(0, 0, 0, 0.80) 100%), url(${img.src}) 100% center / cover no-repeat`; | ||
|
||
// const cookieMessage = document.createRange().createContextualFragment(` | ||
// <h3 class="cookie-message__title">${getTextLabel('single video message title')}</h3> | ||
// <p class="cookie-message__text">${getTextLabel('single video message text')}</p> | ||
// <div class="cookie-message__button-container"> | ||
// <button class="primary dark">${getTextLabel('single video message button')}</button> | ||
// <a href="/" class="button secondary dark">${getTextLabel('single video message button deny')}</a> | ||
// </div> | ||
// `); | ||
|
||
// cookieMsgContainer.append(cookieMessage); | ||
// block.append(cookieMsgContainer); | ||
|
||
// block.querySelector('.cookie-message__button-container .primary')?.addEventListener('click', () => { | ||
// const domain = 'localhost'; | ||
// const path = '/'; // assuming root path | ||
// const expirationDate = new Date(); | ||
// expirationDate.setFullYear(expirationDate.getFullYear() + 1); // 1 year from now | ||
// const sameSite = 'Lax'; | ||
|
||
// console.log('updatecookie'); | ||
|
||
// updateCookieValue('OptanonConsent=', 'C0005:0', 'C0005:1', domain, path, expirationDate, sameSite); | ||
// }); | ||
|
||
// return; | ||
// } | ||
|
||
const iframeYT = document.createRange().createContextualFragment(` | ||
<iframe class="v2-livestream-embed" id="ytvideo" | ||
frameborder="0" allowfullscreen="" | ||
src="https://www.youtube.com/embed/${videoLink}?color=white&rel=0&playsinline=1&enablejsapi=1&"> | ||
</iframe> | ||
`); | ||
|
||
block.innerHTML = ''; | ||
|
||
block.append(...iframeYT.childNodes); | ||
} |
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
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