GamendWeb.Icons (gamend_web v1.0.1216)

Copy Markdown View Source

The typed icon set: every heroicon the site ships, as an atom.

Generated at compile time from deps/heroicons (24px solid set), so the atoms are the icon catalog — :trophy, :currency_dollar, :academic_cap, … all 324 of them. Anything choosing an icon in code does it through a typed value; an unknown atom raises instead of silently rendering nothing.

svg/1 returns the icon's inline SVG (compile-time embedded), which is how <.entity_icon> renders fallbacks — deliberately not the hero-* CSS classes, because Tailwind only generates those for names it finds literally in source, and these names are chosen at runtime.

Entities with no uploaded icon_url fall back to default/1 for their type: every group without an icon shares one icon, every tournament another, and so on. API clients get icon_url as null and apply their own equivalent.

Summary

Functions

The shared default icon atom for an entity type without an icon.

The icon a path/1 URL refers to, or :error for anything else — an uploaded image, a CDN URL, a name we do not ship.

The hero-* class name for a typed icon atom. Raises on unknown atoms.

Every typed icon atom, for pickers and docs.

The URL an icon is served at, for storing in an entity's icon_url.

The icon's raw inline SVG (24px solid, currentColor fill).

Types

entity()

@type entity() :: :quest | :leaderboard | :tournament | :group | :notification

icon()

@type icon() :: atom()

Functions

default(type)

@spec default(entity()) :: icon()

The shared default icon atom for an entity type without an icon.

from_path(arg1)

@spec from_path(String.t()) :: {:ok, icon()} | :error

The icon a path/1 URL refers to, or :error for anything else — an uploaded image, a CDN URL, a name we do not ship.

get(icon)

@spec get(icon()) :: String.t()

The hero-* class name for a typed icon atom. Raises on unknown atoms.

list()

@spec list() :: [icon()]

Every typed icon atom, for pickers and docs.

path(icon)

@spec path(icon()) :: String.t()

The URL an icon is served at, for storing in an entity's icon_url.

iex> GamendWeb.Icons.path(:trophy)
"/icons/trophy.svg"

Storing a URL rather than an atom keeps icon_url one kind of thing: a game client fetches it like any other icon, while the web UI recognises its own route and inlines the SVG instead (see GamendWeb.CoreComponents.entity_icon/1), so currentColor still follows the theme.

svg(icon)

@spec svg(icon()) :: String.t()

The icon's raw inline SVG (24px solid, currentColor fill).