Not Found
Not Found
Not Found
Request path contains unescaped characters
Request path contains unescaped characters
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

FrontEnd Mentor Accordion Project

papa 340

@PapsPython

Desktop design screenshot for the FAQ accordion card coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I fell victim to image and background size manipulation. Still need to iterate a lot more around around image and background manipulation.

The JS was fun, a great reminder of classList.toggle and a welcome introduction to classList.contains. Also tried experimenting with a database and data attributes, still working through that solution.

Community feedback

P
visualdennis 8,375

@visualdenniss

Posted

Congrats on completing the challenge! It looks good overall.

However few issues to be noted, as u also pointed out some of them. This image belong to the FAQ Card and not the body or the page as a whole, so it is better to group things together that belong to each other, meaning ideally image should be inside the main tag or the container of the card and it must be positioned to absolute relative to that container (although it does not need to be absolutely positioned too, there are other alternatives).

Also somehow i cannot open the answers nomatter where i click, it does not seem to work for me.

0

papa 340

@PapsPython

Posted

@visualdenniss thanks for the feedback Dennis. I made the click specific to the arrow. Please click on the "how do i reset password" arrow. My attempt at using data-attributes introduced complications.

Kindly let me know if that worked.

0
P
visualdennis 8,375

@visualdenniss

Posted

@PapsPython Yep clicking on that arrow opens. You can also check my solution if you want to see a possible way to do it. Even tho the source code is in React, that part of the logic is vanilla JS, where on Click on the button i call handleToggle function:

const handleToggle = (e) => {
    
    const question = e.target 
    const answer = e.target.nextSibling 

    if(question.classList.contains('faq-accordion-question-button-active')) {
        question.classList.remove('faq-accordion-question-button-active')
        answer.classList.remove('faq-accordion-answer-active')
    } else {
        // // reset 
        const openQuestions = document.querySelectorAll('.faq-accordion-answer-active')
        const openBtn = document.querySelectorAll('.faq-accordion-question-button-active')
        openQuestions?.forEach(item => item.classList.remove('faq-accordion-answer-active'))      
        openBtn?.forEach(btn => btn.classList.remove('faq-accordion-question-button-active'))

        question.classList.add('faq-accordion-question-button-active')           
        answer.classList.toggle('faq-accordion-answer-active')
    }
}

Hope this was helpful!

0

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