Current section

Files

Jump to
shino lib ui helpers.ex
Raw

lib/ui/helpers.ex

defmodule Shino.UI.Helpers do
@moduledoc false
use Phoenix.Component
def mc(nil), do: nil
def mc(classes) when is_list(classes) do
classes
|> List.flatten()
|> Enum.reject(& &1 == nil)
|> Enum.join(" ")
end
def ms(nil), do: nil
def ms(styles) when is_list(styles) do
Enum.join(styles, " ")
end
@doc """
Renders an icon.
"""
attr :name, :string, required: true
attr :class, :any, default: nil
attr :rest, :global
def icon(%{name: "tabler-x"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M18 6l-12 12" /><path d="M6 6l12 12" />
</svg>
"""
end
def icon(%{name: "tabler-menu-2"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6l16 0" /><path d="M4 12l16 0" /><path d="M4 18l16 0" />
</svg>
"""
end
def icon(%{name: "tabler-chevron-right"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 6l6 6l-6 6" />
</svg>
"""
end
def icon(%{name: "tabler-chevron-left"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 6l-6 6l6 6" />
</svg>
"""
end
def icon(%{name: "tabler-dots"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /><path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /><path d="M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" />
</svg>
"""
end
def icon(%{name: "loader-circle"} = assigns) do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class={@class}
{@rest}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 3a9 9 0 1 0 9 9" />
</svg>
"""
end
end