Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets 33680 #26

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions blocks/gmo-landing-page/gmo-landing-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,27 @@
color: #505050;
}

.gmo-landing-page p a:any-link {
color: #035fe6;
transition:
color 0.2s;
}

.gmo-landing-page p a:hover {
color: #136ff6;
}

.gmo-landing-page p a:active {
color: #035fe6;
}

.gmo-landing-page .video-background {
position: relative;
width: 100%;
display: flex;
justify-content: center;
}

.gmo-landing-page .video-background video {
position: relative;
top: 0;
Expand Down
49 changes: 46 additions & 3 deletions blocks/gmo-landing-page/gmo-landing-page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
import { readBlockConfig } from '../../scripts/lib-franklin.js';

async function waitForVideoLoad() {
const video = document.querySelector('.desktop');

Check failure on line 4 in blocks/gmo-landing-page/gmo-landing-page.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
return new Promise((resolve) => {

Check failure on line 5 in blocks/gmo-landing-page/gmo-landing-page.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4
video.oncanplaythrough = () => {

Check failure on line 6 in blocks/gmo-landing-page/gmo-landing-page.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 8
resolve();

Check failure on line 7 in blocks/gmo-landing-page/gmo-landing-page.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 12
};

Check failure on line 8 in blocks/gmo-landing-page/gmo-landing-page.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 8
});
}

async function getVideoColor(){
const video = document.querySelector('.desktop');
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d', { willReadFrequently: true });
await waitForVideoLoad();

canvas.width = video.videoWidth;
canvas.height = video.videoHeight;

let hexColorOld = null;

// Capture the video frame and extract the color information at the specified interval
setInterval(() => {
context.drawImage(video, 0, 0, canvas.width, canvas.height);
const pixelData = context.getImageData(10, 10, canvas.width, canvas.height).data;
const red = pixelData[0];
const green = pixelData[1];
const blue = pixelData[2];
const hexColor = '#' + ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);

if (hexColorOld !== hexColor) {
hexColorOld = hexColor;
let linkActive = document.querySelector('.gmo-landing-page p a');
if (hexColor == '#000000') {
return linkActive.style.color = '#AEDBFE';
}
linkActive.style.color = '#035FE6';
}
}, 500);
}

export default async function decorate(block) {
const host = location.origin;
const signInMsg = getSignInMsg(block);
Expand All @@ -8,10 +48,11 @@

block.innerHTML=`
<div class="video-background">
<video autoplay loop muted playsinline class="desktop">
<video autoplay loop muted playsinline class="desktop" crossorigin="anonymous">
<source src="${config.videodesktop}" type="video/mp4">

</video>
<video autoplay loop muted playsinline class="mobile">
<video autoplay loop muted playsinline class="mobile" crossorigin="anonymous">
<source src="${config.videomobile}" type="video/mp4">
</video>
</div>
Expand All @@ -32,6 +73,7 @@
</div>`
const msgParent = block.querySelector(".signin-notif");
msgParent.append(signInMsg);
getVideoColor();
}

function getSignInMsg(block) {
Expand All @@ -42,4 +84,5 @@
}
});
return msgDiv;
}
}

12 changes: 12 additions & 0 deletions blocks/gmo-teaser/gmo-teaser.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
text-transform: none;
}

.gmo-teaser a:any-link {
color: #72B7F9;
}

.gmo-teaser a:hover {
color: #8FCAFC;
}

.gmo-teaser a:active {
color: #AEDBFE;
}

.gmo-teaser .teaser {
background-color: #292929;
color: #efefef;
Expand Down
Loading