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(RUU))) -> lustre@vdom@vnode:element(RUU).
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(RVO))) -> lustre@vdom@vnode:element(RVO).
plus(Attrs) ->
icon(<<"plus"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 139).
-spec minus(list(lustre@vdom@vattr:attribute(RVS))) -> lustre@vdom@vnode:element(RVS).
minus(Attrs) ->
icon(<<"minus"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 143).
-spec x(list(lustre@vdom@vattr:attribute(RVW))) -> lustre@vdom@vnode:element(RVW).
x(Attrs) ->
icon(<<"x"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 147).
-spec check(list(lustre@vdom@vattr:attribute(RWA))) -> lustre@vdom@vnode:element(RWA).
check(Attrs) ->
icon(<<"check"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 151).
-spec chevron_right(list(lustre@vdom@vattr:attribute(RWE))) -> lustre@vdom@vnode:element(RWE).
chevron_right(Attrs) ->
icon(<<"chevron-right"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 155).
-spec chevron_left(list(lustre@vdom@vattr:attribute(RWI))) -> lustre@vdom@vnode:element(RWI).
chevron_left(Attrs) ->
icon(<<"chevron-left"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 159).
-spec chevron_down(list(lustre@vdom@vattr:attribute(RWM))) -> lustre@vdom@vnode:element(RWM).
chevron_down(Attrs) ->
icon(<<"chevron-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 163).
-spec chevron_up(list(lustre@vdom@vattr:attribute(RWQ))) -> lustre@vdom@vnode:element(RWQ).
chevron_up(Attrs) ->
icon(<<"chevron-up"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 167).
-spec arrow_right(list(lustre@vdom@vattr:attribute(RWU))) -> lustre@vdom@vnode:element(RWU).
arrow_right(Attrs) ->
icon(<<"arrow-right"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 171).
-spec arrow_left(list(lustre@vdom@vattr:attribute(RWY))) -> lustre@vdom@vnode:element(RWY).
arrow_left(Attrs) ->
icon(<<"arrow-left"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 175).
-spec search(list(lustre@vdom@vattr:attribute(RXC))) -> lustre@vdom@vnode:element(RXC).
search(Attrs) ->
icon(<<"search"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 179).
-spec settings(list(lustre@vdom@vattr:attribute(RXG))) -> lustre@vdom@vnode:element(RXG).
settings(Attrs) ->
icon(<<"settings"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 183).
-spec user(list(lustre@vdom@vattr:attribute(RXK))) -> lustre@vdom@vnode:element(RXK).
user(Attrs) ->
icon(<<"user"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 187).
-spec home(list(lustre@vdom@vattr:attribute(RXO))) -> lustre@vdom@vnode:element(RXO).
home(Attrs) ->
icon(<<"home"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 191).
-spec menu(list(lustre@vdom@vattr:attribute(RXS))) -> lustre@vdom@vnode:element(RXS).
menu(Attrs) ->
icon(<<"menu"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 195).
-spec more_vertical(list(lustre@vdom@vattr:attribute(RXW))) -> lustre@vdom@vnode:element(RXW).
more_vertical(Attrs) ->
icon(<<"more-vertical"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 199).
-spec more_horizontal(list(lustre@vdom@vattr:attribute(RYA))) -> lustre@vdom@vnode:element(RYA).
more_horizontal(Attrs) ->
icon(<<"more-horizontal"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 203).
-spec trash(list(lustre@vdom@vattr:attribute(RYE))) -> lustre@vdom@vnode:element(RYE).
trash(Attrs) ->
icon(<<"trash-2"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 207).
-spec edit(list(lustre@vdom@vattr:attribute(RYI))) -> lustre@vdom@vnode:element(RYI).
edit(Attrs) ->
icon(<<"pencil"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 211).
-spec copy(list(lustre@vdom@vattr:attribute(RYM))) -> lustre@vdom@vnode:element(RYM).
copy(Attrs) ->
icon(<<"copy"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 215).
-spec external_link(list(lustre@vdom@vattr:attribute(RYQ))) -> lustre@vdom@vnode:element(RYQ).
external_link(Attrs) ->
icon(<<"external-link"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 219).
-spec mail(list(lustre@vdom@vattr:attribute(RYU))) -> lustre@vdom@vnode:element(RYU).
mail(Attrs) ->
icon(<<"mail"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 223).
-spec phone(list(lustre@vdom@vattr:attribute(RYY))) -> lustre@vdom@vnode:element(RYY).
phone(Attrs) ->
icon(<<"phone"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 227).
-spec calendar(list(lustre@vdom@vattr:attribute(RZC))) -> lustre@vdom@vnode:element(RZC).
calendar(Attrs) ->
icon(<<"calendar"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 231).
-spec clock(list(lustre@vdom@vattr:attribute(RZG))) -> lustre@vdom@vnode:element(RZG).
clock(Attrs) ->
icon(<<"clock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 235).
-spec info(list(lustre@vdom@vattr:attribute(RZK))) -> lustre@vdom@vnode:element(RZK).
info(Attrs) ->
icon(<<"info"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 239).
-spec alert_circle(list(lustre@vdom@vattr:attribute(RZO))) -> lustre@vdom@vnode:element(RZO).
alert_circle(Attrs) ->
icon(<<"alert-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 243).
-spec alert_triangle(list(lustre@vdom@vattr:attribute(RZS))) -> lustre@vdom@vnode:element(RZS).
alert_triangle(Attrs) ->
icon(<<"alert-triangle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 247).
-spec check_circle(list(lustre@vdom@vattr:attribute(RZW))) -> lustre@vdom@vnode:element(RZW).
check_circle(Attrs) ->
icon(<<"check-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 251).
-spec x_circle(list(lustre@vdom@vattr:attribute(SAA))) -> lustre@vdom@vnode:element(SAA).
x_circle(Attrs) ->
icon(<<"x-circle"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 255).
-spec loader(list(lustre@vdom@vattr:attribute(SAE))) -> lustre@vdom@vnode:element(SAE).
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(SAI))) -> lustre@vdom@vnode:element(SAI).
refresh(Attrs) ->
icon(<<"refresh-cw"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 263).
-spec download(list(lustre@vdom@vattr:attribute(SAM))) -> lustre@vdom@vnode:element(SAM).
download(Attrs) ->
icon(<<"download"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 267).
-spec upload(list(lustre@vdom@vattr:attribute(SAQ))) -> lustre@vdom@vnode:element(SAQ).
upload(Attrs) ->
icon(<<"upload"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 271).
-spec save(list(lustre@vdom@vattr:attribute(SAU))) -> lustre@vdom@vnode:element(SAU).
save(Attrs) ->
icon(<<"save"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 275).
-spec file(list(lustre@vdom@vattr:attribute(SAY))) -> lustre@vdom@vnode:element(SAY).
file(Attrs) ->
icon(<<"file"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 279).
-spec folder(list(lustre@vdom@vattr:attribute(SBC))) -> lustre@vdom@vnode:element(SBC).
folder(Attrs) ->
icon(<<"folder"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 283).
-spec image(list(lustre@vdom@vattr:attribute(SBG))) -> lustre@vdom@vnode:element(SBG).
image(Attrs) ->
icon(<<"image"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 287).
-spec video(list(lustre@vdom@vattr:attribute(SBK))) -> lustre@vdom@vnode:element(SBK).
video(Attrs) ->
icon(<<"video"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 291).
-spec music(list(lustre@vdom@vattr:attribute(SBO))) -> lustre@vdom@vnode:element(SBO).
music(Attrs) ->
icon(<<"music"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 295).
-spec star(list(lustre@vdom@vattr:attribute(SBS))) -> lustre@vdom@vnode:element(SBS).
star(Attrs) ->
icon(<<"star"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 299).
-spec heart(list(lustre@vdom@vattr:attribute(SBW))) -> lustre@vdom@vnode:element(SBW).
heart(Attrs) ->
icon(<<"heart"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 303).
-spec thumbs_up(list(lustre@vdom@vattr:attribute(SCA))) -> lustre@vdom@vnode:element(SCA).
thumbs_up(Attrs) ->
icon(<<"thumbs-up"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 307).
-spec thumbs_down(list(lustre@vdom@vattr:attribute(SCE))) -> lustre@vdom@vnode:element(SCE).
thumbs_down(Attrs) ->
icon(<<"thumbs-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 311).
-spec share(list(lustre@vdom@vattr:attribute(SCI))) -> lustre@vdom@vnode:element(SCI).
share(Attrs) ->
icon(<<"share-2"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 315).
-spec link(list(lustre@vdom@vattr:attribute(SCM))) -> lustre@vdom@vnode:element(SCM).
link(Attrs) ->
icon(<<"link"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 319).
-spec eye(list(lustre@vdom@vattr:attribute(SCQ))) -> lustre@vdom@vnode:element(SCQ).
eye(Attrs) ->
icon(<<"eye"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 323).
-spec eye_off(list(lustre@vdom@vattr:attribute(SCU))) -> lustre@vdom@vnode:element(SCU).
eye_off(Attrs) ->
icon(<<"eye-off"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 327).
-spec lock(list(lustre@vdom@vattr:attribute(SCY))) -> lustre@vdom@vnode:element(SCY).
lock(Attrs) ->
icon(<<"lock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 331).
-spec unlock(list(lustre@vdom@vattr:attribute(SDC))) -> lustre@vdom@vnode:element(SDC).
unlock(Attrs) ->
icon(<<"unlock"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 335).
-spec key(list(lustre@vdom@vattr:attribute(SDG))) -> lustre@vdom@vnode:element(SDG).
key(Attrs) ->
icon(<<"key"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 339).
-spec filter(list(lustre@vdom@vattr:attribute(SDK))) -> lustre@vdom@vnode:element(SDK).
filter(Attrs) ->
icon(<<"filter"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 343).
-spec sort(list(lustre@vdom@vattr:attribute(SDO))) -> lustre@vdom@vnode:element(SDO).
sort(Attrs) ->
icon(<<"arrow-up-down"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 347).
-spec grid(list(lustre@vdom@vattr:attribute(SDS))) -> lustre@vdom@vnode:element(SDS).
grid(Attrs) ->
icon(<<"grid-3x3"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 351).
-spec list(list(lustre@vdom@vattr:attribute(SDW))) -> lustre@vdom@vnode:element(SDW).
list(Attrs) ->
icon(<<"list"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 355).
-spec moon(list(lustre@vdom@vattr:attribute(SEA))) -> lustre@vdom@vnode:element(SEA).
moon(Attrs) ->
icon(<<"moon"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 359).
-spec sun(list(lustre@vdom@vattr:attribute(SEE))) -> lustre@vdom@vnode:element(SEE).
sun(Attrs) ->
icon(<<"sun"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 363).
-spec github(list(lustre@vdom@vattr:attribute(SEI))) -> lustre@vdom@vnode:element(SEI).
github(Attrs) ->
icon(<<"github"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 367).
-spec twitter(list(lustre@vdom@vattr:attribute(SEM))) -> lustre@vdom@vnode:element(SEM).
twitter(Attrs) ->
icon(<<"twitter"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 371).
-spec linkedin(list(lustre@vdom@vattr:attribute(SEQ))) -> lustre@vdom@vnode:element(SEQ).
linkedin(Attrs) ->
icon(<<"linkedin"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 375).
-spec facebook(list(lustre@vdom@vattr:attribute(SEU))) -> lustre@vdom@vnode:element(SEU).
facebook(Attrs) ->
icon(<<"facebook"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 379).
-spec instagram(list(lustre@vdom@vattr:attribute(SEY))) -> lustre@vdom@vnode:element(SEY).
instagram(Attrs) ->
icon(<<"instagram"/utf8>>, Attrs).
-file("src/glaze/basecoat/icon.gleam", 383).
-spec youtube(list(lustre@vdom@vattr:attribute(SFC))) -> lustre@vdom@vnode:element(SFC).
youtube(Attrs) ->
icon(<<"youtube"/utf8>>, Attrs).