diff --git a/.gitignore b/.gitignore
index 01ecd05..65cdf45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,3 +46,6 @@ npm-debug.log
# FreeBSD package
*.pkg
+
+# Local temp
+_attic/
diff --git a/lib/freedive_web/live/liliform_live.ex b/lib/freedive_web/live/liliform_live.ex
new file mode 100644
index 0000000..87396ed
--- /dev/null
+++ b/lib/freedive_web/live/liliform_live.ex
@@ -0,0 +1,79 @@
+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_tabs is-hidden-mobile>
+ All
+ Compute
+ Storage
+ Network
+ System
+
+
+ <.panel_tabs is-hidden-tablet>
+
+ <.icon for="all" color="auto" />
+
+
+ <.icon for="compute" color="auto" />
+
+
+ <.icon for="storage" color="auto" />
+
+
+ <.icon for="network" color="auto" />
+
+
+ <.icon for="system" color="auto" />
+
+
+
+ <.panel_block>
+ <.control has-icons-left>
+
+ <.icon for="search" size="1.5rem" aria-hidden="true" is-left />
+
+
+
+
+ <.section>
+ <.box>
+ <.button phx-click="color" phx-value-enable="true">
+ Color
+
+ <.button phx-click="color" phx-value-enable="false">
+ Grayscale
+
+
+
+ """
+ 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")}
+ end
+end
diff --git a/lib/liliform/colorhash.ex b/lib/liliform/colorhash.ex
index 3f5c476..19ef2e7 100644
--- a/lib/liliform/colorhash.ex
+++ b/lib/liliform/colorhash.ex
@@ -3,6 +3,7 @@ defmodule Liliform.Colorhash do
Given a string returns HSL color.
"""
alias Freedive.Features
+ require Logger
@seed "zeni"
@default_color {0, 0, 0}
@@ -20,6 +21,7 @@ defmodule Liliform.Colorhash do
"""
def hsl(input, raw: true) do
if Features.enabled?(:colorhash) do
+ Logger.debug("Colorhash enabled")
input = String.downcase(input) <> @seed
hash = :erlang.phash2(input, 2_147_483_647)
@@ -29,6 +31,7 @@ defmodule Liliform.Colorhash do
{hue, saturation, lightness}
else
+ Logger.debug("Colorhash disabled")
@default_color
end
end
diff --git a/lib/liliform/icon.ex b/lib/liliform/icon.ex
index 252524c..abe0b68 100644
--- a/lib/liliform/icon.ex
+++ b/lib/liliform/icon.ex
@@ -17,6 +17,7 @@ defmodule Liliform.Icon do
"""
use Liliform.Component
alias Liliform.Colorhash
+ alias Freedive.Features
@doc """
Renders an icon.
@@ -71,7 +72,7 @@ defmodule Liliform.Icon do
~H"""
- <.icon_svg for={@for} height={@size} width={@size} color={icon_color(assigns)} />
+ <.icon_svg for={@for} height={@size} width={@size} {icon_color(assigns)} />
<%= if @inner_block != [] do %>
@@ -92,10 +93,30 @@ defmodule Liliform.Icon do
end
defp icon_color(assigns) do
- case assigns.color do
- nil -> ""
- "auto" -> Colorhash.hsl(assigns.for)
- color -> color
+ if Features.enabled?(:colorhash) do
+ color =
+ case assigns.color do
+ nil -> ""
+ "auto" -> Colorhash.hsl(assigns.for)
+ color -> color
+ end
+
+ case assigns.for do
+ "alert" -> [class: "has-text-danger"]
+ "info" -> [class: "has-text-info"]
+ "success" -> [class: "has-text-success"]
+ "warning" -> [class: "has-text-warning"]
+ "error" -> [class: "has-text-danger"]
+ "all" -> [color: "magenta"]
+ "compute" -> [color: "blue"]
+ "storage" -> [color: "green"]
+ "network" -> [color: "orange"]
+ "system" -> [color: "purple"]
+ "account" -> [color: "darkblue"]
+ _ -> [color: color]
+ end
+ else
+ [class: "has-text-dark"]
end
end
@@ -113,6 +134,7 @@ defmodule Liliform.Icon do
"network" -> :earth
"system" -> :bot
"account" -> :user
+ "all" -> :infinity
lucide_name -> String.to_atom(lucide_name)
end
end