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

@ -9,11 +9,12 @@ body {
} }
.post { .post {
@apply bg-base-200 shadow-md rounded-md; @apply bg-base-200 shadow-md rounded-md mb-4;
@apply flex flex-col sm:flex-row mb-4; @apply grid grid-cols-[1fr] grid-rows-[min-content_1fr_auto];
@apply sm:grid-cols-[13em_auto] sm:grid-rows-[1fr_auto];
} }
.post :where(article, .userinfo) { .post :where(article, .userinfo) {
@apply p-4 pt-4; @apply p-4 pb-0 sm:pb-4;
} }
.post .bbc-block { .post .bbc-block {

View File

@ -31,16 +31,17 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
~H""" ~H"""
<div class="post"> <div class="post">
<.user info={@author} /> <.user info={@author} />
<article class="grow-1 w-full"> <article class="postbody">
<%= raw @article %> <%= raw @article %>
</article> </article>
<.toolbar date={@date} />
</div> </div>
""" """
end end
def user(assigns) do def user(assigns) do
~H""" ~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> <h3 class="mb-4"><%= @info.name %></h3>
<div class="title hidden sm:flex flex-col text-sm pr-4"> <div class="title hidden sm:flex flex-col text-sm pr-4">
<%= raw @info.title %> <%= raw @info.title %>
@ -49,6 +50,13 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
""" """
end 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 def pagination(assigns) do
%{page: page_number, page_count: page_count} = assigns.thread %{page: page_number, page_count: page_count} = assigns.thread

View File

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