grid-template-areas solution with Next.js, TailwindCSS, CSS module

Solution retrospective
I made various efforts to enhance the reusability of components,
like:
- storing the card's content information (title, logo, description) as an array of data, allowing it to be flexibly passed as arguments to the card component.
- using grid-template-area to handle changes in screen width only with the parent element of the card.
- using round and overflow-hidden class to make cards round.
I needed to change the card layout between the mobile and desktop versions, but achieving this with "flex" was challenging, so I decided to use "grid". While it’s possible to achieve the desired layout with grid-row and grid-column, it would require writing different conditional logic for each card, which would reduce the reusability of the component and make it difficult to process the array data using the map function. I wanted the parent element of the cards to have full control over the layout without adding layout-specific classes to each card. Therefore, I used grid-template-areas to allow the parent element to handle the layout adjustments based on screen size. Since grid-template-areas isn't available as a utility in TailwindCSS, I resolved this by using CSS modules.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Ryo Nakai'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