Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 3 months ago

Ecommerce Product Page using dialogs

pure-css
P
Josh Kahlbaugh•540
@Joshk7
A solution to the E-commerce product page challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I liked the use of dialog elements in html.

What challenges did you encounter, and how did you overcome them?

I major issue that I encountered was centering the checkout dialog relative to the shopping cart button that I used as a trigger to open a dialog.

const handleCartButton = (e) => {
    if (large.matches) {
        const rect = cartButton.getBoundingClientRect();
        checkoutDialog.style.position = "absolute";
        checkoutDialog.style.top = `${rect.bottom + window.scrollY}px`;
        checkoutDialog.style.left = `${
            rect.left + rect.width / 2 + window.scrollX
        }px`;
        checkoutDialog.style.transform = "translateX(-50%)";
    }

    if (checkoutDialog.open) {
        checkoutDialog.close();
    } else {
        checkoutDialog.show();
    }
};

I used javascript to adjust the position of the dialog accordingly, however, there might be better ways to achieve this.

What specific areas of your project would you like help with?

Specifically, I'd like any suggestions or help on how to make that checkout dialog better. Generally, any tips on how to create modals would be helpful as well.

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Josh Kahlbaugh's solution.

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License