-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2061 from FlowFuse/1968-rotating-event-banner
Rotating event banner
- Loading branch information
Showing
9 changed files
with
175 additions
and
56 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
- type: "Webinar" | ||
title: "Deploy FlowFuse on Industrial IoT with NCD.io" | ||
buttonText: "Learn more" | ||
link: "/webinars/2024/deploy-flowfuse-on-industrial-iot-with-ncd-io/" | ||
expire: "2024-05-29T16:00:00Z" |
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 |
---|---|---|
@@ -1,15 +1,76 @@ | ||
{% set colors = ["bg-indigo-700 hover:bg-indigo-600", "bg-indigo-800 hover:bg-indigo-700", "bg-indigo-900 hover:bg-indigo-800"] %} | ||
{% set hasFutureEvents = false %} | ||
|
||
{% for event in events %} | ||
{% if event.expire | isFutureDate %} | ||
{% set hasFutureEvents = true %} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if hasFutureEvents %} | ||
<div class="event-banner-container bg-indigo-700 hidden sm:block"> | ||
{% for event in events %} | ||
{% if event.expire | isFutureDate %} | ||
{% set color = colors[loop.index0 % colors.length] %} | ||
<a href="{{ event.link }}" class="event-banner hidden sm:flex text-center w-full py-1 pb-3 sm:py-3 {{ color }} text-indigo-100 text-sm px-2 gap-1 sm:gap-2 flex-col sm:flex-row items-center justify-center"> | ||
<span class="hidden sm:block font-semibold">{{ event.type }}</span> | ||
<span class="hidden sm:block">-</span> | ||
<span class="">{{ event.title }}</span> | ||
<span class="hidden sm:block">-</span> | ||
<span class="flex items-center gap-1 font-medium underline" > | ||
{{ event.buttonText }} {% include "components/icons/chevron-right-sm.svg" %} | ||
</span> | ||
</a> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
|
||
<script> | ||
</script> | ||
window.onload = function() { | ||
const banners = document.querySelectorAll('.event-banner'); | ||
const container = document.querySelector('.event-banner-container'); | ||
// If there are no banners, exit the function | ||
if (banners.length === 0) return; | ||
let currentBanner = 0; | ||
// Change the container color to match the current banner | ||
function changeContainerColor(banner) { | ||
const colorClass = banner.className.match(/bg-\w+-\d+/)[0]; | ||
const hoverColorClass = banner.className.match(/hover:bg-\w+-\d+/)[0]; | ||
container.className = 'event-banner-container ' + colorClass + ' ' + hoverColorClass + ' hidden sm:block'; | ||
} | ||
// All banners are hidden by default | ||
banners.forEach(banner => banner.style.visibility = 'hidden'); | ||
<a data-action="event-banner" href="/webinars/2024/deploy-flowfuse-on-industrial-iot-with-ncd-io/" | ||
class="hidden md:flex text-center w-full py-1 pb-3 sm:py-3 bg-indigo-700 text-indigo-100 text-sm px-2 gap-1 sm:gap-2 flex-col sm:flex-row items-center justify-center hover:bg-indigo-600"> | ||
<span class="hidden sm:block font-semibold">Webinar</span> | ||
<span class="hidden sm:block">-</span> | ||
<span class=""> | ||
Deploy FlowFuse on Industrial IoT with NCD.io | ||
</span> | ||
<span class="hidden sm:block">-</span> | ||
<span class="flex items-center gap-1 font-medium underline" > | ||
Learn more {% include "components/icons/chevron-right-sm.svg" %} | ||
</span> | ||
</a> | ||
// Show the first banner | ||
banners[0].style.visibility = 'visible'; | ||
changeContainerColor(banners[0]); | ||
// If there is more than one banner, change the visible banner every 10 seconds | ||
if (banners.length > 1) { | ||
setInterval(function() { | ||
// Hide the current banner | ||
banners[currentBanner].style.visibility = 'hidden'; | ||
// Increment the current banner index | ||
currentBanner = (currentBanner + 1) % banners.length; | ||
// Show the new banner | ||
banners[currentBanner].style.visibility = 'visible'; | ||
banners[currentBanner].style.animation = 'none'; // reset animation | ||
// force reflow, triggering a new animation | ||
void banners[currentBanner].offsetWidth; | ||
banners[currentBanner].style.animation = 'slideDown 0.5s ease'; | ||
// Change the container color to match the new banner | ||
setTimeout(function() { | ||
changeContainerColor(banners[currentBanner]); | ||
}, 500); // wait for the slideDown animation to finish | ||
}, 10000); | ||
} | ||
}; | ||
</script> |
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