refactor: replace discover for-you swap with targeted htmx fragment
This commit is contained in:
@@ -256,7 +256,7 @@ func (h *AnimeHandler) HandleDiscoverForYou(c *gin.Context) {
|
|||||||
watchlistMap := h.watchlistMapForAnimes(c.Request.Context(), userID, data.Animes)
|
watchlistMap := h.watchlistMapForAnimes(c.Request.Context(), userID, data.Animes)
|
||||||
|
|
||||||
data.Section = "ForYou"
|
data.Section = "ForYou"
|
||||||
data.Fragment = "discover_row"
|
data.Fragment = "discover_for_you_section"
|
||||||
data.WatchlistMap = watchlistMap
|
data.WatchlistMap = watchlistMap
|
||||||
c.HTML(http.StatusOK, "discover.gohtml", data)
|
c.HTML(http.StatusOK, "discover.gohtml", data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{/* For You Section */}}
|
{{/* For You Section */}}
|
||||||
<section class="flex flex-col gap-4">
|
<section id="discover-for-you-section" class="flex flex-col gap-4">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h2 class="text-base font-normal text-foreground">For You</h2>
|
<h2 class="text-base font-normal text-foreground">For You</h2>
|
||||||
<span class="text-sm text-foreground-muted">Based on your watchlist</span>
|
<span class="text-sm text-foreground-muted">Based on your watchlist</span>
|
||||||
</div>
|
</div>
|
||||||
<div hx-get="/api/discover/for-you" hx-trigger="load" hx-swap="outerHTML">
|
<div hx-get="/api/discover/for-you" hx-trigger="load" hx-target="#discover-for-you-section" hx-swap="outerHTML">
|
||||||
{{template "discover_skeleton"}}
|
{{template "discover_skeleton"}}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -93,6 +93,22 @@
|
|||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{define "discover_for_you_section"}}
|
||||||
|
{{if gt (len .Animes) 0}}
|
||||||
|
<section id="discover-for-you-section" class="flex flex-col gap-4">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h2 class="text-base font-normal text-foreground">For You</h2>
|
||||||
|
<span class="text-sm text-foreground-muted">Based on your watchlist</span>
|
||||||
|
</div>
|
||||||
|
<div class="grid gap-4 [grid-template-columns:repeat(auto-fit,minmax(160px,1fr))]">
|
||||||
|
{{range .Animes}}
|
||||||
|
{{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}}
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{define "discover_skeleton"}}
|
{{define "discover_skeleton"}}
|
||||||
<div class="discover-grid">
|
<div class="discover-grid">
|
||||||
{{range (seq 8)}}
|
{{range (seq 8)}}
|
||||||
|
|||||||
Reference in New Issue
Block a user