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

Results Component using Next13

@FLuffy-teddy

Desktop design screenshot for the Results summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I created a component to display each of the summaries (reaction, memory, verbal, visual) but I had to then use four components each with different props to achieve the desired look. Is there a better way of structuring the component to display the necessary information without duplicating four components each with slightly different props?

Community feedback

P
markus 2,060

@markuslewin

Posted

Instead of filtering the data array inside <Summary>, you could iterate over the array in <Home>, like this:

<h3 className="text-lg text-black pb-4">Summary</h3>;
{
data.scores.map((score) => {
return <Summary key={score.category} {...score} />;
});
}

The colors could be stored in an object with the category as a key:

const colorsByCategory = {
Reaction: {
bgColor: "bg-red-100",
textColor: "text-red-600",
},
/* ... */
};

Or, you could style the items using data modifiers:

<div
className="data-[category=Reaction]:bg-red-100 data-[category=Reaction]:text-red-600 ..."
data-category={category}
>

Marked as helpful

1

@FLuffy-teddy

Posted

@markuslewin

Thanks for the response, actually very useful for this next project I am tackling.

1
_nehal💎 6,710

@NehalSahu8055

Posted

Hello Coder 👋.

Congratulations on successfully completing the challenge! 🎉

Few suggestions regarding design.

➨ Replace height:100vh with min-height:100vh in container.

.h-screen {
min-height: 100vh;
}

➨ Give your container some width or more specific max-width as it become very large on larger screens.

➨ You can use accessibility features like aria, sr-only, and title which are accessible to screen readers.

I hope you find this helpful.

Happy coding😄

Marked as helpful

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