In my React app, I am receiving a variable number of square images from an API to display. These images come in dimensions of 200px, 512px, or 600px squares and have corresponding jackpot denominations and amounts underneath them with a title above. The display can show anywhere from 1 to 5 denominations and amounts, all of which must be the same size without resizing.
The app will be shown on a 1920H x 1080W screen in a business setting where scrolling and screen resizing are not possible, ruling out the use of media queries.
The image display will rotate every ten seconds to show new sets of images. A CodeSandbox link - https://codesandbox.io/s/jackpot-ufs5t - provides a basic replica of the app (without rotation or API calls) using simulated data in the imageList.js file acting as a fake API.
I want these images to fit within a container near the top of the screen below the title and above the jackpot denominations/amounts. If there are less than six images, they should be a specific height and width like 303px square. If there are more than 6 images, their height and width need to decrease proportionally while fitting within the container between the title and jackpot amounts.
While everything looks good with fewer images and denominations, having 14 images and 5 jackpot amounts is problematic.
Despite attempts with Flexbox and CSS-Grid, I still struggle with auto-fitting the images and preventing overlapping when there are many images present in the container.
In the provided CodeSandbox example, commenting/uncommenting data in the imageList file can change the number of images and jackpot amounts displayed.
To address this issue, I have been conditionally assigning different classes to the images and container based on various combinations of the image array length and jackpot array amount. Is there a better way using only Flexbox or CSS-Grid to automatically adjust the size of square images based on quantity?
Currently, my concern lies with the vertical display rather than horizontal orientation.
For reference, here is the CodeSandbox link again: https://codesandbox.io/s/jackpot-ufs5t