-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add logos and display in carousel #452
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,32 @@ <h2 class="font-bold text-2xl sm:text-4xl text-center mb-10"> | |
</span> | ||
</h2> | ||
{{ end }} | ||
<ul class="flex flex-col md:flex-row md:flex-wrap items-center lg:justify-between gap-12 md:gap-8"> | ||
{{ range .clients_item}} | ||
{{ if .show }} | ||
<li> | ||
<img loading="lazy" class="max-w-[180px]" src="{{ .image | absURL }}" alt="{{ .name }}"> | ||
</li> | ||
{{ end }} | ||
{{ end }} | ||
</ul> | ||
<div class="embla overflow-hidden" data-loop="true" data-scroll="1"> | ||
<div class="embla__viewport overflow-hidden"> | ||
<ul class="embla__container flex items-center touch-pinch-zoom"> | ||
{{ range .clients_item}} | ||
{{ if .show }} | ||
{{"<!-- Set flex basis to determine the number of slides/logos that will appear. -->" | safeHTML}} | ||
<li class="embla__slide flex-[0_0_50%] md:flex-[0_0_33%] lg:flex-[0_0_20%]"> | ||
<figure class="flex justify-center items-center grayscale hover:grayscale-0"> | ||
<img class="w-28 h-auto max-h-14 object-contain" loading="lazy" src="{{ .image | absURL }}" alt="{{ .name }}" title="{{ .name }}"> | ||
</figure> | ||
</li> | ||
{{ end }} | ||
{{ end }} | ||
</ul> | ||
</div> | ||
<div class="flex justify-between lg:justify-center gap-x-8 items-center mt-4 p-2 sm:p-6"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Displaying on the side of the logos, instead of below them, led to issues where the styles were blocked. I couldn't figure out how to prevent that, so they will appear below the logos for now. |
||
<button type="button" class="embla__prev h-9 w-9 rounded-full bg-[#2F4858] hover:bg-[#2F4858]/80"> | ||
<span class="sr-only">Previous</span> | ||
<i class="fa-solid fa-chevron-left mt-1.5 text-white" title="Previous"></i> | ||
</button> | ||
<button type="button" class="embla__next h-9 w-9 rounded-full bg-[#2F4858] hover:bg-[#2F4858]/80"> | ||
<span class="sr-only">Next</span> | ||
<i class="fa-solid fa-chevron-right mt-1.5 text-white" title="Next"></i> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
{{ end }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
// Initialize Embla carousel | ||
const emblaRoot = document.querySelector('.embla'); | ||
const emblaViewport = emblaRoot?.querySelector('.embla__viewport'); | ||
const prevBtn = emblaRoot?.querySelector('.embla__prev'); | ||
const nextBtn = emblaRoot?.querySelector('.embla__next'); | ||
const options = { loop: true }; | ||
// Initialize Embla carousel. | ||
const emblaRoot = document.querySelectorAll('.embla'); | ||
|
||
if (emblaRoot) { | ||
const carousel = EmblaCarousel(emblaViewport, options); | ||
prevBtn.addEventListener('click', carousel.scrollPrev, false); | ||
nextBtn.addEventListener('click', carousel.scrollNext, false); | ||
} | ||
emblaRoot?.forEach((root) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that there are 2 carousels on the same, page, the JavaScript has been updated so that separate options may be set for each one. Although the |
||
// Set carousel options from the data attributes. | ||
const options = { loop: Boolean(root?.dataset?.loop), slidesToScroll: Number(root?.dataset?.scroll), align: "start" }; | ||
const carousel = EmblaCarousel(root?.querySelector('.embla__viewport'), options); | ||
|
||
const prevBtn = root?.querySelector('.embla__prev'); | ||
const nextBtn = root?.querySelector('.embla__next'); | ||
|
||
prevBtn?.addEventListener('click', carousel?.scrollPrev, false); | ||
nextBtn?.addEventListener('click', carousel?.scrollNext, false); | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user scrolls through the logos, only 1 moves at a time. We can change this to another number. Also, the user will be able to loop through all of the logos. This means that when the user gets to the last logo they will see the first one. This matches how we handle the testimonials.