-
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
205 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,43 @@ | ||
.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%; | ||
} | ||
|
||
|
||
@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,96 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable max-len */ | ||
import { createElement, getTextLabel, isExternalVideoAllowed } from '../../scripts/common.js'; | ||
import { updateCookieValue } from '../../scripts/delayed.js'; | ||
|
||
function loadYouTubeIframeAPI() { | ||
const tag = document.createElement('script'); | ||
tag.src = 'https://www.youtube.com/iframe_api'; | ||
const firstScriptTag = document.getElementsByTagName('script')[0]; | ||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||
} | ||
|
||
let player; | ||
|
||
function onPlayerReady(event) { | ||
event.target.playVideo(); | ||
} | ||
|
||
export function playVideo() { | ||
if (player && player.playVideo) { | ||
player.playVideo(); | ||
} | ||
} | ||
|
||
export default function decorate(block) { | ||
let [videoLink] = block.querySelectorAll('a'); | ||
const [, videoId] = videoLink.getAttribute('href').split('/embed/'); | ||
const [videoCode] = videoId.split('?'); | ||
videoLink = videoCode; | ||
|
||
// eslint-disable-next-line func-names | ||
window.onYouTubeIframeAPIReady = function () { | ||
// eslint-disable-next-line no-undef | ||
player = new YT.Player('ytvideo', { | ||
height: '', | ||
width: '', | ||
videoId: videoLink, | ||
playerVars: { | ||
color: 'white', | ||
rel: 0, | ||
playsinline: 1, | ||
}, | ||
events: { | ||
onReady: onPlayerReady, | ||
}, | ||
}); | ||
}; | ||
|
||
// 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; | ||
// } | ||
|
||
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; | ||
} | ||
|
||
block.innerHTML = ''; | ||
|
||
block.setAttribute('id', 'ytvideo'); | ||
loadYouTubeIframeAPI(); | ||
} |
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