frontend add post toolbar; so far displaying postdate

This commit is contained in:
2022-08-02 13:24:07 +02:00
parent b369c0862b
commit 92469fc558
3 changed files with 18 additions and 9 deletions

View File

@ -31,16 +31,17 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
~H"""
<div class="post">
<.user info={@author} />
<article class="grow-1 w-full">
<article class="postbody">
<%= raw @article %>
</article>
<.toolbar date={@date} />
</div>
"""
end
def user(assigns) do
~H"""
<aside class="userinfo bg-base-100 shrink-0 sm:w-[13em]">
<aside class="userinfo bg-base-100">
<h3 class="mb-4"><%= @info.name %></h3>
<div class="title hidden sm:flex flex-col text-sm pr-4">
<%= raw @info.title %>
@ -49,6 +50,13 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
"""
end
def toolbar(assigns) do
~H"""
<div class="sm:col-span-2 text-sm p-2">
<%= @date |> Calendar.strftime("%A, %b %d %Y @ %H:%M") %></div>
"""
end
def pagination(assigns) do
%{page: page_number, page_count: page_count} = assigns.thread

View File

@ -12,15 +12,15 @@
<% end %>
<h2>
<%= @thread.title %>
<%= raw @thread.title %>
</h2>
<div class="thread my-8">
<.pagination socket={@socket} thread={@thread} />
<%= for post <- @thread.posts do %>
<.post author={post.userinfo} article={post.postbody} />
<% end %>
<.post author={post.userinfo} article={post.postbody} date={post.postdate} />
<% end %>
<.pagination socket={@socket} thread={@thread} />
<.pagination socket={@socket} thread={@thread} />
</div>