Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Testimonials slider (Mobile first workflow|Tailwind-CSS|Vanilla JS)

jwalczak94 810

@jwalczak94

Desktop design screenshot for the Coding bootcamp testimonials slider coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi Frontend Mentor community!

This is my solution for the Coding bootcamp testimonials slider challenge.

I really struggled with the control icons as they should be positioned relative to the img but I ended up putting them on top of the testimonial slider. If there is a way to position them as they should be, please let me know. 😊

Any feedback is greatly appreciated! Thanks!🎉

Community feedback

SrHatcher 710

@SrHatcher

Posted

Hello!

I wanted to say that your fading animation is very cool! I wanted to do that for mine but I didn't know how to do it until I saw your code.

Talking about your control buttons, I would recommend you to take a look at my code to understand much better how I did it, but in short: I used a div container for the person img and my buttons container, so that I can use it to control the img size and use position: relative to positionate my buttons container with position: absolute. I'm using two buttons for each testimonial and using my JS to make them work together and not break the display.

nice solution! :)

0

jwalczak94 810

@jwalczak94

Posted

@SrHatcher Hi, I'm glad my code helped you 😊.

I also thought about the solution you write about, but I preferred to avoid two identical elements on the page. I thought there might be a better solution, but nothing comes to mind. 🤔

1
SrHatcher 710

@SrHatcher

Posted

@jwalczak94 In that case you can use just one container and change the image and information with javascript. You can create an object in your JS file with the information of each person. When the user clicks on any button you change the information depending of the current index. something like this:

let index = 0
leftButton.addEventListener('click', ()=>{
    if(index > 0){
        index--

        //this display none is to use the fade animation later
        testimonial.style.display = 'none'

        imageTag.src=`${people[index].img}`
        textTag.innerText = people[index].testimonial
        nameTag.innerText = people[index].name
        degreeTag.innerText = people[index].degree

        //this setTimeOut is to make the fade animation visible
        setTimeout(() => {
            testimonial.style.display = 'flex'
        }, 10);
    }
})

rightButton.addEventListener('click', ()=>{
    if(index + 1 < people.length){
        index++

        testimonial.style.display = 'none'

        imageTag.src=`${people[index].img}`
        textTag.innerText = people[index].testimonial
        nameTag.innerText = people[index].name
        degreeTag.innerText = people[index].degree

        setTimeout(() => {
            testimonial.style.display = 'flex'
        }, 10);
    }
})

With that solution you make the testimonial component dynamical and we don't have to duplicate any element!

I tried to do it that way and it works, you can take a look at my code if you like! here's the live version and here's the repository

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord