Fix UI layout

This commit is contained in:
Harshad Sharma 2024-05-18 17:36:14 +05:30
parent 01d9c54023
commit 9b898a6506
2 changed files with 80 additions and 96 deletions

View file

@ -149,104 +149,88 @@ defmodule FreediveWeb.ServiceLive.Components do
<div class="mt-2 ml-2">Back</div> <div class="mt-2 ml-2">Back</div>
</.link> </.link>
<.panel_media> <.panel_block>
<:icon> <%!-- <.icon_raw for={@selected_item.icon} color="auto" size="3rem" class="" aria-hidden="true" /> --%>
<.icon_raw for={@selected_item.icon} color="auto" size="3rem" aria-hidden="true" /> <.icon_raw for={@selected_item.icon} color="auto" size="3rem" aria-hidden="true" />
<%!-- <Lucideicons.accessibility height="2rem" width="2rem" /> --%> <div class="column">
</:icon> <.title is-4>
<%= @selected_item.name %>
<.title is-4> <%= if @selected_item.running do %>
<%= @selected_item.name %> <.icon for="circle-play" color="lightgreen" aria-hidden="true" />
</.title> <% else %>
<.subtitle> <.icon for="circle-stop" color="gray" aria-hidden="true" />
<%= @selected_item.description %> <% end %>
</.subtitle> <%= if @selected_item.enabled do %>
<.icon for="circle-check" color="lightgreen" aria-hidden="true" />
<:actions> <% else %>
<div class="columns"> <.icon for="circle-x" color="gray" aria-hidden="true" />
<div class="column is-narrow"> <% end %>
<%= if @selected_item.running do %> </.title>
<.icon for="circle-play" color="green" aria-hidden="true" /> <.subtitle>
<% else %> <%= @selected_item.description %>
<.icon for="circle-stop" color="red" aria-hidden="true" /> </.subtitle>
<% end %> </div>
<%= if @selected_item.enabled do %> </.panel_block>
<.icon for="circle-check" color="green" aria-hidden="true" />
<% else %>
<.icon for="circle-x" color="red" aria-hidden="true" />
<% end %>
</div>
</div>
</:actions>
</.panel_media>
<%= if Map.has_key?(@selected_item, :log) and @selected_item.log != [] do %> <%= if Map.has_key?(@selected_item, :log) and @selected_item.log != [] do %>
<.panel_media> <.panel_block>
<:icon>
<.icon for="terminal" color="gray" aria-hidden="true" />
</:icon>
<:actions></:actions>
<pre><code><%= Enum.join(@selected_item.log, "\n") %></code></pre> <pre><code><%= Enum.join(@selected_item.log, "\n") %></code></pre>
</.panel_media> </.panel_block>
<% end %> <% end %>
<.panel_media> <.panel_block_div>
<:icon> <%= if @selected_item.running do %>
<%!-- <.icon for="terminal" color="auto" size="3rem" aria-hidden="true" /> --%> <.icon_raw for="power" color="lightgreen" size="2rem" class="ml-2 mr-5" aria-hidden="true" />
</:icon> <% else %>
<.icon_raw for="power" color="gray" size="2rem" class="ml-2 mr-5" aria-hidden="true" />
<:actions> <% end %>
<div class="columns is-mobile"> <div class="columns is-fullwidth mr-4">
<%= if @selected_item.running do %> <%= if @selected_item.running do %>
<div class="column is-narrow"> <button
class="button is-warning column is-2 m-2 is-fullwidth"
phx-click="action:restart"
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
Restart
</button>
<button
class="button is-danger column is-2 m-2 is-fullwidth"
phx-click="action:stop"
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
Stop
</button>
<% else %>
<button
class="button is-success column is-2 m-2 is-fullwidth"
phx-click="action:start"
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
Start
</button>
<% end %>
</div>
</.panel_block_div>
<%= if @selected_item.commands != [] and @selected_item.commands != nil do %>
<.panel_block_div>
<.icon_raw for="inspection-panel" color="auto" size="2rem" class="ml-1 mr-5" aria-hidden="true" />
<div class="columns is-fullwidth mr-4">
<%= for command <- @selected_item.commands do %>
<button <button
class="button is-warning" class="button is-info column is-2 m-2 is-fullwidth"
phx-click="action:restart" phx-click={"command:#{command}"}
phx-value-name={@selected_item.name} phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []} {if @selected_item.busy, do: [disabled: true], else: []}
> >
Restart <%= command %>
</button> </button>
</div>
<div class="column">
<button
class="button is-danger"
phx-click="action:stop"
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
Stop
</button>
</div>
<% else %>
<div class="column">
<button
class="button is-success"
phx-click="action:start"
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
Start
</button>
</div>
<% end %> <% end %>
</div> </div>
</:actions> </.panel_block_div>
<% end %>
<%= if @selected_item.commands do %>
<%= for command <- @selected_item.commands do %>
<button
class="button is-info"
phx-disable-with="..."
phx-click={"command:#{command}"}
phx-value-name={@selected_item.name}
{if @selected_item.busy, do: [disabled: true], else: []}
>
<%= command %>
</button>
<% end %>
<% end %>
</.panel_media>
""" """
end end
@ -254,18 +238,18 @@ defmodule FreediveWeb.ServiceLive.Components do
~H""" ~H"""
<%= for {_name, item} <- @items do %> <%= for {_name, item} <- @items do %>
<div> <div>
<.link <.panel_block
class={"panel-block pt-1 #{if @selected_item != nil and @selected_item.name == item.name, do: "has-background-info-light"}"} class={"panel-block pt-3 #{if @selected_item != nil and @selected_item.name == item.name, do: "has-background-info-light"}"}
phx-click="tap" phx-click="tap"
phx-value-name={item.name} phx-value-name={item.name}
> >
<span class="panel-icon"> <.icon_raw for={item.icon} color="auto" size="1.8rem" aria-hidden="true" />
<.icon for={item.icon} color="auto" aria-hidden="true" /> <%!-- <div class="mt-2 ml-2"> --%>
</span> <.subtitle class="ml-3">
<div class="mt-2 ml-2">
<%= item.name %> <%= item.name %>
</div> </.subtitle>
</.link> <%!-- </div> --%>
</.panel_block>
</div> </div>
<% end %> <% end %>
""" """

View file

@ -99,11 +99,11 @@ defmodule Liliform.Panel do
~H""" ~H"""
<div class={["panel-block", @class]} {@rest}> <div class={["panel-block", @class]} {@rest}>
<.media class="is-fullwidth"> <.media>
<.media_left> <.media_left>
<%= render_slot(@icon) %> <%= render_slot(@icon) %>
</.media_left> </.media_left>
<.media_content class="is-fullwidth"> <.media_content>
<%= render_slot(@inner_block) %> <%= render_slot(@inner_block) %>
</.media_content> </.media_content>
<.media_right> <.media_right>