freedive/lib/freedive_web/live/home_live.ex

99 lines
2.8 KiB
Elixir
Raw Normal View History

2024-05-13 19:35:09 +02:00
defmodule FreediveWeb.HomeLive do
use FreediveWeb, :live_view
def render(assigns) do
~H"""
2024-05-15 22:18:00 +02:00
<.block class="px-2 py-4">
2024-05-14 01:21:07 +02:00
<.panel is-info>
2024-05-15 22:18:00 +02:00
<.panel_heading>
Home
</.panel_heading>
2024-05-14 01:21:07 +02:00
<.panel_tabs is-hidden-mobile>
<a class="is-active">All</a>
<a>Compute</a>
<a>Storage</a>
<a>Network</a>
<a>System</a>
</.panel_tabs>
2024-05-15 22:18:00 +02:00
2024-05-14 01:21:07 +02:00
<.panel_tabs is-hidden-tablet>
2024-05-15 22:18:00 +02:00
<a title="All" is-active>
<.icon for="all" color="auto" />
2024-05-14 02:52:55 +02:00
</a>
2024-05-14 21:58:42 +02:00
<a title="Compute">
2024-05-15 22:18:00 +02:00
<.icon for="compute" color="auto" />
2024-05-14 02:52:55 +02:00
</a>
2024-05-14 21:58:42 +02:00
<a title="Storage">
2024-05-15 22:18:00 +02:00
<.icon for="storage" color="auto" />
2024-05-14 02:52:55 +02:00
</a>
2024-05-14 21:58:42 +02:00
<a title="Network">
2024-05-15 22:18:00 +02:00
<.icon for="network" color="auto" />
2024-05-14 21:58:42 +02:00
</a>
<a title="System">
2024-05-15 22:18:00 +02:00
<.icon for="system" color="auto" />
2024-05-14 02:52:55 +02:00
</a>
2024-05-14 01:21:07 +02:00
</.panel_tabs>
<.panel_block>
<.control has-icons-left>
<input
class="input is-info"
type="text"
placeholder="Search"
name="search"
value={@query}
/>
2024-05-15 22:18:00 +02:00
<.icon for="search" size="1.5rem" aria-hidden="true" is-left />
2024-05-14 01:21:07 +02:00
</.control>
</.panel_block>
2024-05-15 22:18:00 +02:00
2024-05-14 01:21:07 +02:00
<.link patch={~p"/services"} class="panel-block pt-1">
<span class="panel-icon">
2024-05-14 21:58:42 +02:00
<.icon for="puzzle" color="auto" aria-hidden="true" />
2024-05-14 01:21:07 +02:00
</span>
2024-05-14 21:58:42 +02:00
<div class="mt-2 ml-2">Services</div>
2024-05-14 01:21:07 +02:00
</.link>
<.link patch={~p"/packages"} class="panel-block pt-1">
<span class="panel-icon">
2024-05-14 21:58:42 +02:00
<.icon for="package" color="auto" aria-hidden="true" />
2024-05-14 01:21:07 +02:00
</span>
2024-05-14 21:58:42 +02:00
<span class="mt-2 ml-2">Packages</span>
2024-05-14 01:21:07 +02:00
</.link>
<.link patch={~p"/updates"} class="panel-block pt-1">
<span class="panel-icon">
2024-05-14 21:58:42 +02:00
<.icon for="hard-drive-download" color="auto" aria-hidden="true" />
2024-05-14 01:21:07 +02:00
</span>
2024-05-14 21:58:42 +02:00
<span class="mt-2 ml-2">Software updates</span>
2024-05-14 01:21:07 +02:00
</.link>
</.panel>
2024-05-15 22:18:00 +02:00
</.block>
<.section>
<.box>
<.button phx-click="color" phx-value-enable="true">
Color
</.button>
<.button phx-click="color" phx-value-enable="false">
Grayscale
</.button>
</.box>
2024-05-13 19:35:09 +02:00
</.section>
"""
end
def mount(_params, _session, socket) do
2024-05-15 22:18:00 +02:00
socket = assign(socket, query: "all")
2024-05-13 19:35:09 +02:00
{:ok, socket}
end
2024-05-15 22:18:00 +02:00
def handle_event("color", %{"enable" => "true"}, socket) do
Freedive.Features.enable(:colorhash)
{:noreply, assign(socket, query: "color")}
end
def handle_event("color", %{"enable" => "false"}, socket) do
Freedive.Features.disable(:colorhash)
{:noreply, assign(socket, query: "grayscale")}
end
2024-05-13 19:35:09 +02:00
end