add random color generation to tags
This commit is contained in:
		| @@ -55,4 +55,13 @@ defmodule CanneryWeb.TagLive.FormComponent do | ||||
|         {:noreply, socket |> assign(changeset: changeset)} | ||||
|     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 | ||||
|   | ||||
| @@ -16,13 +16,17 @@ | ||||
|   </span> | ||||
|  | ||||
|   <%= 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"> | ||||
|     <%= error_tag f, :bg_color %> | ||||
|   </span> | ||||
|  | ||||
|   <%= 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"> | ||||
|     <%= error_tag f, :text_color %> | ||||
|   </span> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user