Current section

Files

Jump to
glaze_basecoat src glaze@basecoat@icon.erl
Raw

src/glaze@basecoat@icon.erl

-module(glaze@basecoat@icon).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/basecoat/icon.gleam").
-export([init/0, register_cdn/1, icon/2, size_xs/0, size_sm/0, size_md/0, size_lg/0, size_xl/0, thin/0, normal/0, bold/0, plus/1, minus/1, x/1, check/1, chevron_right/1, chevron_left/1, chevron_down/1, chevron_up/1, arrow_right/1, arrow_left/1, search/1, settings/1, user/1, home/1, menu/1, more_vertical/1, more_horizontal/1, trash/1, edit/1, copy/1, external_link/1, mail/1, phone/1, calendar/1, clock/1, info/1, alert_circle/1, alert_triangle/1, check_circle/1, x_circle/1, loader/1, refresh/1, download/1, upload/1, save/1, file/1, folder/1, image/1, video/1, music/1, star/1, heart/1, thumbs_up/1, thumbs_down/1, share/1, link/1, eye/1, eye_off/1, lock/1, unlock/1, key/1, filter/1, sort/1, grid/1, list/1, moon/1, sun/1, github/1, twitter/1, linkedin/1, facebook/1, instagram/1, youtube/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Icon helpers for Lucide icons in Basecoat UIs.\n"
"\n"
" Basecoat uses Lucide icons: <https://lucide.dev>\n"
"\n"
" ## Anatomy\n"
"\n"
" - [`icon`](#icon): render an icon placeholder element\n"
" - [`init`](#init): load Lucide via ESM (bundler/import map)\n"
" - [`register_cdn`](#register_cdn): load Lucide via CDN (no bundler)\n"
"\n"
" ## Recipes\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/icon\n"
"\n"
" icon.icon(\"plus\", [])\n"
" ```\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/icon\n"
"\n"
" html.head([], [\n"
" // Prefer a pinned version in real projects.\n"
" icon.register_cdn(\"latest\"),\n"
" ])\n"
" ```\n"
"\n"
" ## References\n"
"\n"
" - Lucide icon list: <https://lucide.dev/icons>\n"
" - Lucide package guide: <https://lucide.dev/guide/packages/lucide>\n"
"\n"
).
-file("src/glaze/basecoat/icon.gleam", 43).
?DOC(
" Initialize Lucide icons.\n"
"\n"
" Add this script to your `<head>` to enable Lucide icon rendering.\n"
" Requires a JS setup that can resolve `import ... from \"lucide\"`.\n"
).
-spec init() -> lustre@vdom@vnode:element(any()).
init() ->
lustre@element@html:script(
[lustre@attribute:type_(<<"module"/utf8>>)],
<<"import lucide from 'lucide'; lucide.createIcons();"/utf8>>
).
-file("src/glaze/basecoat/icon.gleam", 58).
?DOC(
" Initialize Lucide icons via CDN (no bundler).\n"
"\n"
" This injects Lucide's UMD build from unpkg and runs `lucide.createIcons()` on\n"
" `DOMContentLoaded`.\n"
"\n"
" Lucide recommends pinning a specific version instead of using `latest`.\n"
" See: <https://lucide.dev/guide/packages/lucide>\n"
).
-spec register_cdn(binary()) -> lustre@vdom@vnode:element(any()).
register_cdn(Lucide_version) ->
lustre@element:fragment(
[lustre@element@html:script(
[lustre@attribute:attribute(<<"defer"/utf8>>, <<"defer"/utf8>>),
lustre@attribute:src(
<<<<"https://unpkg.com/lucide@"/utf8,
Lucide_version/binary>>/binary,
"/dist/umd/lucide.min.js"/utf8>>
)],
<<""/utf8>>
),
lustre@element@html:script(
[],
<<"window.addEventListener('DOMContentLoaded', () => lucide.createIcons());"/utf8>>
)]
).
-file("src/glaze/basecoat/icon.gleam", 90).
?DOC(
" Render a Lucide icon by name.\n"
"\n"
" Use the icon name from [lucide.dev/icons](https://lucide.dev/icons).\n"
"\n"
" ### Example\n"
"\n"
" ```gleam\n"
" import glaze/basecoat/icon\n"
"\n"
" icon.icon(\"plus\", [attribute.class(\"size-4\")])\n"
" ```\n"
).
-spec icon(binary(), list(lustre@vdom@vattr:attribute(RTB))) -> lustre@vdom@vnode:element(RTB).
icon(Name, Attrs) ->
lustre@element@html:i(
[lustre@attribute:class(<<"lucide"/utf8>>),
lustre@attribute:attribute(<<"data-lucide"/utf8>>, Name) |
Attrs],
[]
).
-file("src/glaze/basecoat/icon.gleam", 99).
?DOC(" Common icon sizes for convenience.\n").
-spec size_xs() -> lustre@vdom@vattr:attribute(any()).
size_xs() ->
lustre@attribute:class(<<"size-3"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 103).
-spec size_sm() -> lustre@vdom@vattr:attribute(any()).
size_sm() ->
lustre@attribute:class(<<"size-4"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 107).
-spec size_md() -> lustre@vdom@vattr:attribute(any()).
size_md() ->
lustre@attribute:class(<<"size-5"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 111).
-spec size_lg() -> lustre@vdom@vattr:attribute(any()).
size_lg() ->
lustre@attribute:class(<<"size-6"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 115).
-spec size_xl() -> lustre@vdom@vattr:attribute(any()).
size_xl() ->
lustre@attribute:class(<<"size-8"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 121).
?DOC(" Stroke width variants.\n").
-spec thin() -> lustre@vdom@vattr:attribute(any()).
thin() ->
lustre@attribute:class(<<"stroke-1"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 125).
-spec normal() -> lustre@vdom@vattr:attribute(any()).
normal() ->
lustre@attribute:class(<<"stroke-2"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 129).
-spec bold() -> lustre@vdom@vattr:attribute(any()).
bold() ->
lustre@attribute:class(<<"stroke-3"/utf8>>).
-file("src/glaze/basecoat/icon.gleam", 135).
?DOC(" Common icons as constants for convenience.\n").
-spec plus(list(lustre@vdom@vattr:attribute(RTV))) -> lustre@vdom@vnode:element(RTV).
plus(Attrs) ->
icon(<<"plus"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 139).
-spec minus(list(lustre@vdom@vattr:attribute(RTZ))) -> lustre@vdom@vnode:element(RTZ).
minus(Attrs) ->
icon(<<"minus"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 143).
-spec x(list(lustre@vdom@vattr:attribute(RUD))) -> lustre@vdom@vnode:element(RUD).
x(Attrs) ->
icon(<<"x"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 147).
-spec check(list(lustre@vdom@vattr:attribute(RUH))) -> lustre@vdom@vnode:element(RUH).
check(Attrs) ->
icon(<<"check"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 151).
-spec chevron_right(list(lustre@vdom@vattr:attribute(RUL))) -> lustre@vdom@vnode:element(RUL).
chevron_right(Attrs) ->
icon(<<"chevron-right"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 155).
-spec chevron_left(list(lustre@vdom@vattr:attribute(RUP))) -> lustre@vdom@vnode:element(RUP).
chevron_left(Attrs) ->
icon(<<"chevron-left"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 159).
-spec chevron_down(list(lustre@vdom@vattr:attribute(RUT))) -> lustre@vdom@vnode:element(RUT).
chevron_down(Attrs) ->
icon(<<"chevron-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 163).
-spec chevron_up(list(lustre@vdom@vattr:attribute(RUX))) -> lustre@vdom@vnode:element(RUX).
chevron_up(Attrs) ->
icon(<<"chevron-up"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 167).
-spec arrow_right(list(lustre@vdom@vattr:attribute(RVB))) -> lustre@vdom@vnode:element(RVB).
arrow_right(Attrs) ->
icon(<<"arrow-right"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 171).
-spec arrow_left(list(lustre@vdom@vattr:attribute(RVF))) -> lustre@vdom@vnode:element(RVF).
arrow_left(Attrs) ->
icon(<<"arrow-left"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 175).
-spec search(list(lustre@vdom@vattr:attribute(RVJ))) -> lustre@vdom@vnode:element(RVJ).
search(Attrs) ->
icon(<<"search"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 179).
-spec settings(list(lustre@vdom@vattr:attribute(RVN))) -> lustre@vdom@vnode:element(RVN).
settings(Attrs) ->
icon(<<"settings"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 183).
-spec user(list(lustre@vdom@vattr:attribute(RVR))) -> lustre@vdom@vnode:element(RVR).
user(Attrs) ->
icon(<<"user"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 187).
-spec home(list(lustre@vdom@vattr:attribute(RVV))) -> lustre@vdom@vnode:element(RVV).
home(Attrs) ->
icon(<<"home"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 191).
-spec menu(list(lustre@vdom@vattr:attribute(RVZ))) -> lustre@vdom@vnode:element(RVZ).
menu(Attrs) ->
icon(<<"menu"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 195).
-spec more_vertical(list(lustre@vdom@vattr:attribute(RWD))) -> lustre@vdom@vnode:element(RWD).
more_vertical(Attrs) ->
icon(<<"more-vertical"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 199).
-spec more_horizontal(list(lustre@vdom@vattr:attribute(RWH))) -> lustre@vdom@vnode:element(RWH).
more_horizontal(Attrs) ->
icon(<<"more-horizontal"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 203).
-spec trash(list(lustre@vdom@vattr:attribute(RWL))) -> lustre@vdom@vnode:element(RWL).
trash(Attrs) ->
icon(<<"trash-2"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 207).
-spec edit(list(lustre@vdom@vattr:attribute(RWP))) -> lustre@vdom@vnode:element(RWP).
edit(Attrs) ->
icon(<<"pencil"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 211).
-spec copy(list(lustre@vdom@vattr:attribute(RWT))) -> lustre@vdom@vnode:element(RWT).
copy(Attrs) ->
icon(<<"copy"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 215).
-spec external_link(list(lustre@vdom@vattr:attribute(RWX))) -> lustre@vdom@vnode:element(RWX).
external_link(Attrs) ->
icon(<<"external-link"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 219).
-spec mail(list(lustre@vdom@vattr:attribute(RXB))) -> lustre@vdom@vnode:element(RXB).
mail(Attrs) ->
icon(<<"mail"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 223).
-spec phone(list(lustre@vdom@vattr:attribute(RXF))) -> lustre@vdom@vnode:element(RXF).
phone(Attrs) ->
icon(<<"phone"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 227).
-spec calendar(list(lustre@vdom@vattr:attribute(RXJ))) -> lustre@vdom@vnode:element(RXJ).
calendar(Attrs) ->
icon(<<"calendar"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 231).
-spec clock(list(lustre@vdom@vattr:attribute(RXN))) -> lustre@vdom@vnode:element(RXN).
clock(Attrs) ->
icon(<<"clock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 235).
-spec info(list(lustre@vdom@vattr:attribute(RXR))) -> lustre@vdom@vnode:element(RXR).
info(Attrs) ->
icon(<<"info"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 239).
-spec alert_circle(list(lustre@vdom@vattr:attribute(RXV))) -> lustre@vdom@vnode:element(RXV).
alert_circle(Attrs) ->
icon(<<"alert-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 243).
-spec alert_triangle(list(lustre@vdom@vattr:attribute(RXZ))) -> lustre@vdom@vnode:element(RXZ).
alert_triangle(Attrs) ->
icon(<<"alert-triangle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 247).
-spec check_circle(list(lustre@vdom@vattr:attribute(RYD))) -> lustre@vdom@vnode:element(RYD).
check_circle(Attrs) ->
icon(<<"check-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 251).
-spec x_circle(list(lustre@vdom@vattr:attribute(RYH))) -> lustre@vdom@vnode:element(RYH).
x_circle(Attrs) ->
icon(<<"x-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 255).
-spec loader(list(lustre@vdom@vattr:attribute(RYL))) -> lustre@vdom@vnode:element(RYL).
loader(Attrs) ->
icon(
<<"loader-2"/utf8>>,
[lustre@attribute:class(<<"animate-spin"/utf8>>) | Attrs]
).
-file("src/glaze/basecoat/icon.gleam", 259).
-spec refresh(list(lustre@vdom@vattr:attribute(RYP))) -> lustre@vdom@vnode:element(RYP).
refresh(Attrs) ->
icon(<<"refresh-cw"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 263).
-spec download(list(lustre@vdom@vattr:attribute(RYT))) -> lustre@vdom@vnode:element(RYT).
download(Attrs) ->
icon(<<"download"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 267).
-spec upload(list(lustre@vdom@vattr:attribute(RYX))) -> lustre@vdom@vnode:element(RYX).
upload(Attrs) ->
icon(<<"upload"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 271).
-spec save(list(lustre@vdom@vattr:attribute(RZB))) -> lustre@vdom@vnode:element(RZB).
save(Attrs) ->
icon(<<"save"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 275).
-spec file(list(lustre@vdom@vattr:attribute(RZF))) -> lustre@vdom@vnode:element(RZF).
file(Attrs) ->
icon(<<"file"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 279).
-spec folder(list(lustre@vdom@vattr:attribute(RZJ))) -> lustre@vdom@vnode:element(RZJ).
folder(Attrs) ->
icon(<<"folder"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 283).
-spec image(list(lustre@vdom@vattr:attribute(RZN))) -> lustre@vdom@vnode:element(RZN).
image(Attrs) ->
icon(<<"image"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 287).
-spec video(list(lustre@vdom@vattr:attribute(RZR))) -> lustre@vdom@vnode:element(RZR).
video(Attrs) ->
icon(<<"video"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 291).
-spec music(list(lustre@vdom@vattr:attribute(RZV))) -> lustre@vdom@vnode:element(RZV).
music(Attrs) ->
icon(<<"music"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 295).
-spec star(list(lustre@vdom@vattr:attribute(RZZ))) -> lustre@vdom@vnode:element(RZZ).
star(Attrs) ->
icon(<<"star"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 299).
-spec heart(list(lustre@vdom@vattr:attribute(SAD))) -> lustre@vdom@vnode:element(SAD).
heart(Attrs) ->
icon(<<"heart"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 303).
-spec thumbs_up(list(lustre@vdom@vattr:attribute(SAH))) -> lustre@vdom@vnode:element(SAH).
thumbs_up(Attrs) ->
icon(<<"thumbs-up"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 307).
-spec thumbs_down(list(lustre@vdom@vattr:attribute(SAL))) -> lustre@vdom@vnode:element(SAL).
thumbs_down(Attrs) ->
icon(<<"thumbs-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 311).
-spec share(list(lustre@vdom@vattr:attribute(SAP))) -> lustre@vdom@vnode:element(SAP).
share(Attrs) ->
icon(<<"share-2"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 315).
-spec link(list(lustre@vdom@vattr:attribute(SAT))) -> lustre@vdom@vnode:element(SAT).
link(Attrs) ->
icon(<<"link"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 319).
-spec eye(list(lustre@vdom@vattr:attribute(SAX))) -> lustre@vdom@vnode:element(SAX).
eye(Attrs) ->
icon(<<"eye"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 323).
-spec eye_off(list(lustre@vdom@vattr:attribute(SBB))) -> lustre@vdom@vnode:element(SBB).
eye_off(Attrs) ->
icon(<<"eye-off"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 327).
-spec lock(list(lustre@vdom@vattr:attribute(SBF))) -> lustre@vdom@vnode:element(SBF).
lock(Attrs) ->
icon(<<"lock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 331).
-spec unlock(list(lustre@vdom@vattr:attribute(SBJ))) -> lustre@vdom@vnode:element(SBJ).
unlock(Attrs) ->
icon(<<"unlock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 335).
-spec key(list(lustre@vdom@vattr:attribute(SBN))) -> lustre@vdom@vnode:element(SBN).
key(Attrs) ->
icon(<<"key"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 339).
-spec filter(list(lustre@vdom@vattr:attribute(SBR))) -> lustre@vdom@vnode:element(SBR).
filter(Attrs) ->
icon(<<"filter"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 343).
-spec sort(list(lustre@vdom@vattr:attribute(SBV))) -> lustre@vdom@vnode:element(SBV).
sort(Attrs) ->
icon(<<"arrow-up-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 347).
-spec grid(list(lustre@vdom@vattr:attribute(SBZ))) -> lustre@vdom@vnode:element(SBZ).
grid(Attrs) ->
icon(<<"grid-3x3"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 351).
-spec list(list(lustre@vdom@vattr:attribute(SCD))) -> lustre@vdom@vnode:element(SCD).
list(Attrs) ->
icon(<<"list"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 355).
-spec moon(list(lustre@vdom@vattr:attribute(SCH))) -> lustre@vdom@vnode:element(SCH).
moon(Attrs) ->
icon(<<"moon"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 359).
-spec sun(list(lustre@vdom@vattr:attribute(SCL))) -> lustre@vdom@vnode:element(SCL).
sun(Attrs) ->
icon(<<"sun"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 363).
-spec github(list(lustre@vdom@vattr:attribute(SCP))) -> lustre@vdom@vnode:element(SCP).
github(Attrs) ->
icon(<<"github"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 367).
-spec twitter(list(lustre@vdom@vattr:attribute(SCT))) -> lustre@vdom@vnode:element(SCT).
twitter(Attrs) ->
icon(<<"twitter"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 371).
-spec linkedin(list(lustre@vdom@vattr:attribute(SCX))) -> lustre@vdom@vnode:element(SCX).
linkedin(Attrs) ->
icon(<<"linkedin"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 375).
-spec facebook(list(lustre@vdom@vattr:attribute(SDB))) -> lustre@vdom@vnode:element(SDB).
facebook(Attrs) ->
icon(<<"facebook"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 379).
-spec instagram(list(lustre@vdom@vattr:attribute(SDF))) -> lustre@vdom@vnode:element(SDF).
instagram(Attrs) ->
icon(<<"instagram"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 383).
-spec youtube(list(lustre@vdom@vattr:attribute(SDJ))) -> lustre@vdom@vnode:element(SDJ).
youtube(Attrs) ->
icon(<<"youtube"/utf8>>, Attrs).