I have an image gallery with various image sizes (that are constantly being changed). I want to be able to move image cards up to sit right below the above image card.
However, it's very important that the images remain in date order. The solutions I've tried all shift the order around. They mostly involve using flex to order by column, which produces the following result:
1 4 7
2 5
3 6
I still want:
1 2 3 4
5 6 7
Is there a way to do this, preferably in CSS Grid but I can use flexbox if necessary and it doesn't mess with ordering.
My current styling is very simplistic:
.cards-container-not-home {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
}
Ordering is determined by date desc. Images are stored with a timestamp on upload. Then I call firebase and get them back in date order and push them into an array:
let picturesData = [];
let snapshot = await db
.collection(collection)
.orderBy("timestamp", "desc")
.get();
snapshot.forEach((doc) => {
let appData = doc.data();
appData.id = doc.id;
picturesData.push(appData);
});
return picturesData;
I iterate over the array, then do a v-for
loop to print the image cards tot he page in that desc date order.
Here's the template:
<template>
<div v-bind:class="{ 'cards-container-not-home': notHome }">
<div v-for="data in imageData" :key="data.id">
<div class="card">
<img :src="data.source" :alt="data.caption" class="card-img" />
<div class="text-box">
<p>{{ moment(data.timestamp.toDate()).format("MMM Do YYYY") }}</p>
<p>{{ data.caption }}</p>
<Geolocation v-bind:address="data.location" />
</div>
</div>
</div>
</div>
</template>