-
Notifications
You must be signed in to change notification settings - Fork 8
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
refactor: improve announcements pages #530
base: develop
Are you sure you want to change the base?
Changes from all commits
e9f3a43
750bedf
8f56c58
55b65af
f61df59
a010415
88d0b12
1c8defc
57d689d
3802137
0d17920
23558c6
f1800bc
6b0f7ec
678c82d
fac57ec
424175a
040ee69
5812fae
a7a468b
8735240
7f1935f
8f248e5
3d16dca
4384942
4a36fa3
a80c0fa
1af4b79
abe715e
01dfeb0
66bda3f
e8c16b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
defmodule AtomicWeb.AnnouncementLive.Components.AnnouncementCard do | ||
@moduledoc false | ||
|
||
import AtomicWeb.Components.Avatar | ||
|
||
use AtomicWeb, :component | ||
|
||
def announcement_card(assigns) do | ||
~H""" | ||
<div class="flex flex-col justify-center rounded-lg bg-white lg:p-4"> | ||
<.link navigate={~p"/organizations/#{@organization}/announcements/#{@announcement}"} class="block"> | ||
<div class="flex items-center space-x-2 px-4 py-1"> | ||
<div class="flex-shrink-0"> | ||
<.avatar name={@announcement.organization.name} color={:light_gray} class="!h-10 !w-10" size={:xs} type={:organization} src={Uploaders.Logo.url({@announcement.organization.logo, @announcement.organization}, :original)} /> | ||
</div> | ||
<div> | ||
<p class="text-sm font-medium text-zinc-700"><%= @announcement.organization.name %></p> | ||
<p class="text-xs text-gray-500"> | ||
<span class="sr-only">Published on</span> | ||
<time><%= relative_datetime(@announcement.inserted_at) %></time> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="px-4 py-2"> | ||
<p class="text-lg font-semibold text-zinc-900" title={@announcement.title}> | ||
Comment on lines
+17
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The activitys component is using |
||
<%= @announcement.title %> | ||
</p> | ||
<p class="mt-2 text-sm leading-relaxed text-zinc-500"> | ||
<%= @announcement.description %> | ||
</p> | ||
</div> | ||
<%= if @announcement.image do %> | ||
<div class="h-auto w-full overflow-hidden"> | ||
<img class="h-full w-full rounded-xl object-cover" src={Uploaders.Post.url({@announcement.image, @announcement}, :original)} alt="Announcement Image" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</div> | ||
<% end %> | ||
</.link> | ||
</div> | ||
""" | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
<div> | ||
<.form :let={f} for={@changeset} id="announcement-form" phx-target={@myself} phx-change="validate" phx-submit="save"> | ||
<.field field={f[:title]} help_text={gettext("The title of the announcement")} type="text" placeholder="Title" required /> | ||
<div class="relative"> | ||
<.form :let={f} for={@changeset} id="announcement-form" phx-target={@myself} phx-change="validate" phx-submit="save" class="space-y-6"> | ||
<div class="relative pb-16"> | ||
<div class="grid gap-4 xl:grid-cols-2"> | ||
<div class="flex flex-col"> | ||
<.field field={f[:title]} type="text" placeholder="Choose a title for the announcement" required class="w-full" /> | ||
|
||
<.field field={f[:description]} help_text={gettext("Announcement description")} type="text" placeholder="Description" required /> | ||
<.field field={f[:description]} type="textarea" placeholder="Write a description" required class="w-full overflow-auto resize-none h-44 xl:h-64" /> | ||
</div> | ||
<div class="space-y-4"> | ||
<.live_component module={ImageUploader} id="uploader" uploads={@uploads} target={@myself} class="object-cover" /> | ||
|
||
<div class="mt-8 flex w-full justify-end"> | ||
<.button size={:md} color={:white} icon="hero-cube" type="submit"><%= gettext("Save Changes") %></.button> | ||
<div class="flex justify-end"> | ||
<.button size={:md} color={:white} icon="hero-cube" type="submit"><%= gettext("Save Changes") %></.button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</.form> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
<.page title="Announcements"> | ||
<:actions> | ||
<%= if not @empty? and @has_permissions? do %> | ||
<.button navigate={~p"/announcements/new"}> | ||
<.button navigate={~p"/organizations/#{@current_organization}/announcements/new"} icon="hero-plus"> | ||
<%= gettext("New") %> | ||
</.button> | ||
<% end %> | ||
</:actions> | ||
<!-- Tabs --> | ||
<.tabs class="max-w-5-xl mx-auto px-4 sm:px-6 lg:px-8"> | ||
<.link patch="?tab=all" replace={false}> | ||
<.tab active={@current_tab == "all"}> | ||
<%= gettext("All") %> | ||
</.tab> | ||
</.link> | ||
|
||
<.link patch="?tab=following" replace={false}> | ||
<.tab active={@current_tab == "following"}> | ||
<%= gettext("Following") %> | ||
</.tab> | ||
</.link> | ||
</.tabs> | ||
<.tabs></.tabs> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This solution to add the border in the page its not that good 😅, but I dont really know other solution. @joaodiaslobo any idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The def page(assigns) do
~H"""
<div class="flex min-h-full flex-col items-stretch justify-between lg:flex-row">
<div class="min-h-[100vh] flex w-full flex-col bg-white lg:flex-row lg:border-r">
<main class="relative z-0 mb-10 flex-1 overflow-y-auto focus:outline-none xl:order-last">
<div class={["mx-auto max-w-5xl px-4 sm:px-6 lg:px-8", @bottom_border && "border-b"]}>
<div class="my-6 flex min-w-0 flex-row items-center justify-between"}>
<h1 class="flex-1 select-none truncate text-2xl font-bold text-gray-900">
<%= @title %>
</h1>
<%= render_slot(@actions) %>
</div>
</div>
<%= render_slot(@inner_block) %>
</main>
</div>
</div>
"""
end And use it like this:
By the way, this PR is looking real good! 🤩 |
||
<!-- Announcements index --> | ||
<%= if @empty? and @has_permissions? do %> | ||
<div class="mt-32"> | ||
<.empty_state url={~p"/announcements/new"} placeholder="announcement" /> | ||
<.empty_state url={~p"/organizations/#{@organization}/announcements/new"} placeholder="announcement" /> | ||
</div> | ||
<% else %> | ||
<div class="overflow-hidden bg-white"> | ||
<ul role="list" class="divide-y divide-zinc-200 overflow-auto"> | ||
<%= for announcement <- @announcements do %> | ||
<li id={announcement.id}> | ||
<.link navigate={~p"/announcements/#{announcement}"} class="block hover:bg-zinc-50"> | ||
<div class="px-4 py-4 lg:px-6"> | ||
<div class="flex items-center justify-between"> | ||
<p class="truncate text-sm font-medium text-zinc-900"> | ||
<%= announcement.title %> | ||
</p> | ||
</div> | ||
<p class="mt-2 text-sm text-zinc-500"> | ||
<%= announcement.description %> | ||
</p> | ||
</div> | ||
</.link> | ||
<.announcement_card announcement={announcement} organization={@organization} /> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a bottom border in the last announcement