-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Lo-Fi system status widget
- Loading branch information
1 parent
f69f0da
commit d3916bc
Showing
2 changed files
with
117 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
defmodule DotcomWeb.SystemStatus.Widget do | ||
@moduledoc """ | ||
A component that renders the given `@statuses` in a table. | ||
""" | ||
|
||
use DotcomWeb, :component | ||
|
||
def system_status_widget(assigns) do | ||
~H""" | ||
<div class="flex flex-col gap-2"> | ||
<.status_entry | ||
:for={route_with_statuses <- @routes_with_statuses} | ||
route_with_statuses={route_with_statuses} | ||
/> | ||
</div> | ||
""" | ||
end | ||
|
||
defp status_entry(%{route_with_statuses: %{branches_with_statuses: _}} = assigns) do | ||
~H""" | ||
<.status_entry_for_route | ||
route_with_statuses={@route_with_statuses} | ||
route_id={@route_with_statuses.route_id} | ||
branches_with_statuses={@route_with_statuses.branches_with_statuses} | ||
/> | ||
""" | ||
end | ||
|
||
defp status_entry_for_route(assigns) do | ||
~H""" | ||
<div class="border border-gray-lighter p-2"> | ||
<.status_entry_for_branches | ||
:for={branch <- @branches_with_statuses} | ||
route_id={@route_id} | ||
branch_ids={branch.branch_ids} | ||
statuses={branch.statuses} | ||
/> | ||
</div> | ||
""" | ||
end | ||
|
||
defp status_entry_for_branches(assigns) do | ||
~H""" | ||
<div class="flex gap-2"> | ||
<span class="font-bold"> | ||
{@route_id}<span :for={sub_route <- @branch_ids}>{" "}{sub_route}</span>: | ||
</span> | ||
<div class="flex flex-col"> | ||
<div :for={status <- @statuses}> | ||
<span :if={status.time}>{status.time}:</span> | ||
{status.description} | ||
</div> | ||
</div> | ||
</div> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters