Add special day elements to KotOR shrine

This commit is contained in:
Helen Chong 2023-11-09 20:03:36 +08:00
parent f728adc4bc
commit a2a4da004f
2 changed files with 54 additions and 8 deletions

View File

@ -30,13 +30,10 @@
--clr-main-footer-bg: #171717; --clr-main-footer-bg: #171717;
} }
.main-header {
max-height: 20rem;
}
.main-header img { .main-header img {
object-fit: cover; object-fit: cover;
object-position: center; object-position: center;
max-height: 20rem;
} }
.juhani-history { .juhani-history {

View File

@ -1,7 +1,57 @@
/* ------ STAR WARS KOTOR SHRINE HEADER COMPONENT ------ */ /* ------ STAR WARS KOTOR SHRINE HEADER COMPONENT ------ */
document.querySelector(".main-header").innerHTML = ` const header = document.querySelector(".main-header");
<img src="/shrines/starwarskotor/img/swkotor-header.jpg" alt="">
`; header.innerHTML = loadHeader();
function loadHeader() {
const headerTopBar = `<div class="main-header__top-bar"></div>`;
const headerImg = `<img src="/shrines/starwarskotor/img/swkotor-header.jpg
" alt="">`;
const todayEvent = getTodayEvent();
if (todayEvent == "No event") {
return headerImg;
} else {
return headerTopBar + headerImg;
};
}
const todayEvent = getTodayEvent();
const headerTopBarEl = document.querySelector(".main-header__top-bar");
if (todayEvent != "No event") {
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
};
function getTodayEvent() {
const date = new Date();
const month = date.getMonth() + 1;
const day = date.getDate();
if (month == 7 && day == 16)
return "KotOR 1 Anniversary";
else if (month == 12 && day == 6)
return "KotOR 2 Anniversary";
else
return "No event";
}
function getBlurbHtml(day) {
switch (day) {
case "KotOR 1 Anniversary":
return `
Today is the anniversary of the release of <cite>Star Wars: Knihgts of the Old Republic</cite>
`;
break;
case "KotOR 2 Anniversary":
return `
Today is the anniversary of the release of <cite>Star Wars: Knights of the Old Republic II The Sith Lords</cite>
`;
break;
default:
return ``;
}
}
/* Navigation component content */ /* Navigation component content */
document.querySelector(".navbar").innerHTML = ` document.querySelector(".navbar").innerHTML = `
@ -16,7 +66,6 @@ document.querySelector(".navbar").innerHTML = `
`; `;
// Make the navigation bar sticky // Make the navigation bar sticky
const header = document.querySelector(".main-header");
const navbar = document.querySelector(".navbar"); const navbar = document.querySelector(".navbar");
window.addEventListener("scroll", e => { window.addEventListener("scroll", e => {