Skip to content
Merged
Changes from 2 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
39 changes: 39 additions & 0 deletions lib/yearbook_web/components/entry_card.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
defmodule YearbookWeb.Components.EntryCard do
@moduledoc """
Entry Card Component.
"""
use Phoenix.Component
import YearbookWeb.Components.Avatar

attr :src, :string, default: nil, doc: "The URL of the image to display."
attr :name, :string, doc: "The name of the user."
attr :text, :string, default: nil, doc: "Text."
attr :size, :string, default: "md", values: ["sm", "md", "lg"], doc: "Card size."
Comment thread
glfaria marked this conversation as resolved.
Outdated

def entry_card(assigns) do
~H"""
<div class={"flex flex-col items-center gap-2 overflow-auto bg-white rounded-xl shadow-md #{size_class(@size)}"}>
<div class="w-full shrink-0 h-3/5 p-2 overflow-hidden">
Comment thread
glfaria marked this conversation as resolved.
Outdated
<%= if @src do %>
<img
src={@src}
alt={@name}
class="w-full h-full object-cover rounded-md"
/>
<% else %>
<div class="flex items-center justify-center w-full h-full rounded-xl bg-gray-300 text-white font-bold text-2xl">
{get_initials(@name)}
</div>
<% end %>
</div>
<h1 class="text-center mx-auto max-w-[90%] font-bold text-xl">{@name}</h1>
<p class="flex-1 text-justify mx-auto px-2 pb-2">{@text}</p>
Comment thread
glfaria marked this conversation as resolved.
Outdated
</div>
"""
end

defp size_class("sm"), do: "w-36 h-64"
defp size_class("md"), do: "w-48 h-84"
defp size_class("lg"), do: "w-64 h-108"
defp size_class(_), do: size_class("md")
Comment thread
glfaria marked this conversation as resolved.
Outdated
end