Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browse with four pics next to it. #323

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions lib/dpul_collections_web/live/browse_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule DpulCollectionsWeb.BrowseLive do
<%= gettext("Randomize") %>
</button>
</div>
<div class="grid grid-cols-5 gap-3">
<div class="grid grid-cols-2 gap-6">
<.browse_item :for={item <- @items} item={item} />
</div>
"""
Expand All @@ -48,8 +48,16 @@ defmodule DpulCollectionsWeb.BrowseLive do
def browse_item(assigns) do
~H"""
<div id={"item-#{@item.id}"} class="item">
<div class="flex flex-wrap gap-5 md:max-h-60 max-h-[22rem] overflow-hidden justify-center md:justify-start relative">
<.thumb :if={@item.page_count} thumb={thumbnail_service_url(@item)} />
<div class="grid grid-cols-2 gap-3">
<.thumb :if={@item.page_count} thumb={thumbnail_service_url(@item)} divisor={2} />
<div class="grid grid-cols-2 gap-3">
<.thumb
:for={{thumb, thumb_num} <- thumbnail_service_urls(4, @item.image_service_urls)}
:if={@item.page_count}
thumb={thumb}
thumb_num={thumb_num}
/>
</div>
</div>
<h2 class="underline text-2xl font-bold pt-4">
<.link navigate={@item.url} class="item-link"><%= @item.title %></.link>
Expand All @@ -59,10 +67,22 @@ defmodule DpulCollectionsWeb.BrowseLive do
"""
end

defp thumbnail_service_urls(max_thumbnails, image_service_urls) do
# Truncate image service urls to max value
image_service_urls
|> Enum.slice(1, max_thumbnails)
|> Enum.with_index()
end

def thumb(assigns = %{thumb: nil}) do
~H"""
"""
end

def thumb(assigns) do
~H"""
<img
class="h-[350px] w-[350px] md:h-[225px] md:w-[225px] border border-solid border-gray-400"
class="border border-solid border-gray-400"
src={"#{@thumb}/square/350,350/0/default.jpg"}
alt="thumbnail image"
style="
Expand Down