ash_hq/lib/ash_hq_web/components/icon.ex

55 lines
1.4 KiB
Elixir
Raw Normal View History

2023-05-14 11:27:54 +12:00
defmodule AshHqWeb.Components.Icon do
@moduledoc """
Defines icons for different types of resources.
"""
2024-04-03 09:38:44 +13:00
use Phoenix.Component
import AshHqWeb.Tails
2023-05-14 11:27:54 +12:00
2024-04-03 09:38:44 +13:00
attr(:type, :string, required: true)
attr(:classes, :string, required: false, default: "")
2023-05-14 11:27:54 +12:00
2024-04-03 09:38:44 +13:00
def icon(assigns) do
2023-05-14 11:27:54 +12:00
case assigns.type do
type when type in ["Dsl", "DSL"] ->
2024-04-03 09:38:44 +13:00
~H"""
<span class={classes(["hero-puzzle-piece", @classes])}/>
2023-05-14 11:27:54 +12:00
"""
"Forum" ->
2024-04-03 09:38:44 +13:00
~H"""
<span class={classes(["hero-user-group", @classes])}/>
2023-05-14 11:27:54 +12:00
"""
type when type in ["Guide", "Guides"] ->
2024-04-03 09:38:44 +13:00
~H"""
<span class={classes(["hero-book-open", @classes])}/>
2023-05-14 11:27:54 +12:00
"""
type when type in ["Mix Task", "Mix Tasks"] ->
# Command-line icon
2024-04-03 09:38:44 +13:00
~H"""
2023-05-14 11:27:54 +12:00
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class={@classes}
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6.75 7.5l3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0021 18V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v12a2.25 2.25 0 002.25 2.25z"
/>
</svg>
"""
_default ->
# Includes the Code category
2024-04-03 09:38:44 +13:00
~H"""
<span class={classes(["hero-code-bracket", @classes])}/>
2023-05-14 11:27:54 +12:00
"""
end
end
end