forked from shibao/cannery
add random color generation to tags
This commit is contained in:
parent
b8255a91bd
commit
f96956cf5e
@ -55,4 +55,13 @@ defmodule CanneryWeb.TagLive.FormComponent do
|
|||||||
{:noreply, socket |> assign(changeset: changeset)}
|
{:noreply, socket |> assign(changeset: changeset)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns a random tag color in `#ffffff` hex format
|
||||||
|
"""
|
||||||
|
@spec random_color() :: String.t()
|
||||||
|
def random_color() do
|
||||||
|
["#cc0066", "#ff6699", "#6666ff", "#0066cc", "#00cc66", "#669900", "#ff9900", "#996633"]
|
||||||
|
|> Enum.random()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,13 +16,17 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<%= label f, :bg_color, class: "title text-lg text-primary-500" %>
|
<%= label f, :bg_color, class: "title text-lg text-primary-500" %>
|
||||||
<%= color_input f, :bg_color, class: "mx-auto col-span-2" %>
|
<span class="mx-auto col-span-2" phx-update="ignore">
|
||||||
|
<%= color_input f, :bg_color, value: random_color() %>
|
||||||
|
</span>
|
||||||
<span class="col-span-3">
|
<span class="col-span-3">
|
||||||
<%= error_tag f, :bg_color %>
|
<%= error_tag f, :bg_color %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<%= label f, :text_color, class: "title text-lg text-primary-500" %>
|
<%= label f, :text_color, class: "title text-lg text-primary-500" %>
|
||||||
<%= color_input f, :text_color, class: "mx-auto col-span-2" %>
|
<span class="mx-auto col-span-2" phx-update="ignore">
|
||||||
|
<%= color_input f, :text_color, value: "#ffffff" %>
|
||||||
|
</span>
|
||||||
<span class="col-span-3">
|
<span class="col-span-3">
|
||||||
<%= error_tag f, :text_color %>
|
<%= error_tag f, :text_color %>
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user