From 141abc130eb5088297379ff9c7ed524aa1d70ccf Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Sun, 28 Apr 2024 10:25:09 +0700 Subject: [PATCH] home: update recently added cards to be horizontally placed --- views/homeview/homeview.templ | 6 +--- ..._card.templ => recently_added_image.templ} | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) rename views/homeview/{recently_added_image_card.templ => recently_added_image.templ} (51%) diff --git a/views/homeview/homeview.templ b/views/homeview/homeview.templ index cc365b4..45a3652 100644 --- a/views/homeview/homeview.templ +++ b/views/homeview/homeview.templ @@ -29,11 +29,7 @@ templ home(_ *views.Context, data Data) {

Recently Added

-
- for _, image := range data.RecentlyAddedImages.Images { - @RecentlyAddedImageCard(image, 0) - } -
+ @RecentlyAddedImageList(data.RecentlyAddedImages.Images, 0)

Subreddits

diff --git a/views/homeview/recently_added_image_card.templ b/views/homeview/recently_added_image.templ similarity index 51% rename from views/homeview/recently_added_image_card.templ rename to views/homeview/recently_added_image.templ index e64422c..8165a54 100644 --- a/views/homeview/recently_added_image_card.templ +++ b/views/homeview/recently_added_image.templ @@ -18,13 +18,13 @@ const ( ) templ RecentlyAddedImageCard(data *models.Image, opts ImageCardOption) { -
+
{ @@ -34,18 +34,28 @@ templ RecentlyAddedImageCard(data *models.Image, opts ImageCardOption) { if !opts.Has(HideTitle) { { data.Title } } { data.Poster } - if data.R.Subreddit != nil { - if !opts.Has(HideSubreddit) { - { data.R.Subreddit.Name } +
+ if data.R.Subreddit != nil { + if !opts.Has(HideSubreddit) { + { data.R.Subreddit.Name } + } } - } +
} + +templ RecentlyAddedImageList(images models.ImageSlice, opts ImageCardOption) { +
+ for _, data := range images { + @RecentlyAddedImageCard(data, opts) + } +
+}