Add stub for liliform liveview helper

This commit is contained in:
Harshad Sharma 2024-05-16 01:48:55 +05:30
parent 2d33f14fcd
commit 0db3e9be30
2 changed files with 17 additions and 76 deletions

View file

@ -1,79 +1,7 @@
defmodule FreediveWeb.LiliformLive do
use FreediveWeb, :live_view
def render(assigns) do
~H"""
<.block class="px-2 py-4">
<.panel is-info>
<.panel_heading>
Home
</.panel_heading>
<.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>
<.panel_tabs is-hidden-tablet>
<a title="All" is-active>
<.icon for="all" color="auto" />
</a>
<a title="Compute">
<.icon for="compute" color="auto" />
</a>
<a title="Storage">
<.icon for="storage" color="auto" />
</a>
<a title="Network">
<.icon for="network" color="auto" />
</a>
<a title="System">
<.icon for="system" color="auto" />
</a>
</.panel_tabs>
<.panel_block>
<.control has-icons-left>
<input
class="input is-info"
type="text"
placeholder="Search"
name="search"
value={@query}
/>
<.icon for="search" size="1.5rem" aria-hidden="true" is-left />
</.control>
</.panel_block>
</.panel>
</.block>
<.section>
<.box>
<.button phx-click="color" phx-value-enable="true">
Color
</.button>
<.button phx-click="color" phx-value-enable="false">
Grayscale
</.button>
</.box>
</.section>
"""
end
def mount(_params, _session, socket) do
socket = assign(socket, query: "all")
{:ok, socket}
end
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")}
defmacro __using__(_) do
quote do
use FreediveWeb, :live_view
end
end
end

View file

@ -0,0 +1,13 @@
defmodule FreediveWeb.ServiceLive do
use FreediveWeb.LiliformLive
def render(assigns) do
~H"""
Hello, World!
"""
end
def mount(_params, _session, socket) do
{:ok, socket}
end
end