Make the header a WebC component
This commit is contained in:
parent
6b3279642d
commit
1299104aa5
|
@ -37,14 +37,14 @@
|
|||
<link rel="manifest" href="/assets/favicon/site.webmanifest">
|
||||
|
||||
{# JavaScript #}
|
||||
<script src="/assets/js/navbar.js" defer></script>
|
||||
<script src="/assets/js/events.js" defer></script>
|
||||
{% if toc %} <script src="/assets/js/toc.js" defer></script> {% endif %}
|
||||
|
||||
<title>{{ title }} | Leilukin's Hub</title>
|
||||
</head>
|
||||
<body>
|
||||
{% include "main/header.njk" %}
|
||||
{% renderTemplate "webc" %}
|
||||
<header-main></header-main>
|
||||
{% endrenderTemplate %}
|
||||
{% renderTemplate "webc" %}
|
||||
<navbar></navbar>
|
||||
{% endrenderTemplate %}
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
<header class="main-header">
|
||||
<noscript>
|
||||
JavaScript is disabled in your browser. To get the best user experience on
|
||||
this website, it is recommended that you enable it.
|
||||
</noscript>
|
||||
<div class="main-header__top-bar"></div>
|
||||
<div class="main-header__img">
|
||||
<img src="/assets/leilukin/Leilukins-Hub-website-banner.png" alt="">
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style webc:keep webc:bucket="defer">
|
||||
header-main {
|
||||
width: 100%;
|
||||
background-color: var(--clr-main-header-bg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.main-header__top-bar {
|
||||
background-color: var(--clr-navbar-bg);
|
||||
width: 100%;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
|
||||
.main-header__img {
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
|
||||
.main-header img {
|
||||
object-fit: scale-down;
|
||||
overflow: hidden;
|
||||
filter: drop-shadow(0.1rem 0.1rem 0.2rem black);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script webc:keep webc:bucket="defer">
|
||||
const header = document.querySelector(".main-header");
|
||||
const todayEvent = getTodayEvent();
|
||||
const headerTopBarEl = document.querySelector(".main-header__top-bar");
|
||||
const headerImgEl = document.querySelector(".main-header__img");
|
||||
|
||||
if (todayEvent != "No event") {
|
||||
if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") {
|
||||
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
|
||||
} else {
|
||||
headerImgEl.classList.add(getBanner(todayEvent));
|
||||
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
|
||||
}
|
||||
} else {
|
||||
headerTopBarEl.textContent = "Welcome to Leilukin's Hub!";
|
||||
};
|
||||
|
||||
function getTodayEvent() {
|
||||
const date = new Date();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
|
||||
if (month == 3 && day == 1)
|
||||
return "Zero Discrimination Day";
|
||||
else if (month == 3 && day == 31)
|
||||
return "Trans Day of Visibility";
|
||||
else if (month == 4 && day == 6)
|
||||
return "International Asexuality Day";
|
||||
else if (month == 4 && day == 26)
|
||||
return "Lesbian Visibility Day";
|
||||
else if (month == 5 && day == 17)
|
||||
return "IDAHOBIT";
|
||||
else if (month == 5 && day == 19)
|
||||
return "Agender Pride Day";
|
||||
else if (month == 5 && day == 25)
|
||||
return "Pansexual and Panromantic Awareness & Visibility Day";
|
||||
else if (month == 6)
|
||||
return "Pride Month";
|
||||
else if (month == 7 && day == 14)
|
||||
return "Non-Binary People's Day";
|
||||
else if (month == 7 && day == 28)
|
||||
return "Leilukin's Birthday";
|
||||
else if (month == 9 && day == 11)
|
||||
return "Leilukin's Hub Anniversary";
|
||||
else if (month == 9 && day == 23)
|
||||
return "Bi Visibility Day";
|
||||
else if (month == 10 && day == 8)
|
||||
return "International Lesbian Day";
|
||||
else if (month == 10 && day == 11)
|
||||
return "National Coming Out Day";
|
||||
else if (month == 10 && day == 26)
|
||||
return "Intersex Awareness Day";
|
||||
else
|
||||
return "No event";
|
||||
}
|
||||
|
||||
function getBanner(day) {
|
||||
switch (day) {
|
||||
case "Zero Discrimination Day":
|
||||
return "flag-progress-intersex";
|
||||
break;
|
||||
case "Trans Day of Visibility":
|
||||
return "flag-trans";
|
||||
break;
|
||||
case "International Asexuality Day":
|
||||
return "flag-ace";
|
||||
break;
|
||||
case "Lesbian Visibility Day":
|
||||
return "flag-lesbian";
|
||||
break;
|
||||
case "IDAHOBIT":
|
||||
return "flag-progress";
|
||||
break;
|
||||
case "Agender Pride Day":
|
||||
return "flag-agender";
|
||||
break;
|
||||
case "Pansexual and Panromantic Awareness & Visibility Day":
|
||||
return "flag-pan";
|
||||
break;
|
||||
case "Pride Month":
|
||||
return "flag-progress-intersex";
|
||||
break;
|
||||
case "Non-Binary People's Day":
|
||||
return "flag-non-binary";
|
||||
break;
|
||||
case "Bi Visibility Day":
|
||||
return "flag-bi";
|
||||
break;
|
||||
case "International Lesbian Day":
|
||||
return "flag-lesbian";
|
||||
break;
|
||||
case "National Coming Out Day":
|
||||
return "flag-rainbow";
|
||||
break;
|
||||
case "Intersex Awareness Day":
|
||||
return "flag-intersex";
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function getBlurbHtml(day) {
|
||||
switch (day) {
|
||||
case "Zero Discrimination Day":
|
||||
return `
|
||||
Today is <a href="https://www.unaids.org/en/zero-discrimination-day" target="_blank">Zero Discrimination Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Trans Day of Visibility":
|
||||
return `
|
||||
Today is <a href="https://www.manygendersonevoice.org/tdov.html" target="_blank">Trans Day of Visibility</a>
|
||||
`;
|
||||
break;
|
||||
case "International Asexuality Day":
|
||||
return `
|
||||
Today is <a href="https://internationalasexualityday.org/en" target="_blank">International Asexuality Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Lesbian Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://www.lesbianvisibilityweek.com" target="_blank">Lesbian Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "IDAHOBIT":
|
||||
return `
|
||||
Today is <a href="https://may17.org" target="_blank">International Day Against Homophobia, Biphobia and Transphobia</a></span>
|
||||
`;
|
||||
break;
|
||||
case "Agender Pride Day":
|
||||
return `
|
||||
Today is <a href="https://www.believeoutloud.com/voices/article/agender-pride-day/" target="_blank">Agender Pride Day</a></span>
|
||||
`;
|
||||
break;
|
||||
case "Pansexual and Panromantic Awareness & Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://genderedintelligence.co.uk/panvisibilityday" target="_blank">Pansexual and Panromantic Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Pride Month":
|
||||
return `
|
||||
Happy <a href="https://www.loc.gov/lgbt-pride-month/about/" target="_blank">Pride Month</a>!
|
||||
`;
|
||||
break;
|
||||
case "Non-Binary People's Day":
|
||||
return `
|
||||
Today is <a href="https://www.manygendersonevoice.org/non-binary-peoples-day.html" target="_blank">Non-Binary People's Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Leilukin's Birthday":
|
||||
return `
|
||||
Today is Leilukin's birthday
|
||||
`;
|
||||
break;
|
||||
case "Leilukin's Hub Anniversary":
|
||||
return `
|
||||
Today is the anniversary of the launch of Leilukin's Hub
|
||||
`;
|
||||
break;
|
||||
case "Bi Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://bivisibilityday.com/about" target="_blank">Bi Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "International Lesbian Day":
|
||||
return `
|
||||
Today is <a href="https://www.lgbtiqhealth.org.au/international_lesbian_day2" target="_blank">International Lesbian Day</a>
|
||||
`;
|
||||
break;
|
||||
case "National Coming Out Day":
|
||||
return `
|
||||
Today is <a href="https://www.hrc.org/resources/national-coming-out-day" target="_blank">National Coming Out Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Intersex Awareness Day":
|
||||
return `
|
||||
Today is <a href="https://interactadvocates.org/intersex-awareness-day" target="_blank">Intersex Awareness Day</a>
|
||||
`;
|
||||
break;
|
||||
default:
|
||||
return ``;
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,10 +0,0 @@
|
|||
<header class="main-header">
|
||||
<noscript>
|
||||
JavaScript is disabled in your browser. To get the best user experience on
|
||||
this website, it is recommended that you enable it.
|
||||
</noscript>
|
||||
<div class="main-header__top-bar"></div>
|
||||
<div class="main-header__img">
|
||||
<img src="/assets/leilukin/Leilukins-Hub-website-banner.png" alt="">
|
||||
</div>
|
||||
</header>
|
|
@ -229,33 +229,6 @@ dd {
|
|||
grid-column-start: 2;
|
||||
}
|
||||
|
||||
/* HEADER COMPONENT */
|
||||
.main-header {
|
||||
width: 100%;
|
||||
background-color: var(--clr-main-header-bg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.main-header__top-bar {
|
||||
background-color: var(--clr-navbar-bg);
|
||||
width: 100%;
|
||||
padding: 0.5em 0;
|
||||
}
|
||||
|
||||
.main-header__img {
|
||||
display: grid;
|
||||
place-content: center;
|
||||
}
|
||||
|
||||
.main-header img {
|
||||
object-fit: scale-down;
|
||||
overflow: hidden;
|
||||
filter: drop-shadow(0.1rem 0.1rem 0.2rem black);
|
||||
}
|
||||
|
||||
/* MAIN CONTENT */
|
||||
main,
|
||||
.content-container,
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
// const header = document.querySelector(".main-header");
|
||||
|
||||
const todayEvent = getTodayEvent();
|
||||
const headerTopBarEl = document.querySelector(".main-header__top-bar");
|
||||
const headerImgEl = document.querySelector(".main-header__img");
|
||||
|
||||
if (todayEvent != "No event") {
|
||||
if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") {
|
||||
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
|
||||
} else {
|
||||
headerImgEl.classList.add(getBanner(todayEvent));
|
||||
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
|
||||
}
|
||||
} else {
|
||||
headerTopBarEl.textContent = "Welcome to Leilukin's Hub!"
|
||||
};
|
||||
|
||||
function getTodayEvent() {
|
||||
const date = new Date();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
|
||||
if (month == 3 && day == 1)
|
||||
return "Zero Discrimination Day";
|
||||
else if (month == 3 && day == 31)
|
||||
return "Trans Day of Visibility";
|
||||
else if (month == 4 && day == 6)
|
||||
return "International Asexuality Day";
|
||||
else if (month == 4 && day == 26)
|
||||
return "Lesbian Visibility Day";
|
||||
else if (month == 5 && day == 17)
|
||||
return "IDAHOBIT";
|
||||
else if (month == 5 && day == 19)
|
||||
return "Agender Pride Day";
|
||||
else if (month == 5 && day == 25)
|
||||
return "Pansexual and Panromantic Awareness & Visibility Day";
|
||||
else if (month == 6)
|
||||
return "Pride Month";
|
||||
else if (month == 7 && day == 14)
|
||||
return "Non-Binary People's Day";
|
||||
else if (month == 7 && day == 28)
|
||||
return "Leilukin's Birthday";
|
||||
else if (month == 9 && day == 11)
|
||||
return "Leilukin's Hub Anniversary";
|
||||
else if (month == 9 && day == 23)
|
||||
return "Bi Visibility Day";
|
||||
else if (month == 10 && day == 8)
|
||||
return "International Lesbian Day";
|
||||
else if (month == 10 && day == 11)
|
||||
return "National Coming Out Day";
|
||||
else if (month == 10 && day == 26)
|
||||
return "Intersex Awareness Day";
|
||||
else
|
||||
return "No event";
|
||||
}
|
||||
|
||||
function getBanner(day) {
|
||||
switch (day) {
|
||||
case "Zero Discrimination Day":
|
||||
return "flag-progress-intersex";
|
||||
break;
|
||||
case "Trans Day of Visibility":
|
||||
return "flag-trans";
|
||||
break;
|
||||
case "International Asexuality Day":
|
||||
return "flag-ace";
|
||||
break;
|
||||
case "Lesbian Visibility Day":
|
||||
return "flag-lesbian";
|
||||
break;
|
||||
case "IDAHOBIT":
|
||||
return "flag-progress";
|
||||
break;
|
||||
case "Agender Pride Day":
|
||||
return "flag-agender";
|
||||
break;
|
||||
case "Pansexual and Panromantic Awareness & Visibility Day":
|
||||
return "flag-pan";
|
||||
break;
|
||||
case "Pride Month":
|
||||
return "flag-progress-intersex";
|
||||
break;
|
||||
case "Non-Binary People's Day":
|
||||
return "flag-non-binary";
|
||||
break;
|
||||
case "Bi Visibility Day":
|
||||
return "flag-bi";
|
||||
break;
|
||||
case "International Lesbian Day":
|
||||
return "flag-lesbian";
|
||||
break;
|
||||
case "National Coming Out Day":
|
||||
return "flag-rainbow";
|
||||
break;
|
||||
case "Intersex Awareness Day":
|
||||
return "flag-intersex";
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function getBlurbHtml(day) {
|
||||
switch (day) {
|
||||
case "Zero Discrimination Day":
|
||||
return `
|
||||
Today is <a href="https://www.unaids.org/en/zero-discrimination-day" target="_blank">Zero Discrimination Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Trans Day of Visibility":
|
||||
return `
|
||||
Today is <a href="https://www.manygendersonevoice.org/tdov.html" target="_blank">Trans Day of Visibility</a>
|
||||
`;
|
||||
break;
|
||||
case "International Asexuality Day":
|
||||
return `
|
||||
Today is <a href="https://internationalasexualityday.org/en" target="_blank">International Asexuality Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Lesbian Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://www.lesbianvisibilityweek.com" target="_blank">Lesbian Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "IDAHOBIT":
|
||||
return `
|
||||
Today is <a href="https://may17.org" target="_blank">International Day Against Homophobia, Biphobia and Transphobia</a></span>
|
||||
`;
|
||||
break;
|
||||
case "Agender Pride Day":
|
||||
return `
|
||||
Today is <a href="https://www.believeoutloud.com/voices/article/agender-pride-day/" target="_blank">Agender Pride Day</a></span>
|
||||
`;
|
||||
break;
|
||||
case "Pansexual and Panromantic Awareness & Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://genderedintelligence.co.uk/panvisibilityday" target="_blank">Pansexual and Panromantic Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Pride Month":
|
||||
return `
|
||||
Happy <a href="https://www.loc.gov/lgbt-pride-month/about/" target="_blank">Pride Month</a>!
|
||||
`;
|
||||
break;
|
||||
case "Non-Binary People's Day":
|
||||
return `
|
||||
Today is <a href="https://www.manygendersonevoice.org/non-binary-peoples-day.html" target="_blank">Non-Binary People's Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Leilukin's Birthday":
|
||||
return `
|
||||
Today is Leilukin's birthday
|
||||
`;
|
||||
break;
|
||||
case "Leilukin's Hub Anniversary":
|
||||
return `
|
||||
Today is the anniversary of the launch of Leilukin's Hub
|
||||
`;
|
||||
break;
|
||||
case "Bi Visibility Day":
|
||||
return `
|
||||
Today is <a href="https://bivisibilityday.com/about" target="_blank">Bi Visibility Day</a>
|
||||
`;
|
||||
break;
|
||||
case "International Lesbian Day":
|
||||
return `
|
||||
Today is <a href="https://www.lgbtiqhealth.org.au/international_lesbian_day2" target="_blank">International Lesbian Day</a>
|
||||
`;
|
||||
break;
|
||||
case "National Coming Out Day":
|
||||
return `
|
||||
Today is <a href="https://www.hrc.org/resources/national-coming-out-day" target="_blank">National Coming Out Day</a>
|
||||
`;
|
||||
break;
|
||||
case "Intersex Awareness Day":
|
||||
return `
|
||||
Today is <a href="https://interactadvocates.org/intersex-awareness-day" target="_blank">Intersex Awareness Day</a>
|
||||
`;
|
||||
break;
|
||||
default:
|
||||
return ``;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue