Bento Grid with Tailwind

Solution retrospective
This was my second project using Tailwind. I gained experience using more of its utility classes, especially those for grid layouts.
If I were to attempt this project again, I would separate the cards into components. Here I decided not to because I saw no way to extract a generalised card component, as none of them share the same structure/styling or state. With this considered, I think it might still be a good idea to separate them in order to make the code more readable.
What challenges did you encounter, and how did you overcome them?I was trying to set an image larger than its container in order to produce the clipped effect where only a portion of the image is visible. It would not work and I could not figure out why. It turned out to be due to Tailwind's default styling - the 'preflight' which added a max width of 100% to images, thus not letting it exceed the width of its parent.
What specific areas of your project would you like help with?Tailwind and dynamic data
Using Vite, I imported an image from my src/assets folder with 'import imgSrc from ".."'. My understanding is then that imgSrc becomes the resolved path to the image after the build step. Does this just exist as a variable in the scope of the module which imported it then?
The reason I ask this question is that I tried to use a custom Tailwind class of the form bg-[url(imgSrc)]. Tailwind did not produce a class for it during build. As such, I assume it is because the imports act as I have described above?
My prior thought process was that a static resource import was evaluated during the build step and substituted where it was referenced.
Many thanks to anyone who has read this far - this was essentially me thinking aloud and more for documentation of my learning than anything. If anyone has any insight I'd very grateful.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Andrew'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