Skip to content

Feature/logo hero video #174

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions assets-src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {navigation} from "./main/navigation";
import {responsiveTables} from "./main/responsive-tables";
import {flashes} from "./main/flashes";
import {headingAnchors} from './main/heading-anchors';
import {videoHero} from './main/video-hero';

function domLoadedActions() {
accountMenu();
Expand All @@ -17,6 +18,7 @@ function domLoadedActions() {
responsiveTables();
flashes();
headingAnchors();
videoHero();

/* Create a navDoubleLevel object and initiate double-level navigation for a <ul> with the correct data-component attribute */
const navDoubleIntro = document.querySelector('ul[data-component="nav-double-intro"]');
Expand Down
81 changes: 81 additions & 0 deletions assets-src/js/main/video-hero.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
let videoHero = function () {
/* My refactored code */
var heroVid = document.querySelector('[data-video="hero"]');
var heroVidControl = document.querySelector('[data-video-control="hero"]');

if (heroVid && heroVidControl) {
// Remove native controls and show custom button
heroVid.removeAttribute("controls");
heroVidControl.removeAttribute("hidden");

// Media query for reduced motion preference
var motionQuery = window.matchMedia("(prefers-reduced-motion)");

// Helper to update button text
function updateButtonState(isPlaying) {
const label = isPlaying ? "Pause" : "Play";
heroVidControl.querySelector("span").innerText = label;
heroVidControl.classList.toggle("js-play-video", isPlaying);
}

// Play video with error handling
function playHeroVid() {
heroVid.play().then(() => {
updateButtonState(true);
}).catch((error) => {
console.warn("Video play failed:", error);
updateButtonState(false);
});
}

// Pause video
function pauseHeroVid() {
heroVid.pause();
updateButtonState(false);
}

// Handle user motion preference
function handleReduceMotionChanged() {
if (motionQuery.matches) {
pauseHeroVid();
} else {
playHeroVid();
}
}

// Attempt to autoplay
var promise = heroVid.play();
if (promise !== undefined) {
promise
.then(() => {
updateButtonState(true);
})
.catch((error) => {
console.warn("Autoplay was prevented:", error);
updateButtonState(false);
});
}

// Media query listener
motionQuery.addEventListener("change", handleReduceMotionChanged);
handleReduceMotionChanged();

// Toggle video playback on control click
document.addEventListener("click", function (event) {
const button = event.target.closest('[data-video-control="hero"]');
if (button) {
if (heroVid.paused) {
playHeroVid();
} else {
pauseHeroVid();
}
}
});

// Unregister media query listener on page unload to prevent memory leaks
window.addEventListener("beforeunload", () => {
motionQuery.removeEventListener("change", handleReduceMotionChanged);
});
}
}
export {videoHero}
14 changes: 5 additions & 9 deletions assets-src/styles/sass/00-settings/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $teal: #39cccc;
$aqua: #7fdbff;
$blue: #0073d8;
$navy: #001f3f;
$purple: #920ba6;
$purple: #75336c;
$fuchsia: #f012be;
$grey: #aaa;
$mercury-grey: #e5e5e5;
Expand All @@ -38,21 +38,17 @@ $red: #e93737;
$light-red: #ec7070;
$coral: #fc7750;
$light-coral: #fea78d;
$deep-yellow: #f9c818;
$yellow: #f9dc4a;
$deep-green: #0a4343;
$teal-green: #237978;
$aqua: #1bc0d7;
$light-blue: #cbe0fb;
$sky-blue: #6bc8fe;
$azure: #0075ff;
$w3c-blue: #005a9c;
$blue: #005797;
$deep-blue: #024488;
$deep-blue: #002a56;
$pink: #ddb0c8;
$light-pink: #eeccdc;
$storm-gray: #545454;
$twiki-gray: #bdbdbd;
$twiki-gray: #cac9c9;
$mist-gray: #f8f8fb;


Expand All @@ -63,12 +59,12 @@ $border-color: $twiki-gray;
$input-border-color: $storm-gray;
$focus-color: $yellow;

$link-color: $blue;
$link-color: $w3c-blue;
$link-color--visited: $purple;
$link-color--hover: $deep-blue;

$success-color: #046704;
$info-color: $w3c-blue;
$info-color: $deep-blue;
$warning-color: #c28605;
$error-color: #a82615;

Expand Down
2 changes: 1 addition & 1 deletion assets-src/styles/sass/50-core-components/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

&.talk {
border-color: $deep-yellow;
border-color: $deep-blue;
}

&.workshop {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

.component--evangelists__list {
background-color: $w3c-blue;
background-color: $deep-blue;
border-radius: rem(6);
color: $white;
overflow: hidden;
Expand Down
12 changes: 3 additions & 9 deletions assets-src/styles/sass/50-core-components/_logo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
\*------------------------------------*/

.logo {
display: block;
height: rem(44);
position: relative;
width: rem(66);

@include mq($bp-tab-large) {
height: rem(52);
width: rem(78);
}
display: block;
position: relative;
width: clamp(3.75rem, 2.51rem + 6.198vw, 7.5rem);
}

.logo--member {
Expand Down
18 changes: 5 additions & 13 deletions assets-src/styles/sass/50-core-components/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@
}

#global-nav {
border-bottom: solid 1px $border-color;
display: block;
padding-bottom: rem(18);
padding-top: rem(18);

@include mq($max-width) {
padding-bottom: 0;
padding-top: rem(20);
}
padding-bottom: em(26);
padding-top: em(26);
}

.global-nav__inner {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: em(48);

@include mq($max-width) {
align-items: flex-end;
flex-wrap: nowrap;
position: relative;
}
Expand Down Expand Up @@ -108,13 +102,11 @@ li.top-nav-item + li.top-nav-item {
}

@include mq($max-width) {
margin-inline-end: rem(25);
padding-bottom: rem(5);
position: relative;

&::before {
background-color: $w3c-blue;
bottom: 0;
bottom: rem(-3);
content:'';
display: none;
height: rem(3);
Expand Down
4 changes: 2 additions & 2 deletions assets-src/styles/sass/50-core-components/_quotes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

.component--quote {
@include txt-saturn;
color: $w3c-blue;
color: $purple;
font-weight: bold;
margin-inline-end: 0;
margin-inline-start: rem(10);
padding: rem(20);
position: relative;

&::before {
background-color: $w3c-blue;
background-color: $purple;
border-radius: rem(5);
left: rem(-10);
width: rem(10);
Expand Down
2 changes: 1 addition & 1 deletion assets-src/styles/sass/50-core-components/_slide.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

&::before {
background-color: $w3c-blue;
background-color: $purple;
border-radius: rem(5);
content: '';
height: 100%;
Expand Down
2 changes: 1 addition & 1 deletion assets-src/styles/sass/50-core-components/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// Only apply the border to the top level list
.toc > ul {
border-inline-start: solid 3px $deep-yellow;
border-inline-start: solid 3px $w3c-blue;
}

.toc ul {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
\*------------------------------------*/

.crosslinks {
background-color: $w3c-blue;
background-color: $deep-blue;
color: $white;
padding-bottom: rem(50);
padding-top: rem(50);
Expand Down
28 changes: 28 additions & 0 deletions assets-src/styles/sass/60-advanced-components/_hero.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,32 @@
h2 {
display: none;
}
}

.js .hero video {
display: block;
margin-left: auto;
margin-right: auto;
}

@media screen and (min-width: 48em) {
.js .hero video {
max-width: 31.25rem;
}
}

[data-video-control="hero"] > * {
pointer-events: none;
}

[data-video-control="hero"] .pause-icon {
display: none;
}

[data-video-control="hero"].js-play-video .pause-icon {
display: block;
}

[data-video-control="hero"].js-play-video .play-icon {
display: none;
}
2 changes: 1 addition & 1 deletion assets-src/styles/sass/80-templates/_event.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

&.talk::before {
background-color: $deep-yellow;
background-color: $deep-blue;
}

&.workshop::before {
Expand Down
Loading