Current section
Files
Jump to
Current section
Files
src/gbr@ui@alert.erl
-module(gbr@ui@alert).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src\\gbr\\ui\\alert.gleam").
-export([desc/2, title/2, open/2, info/1, success/1, warning/1, error/1, class/2, class_title/2, class_desc/2, at/1, inner/2, new/2, class_icon/2, classes_status_info/3, classes_status_success/3, classes_status_warn/3, classes_status_error/3, class_status_info/3, class_status_success/3, class_status_warn/3, class_status_error/3, class_content/2, render/1]).
-export_type([status/0, u_i_alert/0, u_i_alert_render/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(
"\n"
" Gleam UI super alert elements.\n"
"\n"
).
-type status() :: success | warning | error | info.
-opaque u_i_alert() :: {u_i_alert,
gbr@ui@core@el:u_i_el(),
gbr@ui@desc:u_i_desc(),
status(),
boolean(),
boolean()}.
-opaque u_i_alert_render(QYB) :: {u_i_alert_render,
u_i_alert(),
list(lustre@vdom@vnode:element(QYB))}.
-file("src\\gbr\\ui\\alert.gleam", 80).
?DOC(" Replace alert title\n").
-spec desc(u_i_alert(), binary()) -> u_i_alert().
desc(In, Desc) ->
Info = gbr@ui@desc:content(erlang:element(3, In), Desc),
{u_i_alert,
erlang:element(2, In),
Info,
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 72).
?DOC(" Replace alert title\n").
-spec title(u_i_alert(), binary()) -> u_i_alert().
title(In, Title) ->
Info = gbr@ui@desc:title(erlang:element(3, In), Title),
{u_i_alert,
erlang:element(2, In),
Info,
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 88).
?DOC(" Set open alert element.\n").
-spec open(u_i_alert(), boolean()) -> u_i_alert().
open(In, Open) ->
{u_i_alert,
erlang:element(2, In),
erlang:element(3, In),
erlang:element(4, In),
Open,
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 94).
?DOC(" Set info behavior to alert\n").
-spec info(u_i_alert()) -> u_i_alert().
info(In) ->
{u_i_alert,
erlang:element(2, In),
erlang:element(3, In),
info,
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 100).
?DOC(" Set success behavior to alert\n").
-spec success(u_i_alert()) -> u_i_alert().
success(In) ->
{u_i_alert,
erlang:element(2, In),
erlang:element(3, In),
success,
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 106).
?DOC(" Set warning behavior to alert\n").
-spec warning(u_i_alert()) -> u_i_alert().
warning(In) ->
{u_i_alert,
erlang:element(2, In),
erlang:element(3, In),
warning,
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 112).
?DOC(" Set error behavior to alert\n").
-spec error(u_i_alert()) -> u_i_alert().
error(In) ->
{u_i_alert,
erlang:element(2, In),
erlang:element(3, In),
error,
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 121).
?DOC(
" Set alert main class style\n"
"\n"
" in: Alert info\n"
" class: Alert class\n"
).
-spec class(u_i_alert(), binary()) -> u_i_alert().
class(In, Class) ->
El = gbr@ui@core@el:class(erlang:element(2, In), Class),
{u_i_alert,
El,
erlang:element(3, In),
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 143).
?DOC(
" Set alert title class style\n"
"\n"
" in: Alert title info\n"
" class: Alert title class\n"
).
-spec class_title(u_i_alert(), binary()) -> u_i_alert().
class_title(In, Class) ->
Info = gbr@ui@desc:class_title(erlang:element(3, In), Class),
{u_i_alert,
erlang:element(2, In),
Info,
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 154).
?DOC(
" Set alert description class style\n"
"\n"
" in: Alert description info\n"
" class: Alert description class\n"
).
-spec class_desc(u_i_alert(), binary()) -> u_i_alert().
class_desc(In, Class) ->
Info = gbr@ui@desc:class_content(erlang:element(3, In), Class),
{u_i_alert,
erlang:element(2, In),
Info,
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 263).
?DOC(
" New alert render element.\n"
"\n"
" - in: Alert info\n"
).
-spec at(u_i_alert()) -> u_i_alert_render(any()).
at(In) ->
{u_i_alert_render, In, []}.
-file("src\\gbr\\ui\\alert.gleam", 269).
?DOC(" Replace alert inner elements\n").
-spec inner(u_i_alert_render(QYO), list(lustre@vdom@vnode:element(QYO))) -> u_i_alert_render(QYO).
inner(In, Inner) ->
{u_i_alert_render, erlang:element(2, In), Inner}.
-file("src\\gbr\\ui\\alert.gleam", 357).
-spec status_icon(status(), list(lustre@vdom@vattr:attribute(QZM)), boolean()) -> lustre@vdom@vnode:element(QZM).
status_icon(Status, Attrs, Show) ->
gleam@bool:guard(
not Show,
lustre@element:none(),
fun() ->
Status@1 = case Status of
info ->
fun gbr@ui@svg@alert:info/1;
success ->
fun gbr@ui@svg@alert:success/1;
warning ->
fun gbr@ui@svg@alert:warning/1;
error ->
fun gbr@ui@svg@alert:error/1
end,
lustre@element@html:'div'(
Attrs,
[begin
_pipe = gbr@ui@svg:new(24, 24),
_pipe@1 = Status@1(_pipe),
gbr@ui@svg:render(_pipe@1)
end]
)
end
).
-file("src\\gbr\\ui\\alert.gleam", 64).
?DOC(
" New alert super element pass title and description.\n"
"\n"
" - title: Alert title\n"
" - desc: Alert description\n"
).
-spec new(binary(), binary()) -> u_i_alert().
new(Title, Desc) ->
El = gbr@ui@core@el:new(<<"alert"/utf8>>),
Info = gbr@ui@desc:new(Title, Desc),
{u_i_alert, El, Info, info, false, false}.
-file("src\\gbr\\ui\\alert.gleam", 165).
?DOC(
" Set alert icon class style\n"
"\n"
" in: Alert info\n"
" class: Alert icon class to set\n"
).
-spec class_icon(u_i_alert(), binary()) -> u_i_alert().
class_icon(In, Class) ->
El = gbr@ui@core@el:class_key(
erlang:element(2, In),
<<"alert-icon"/utf8>>,
Class
),
{u_i_alert,
El,
erlang:element(3, In),
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 344).
-spec status_key(status()) -> {binary(), binary()}.
status_key(Status) ->
Key = case Status of
info ->
<<"info"/utf8>>;
success ->
<<"success"/utf8>>;
warning ->
<<"warning"/utf8>>;
error ->
<<"error"/utf8>>
end,
Icon_key = <<Key/binary, "alert-icon"/utf8>>,
{Key, Icon_key}.
-file("src\\gbr\\ui\\alert.gleam", 315).
-spec classes_status(
u_i_alert(),
status(),
list({binary(), boolean()}),
list({binary(), boolean()})
) -> u_i_alert().
classes_status(In, Status, Classes, Classes_icon) ->
{Status_key, Status_key_icon} = status_key(Status),
El = begin
_pipe = gbr@ui@core@el:classes_key(
erlang:element(2, In),
Status_key,
Classes
),
gbr@ui@core@el:classes_key(_pipe, Status_key_icon, Classes_icon)
end,
{u_i_alert,
El,
erlang:element(3, In),
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 217).
?DOC(
" Set alert status classes switch\n"
"\n"
" - in: Alert info\n"
" - classes: Alert status classes\n"
" - classes_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec classes_status_info(
u_i_alert(),
list({binary(), boolean()}),
list({binary(), boolean()})
) -> u_i_alert().
classes_status_info(In, Classes, Classes_icon) ->
classes_status(In, info, Classes, Classes_icon).
-file("src\\gbr\\ui\\alert.gleam", 227).
?DOC(
" Set alert status classes switch\n"
"\n"
" - in: Alert info\n"
" - classes: Alert status classes\n"
" - classes_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec classes_status_success(
u_i_alert(),
list({binary(), boolean()}),
list({binary(), boolean()})
) -> u_i_alert().
classes_status_success(In, Classes, Classes_icon) ->
classes_status(In, success, Classes, Classes_icon).
-file("src\\gbr\\ui\\alert.gleam", 241).
?DOC(
" Set alert status classes switch style\n"
"\n"
" - in: Alert info\n"
" - classes: Alert status classes\n"
" - classes_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec classes_status_warn(
u_i_alert(),
list({binary(), boolean()}),
list({binary(), boolean()})
) -> u_i_alert().
classes_status_warn(In, Classes, Classes_icon) ->
classes_status(In, warning, Classes, Classes_icon).
-file("src\\gbr\\ui\\alert.gleam", 251).
?DOC(
" Set alert status classes switch\n"
"\n"
" - in: Alert info\n"
" - classes: Alert status classes\n"
" - classes_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec classes_status_error(
u_i_alert(),
list({binary(), boolean()}),
list({binary(), boolean()})
) -> u_i_alert().
classes_status_error(In, Classes, Classes_icon) ->
classes_status(In, error, Classes, Classes_icon).
-file("src\\gbr\\ui\\alert.gleam", 329).
-spec class_status(u_i_alert(), status(), binary(), binary()) -> u_i_alert().
class_status(In, Status, Class, Class_icon) ->
{Status_key, Status_key_icon} = status_key(Status),
El = begin
_pipe = gbr@ui@core@el:class_key(
erlang:element(2, In),
Status_key,
Class
),
gbr@ui@core@el:class_key(_pipe, Status_key_icon, Class_icon)
end,
{u_i_alert,
El,
erlang:element(3, In),
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 177).
?DOC(
" Set alert status class style\n"
"\n"
" - in: Alert info\n"
" - class: Alert status class style\n"
" - class_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec class_status_info(u_i_alert(), binary(), binary()) -> u_i_alert().
class_status_info(In, Class, Class_icon) ->
class_status(In, info, Class, Class_icon).
-file("src\\gbr\\ui\\alert.gleam", 187).
?DOC(
" Set alert status class style\n"
"\n"
" - in: Alert info\n"
" - class: Alert status class style\n"
" - class_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec class_status_success(u_i_alert(), binary(), binary()) -> u_i_alert().
class_status_success(In, Class, Class_icon) ->
class_status(In, success, Class, Class_icon).
-file("src\\gbr\\ui\\alert.gleam", 197).
?DOC(
" Set alert status class style\n"
"\n"
" - in: Alert info\n"
" - class: Alert status class style\n"
" - class_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec class_status_warn(u_i_alert(), binary(), binary()) -> u_i_alert().
class_status_warn(In, Class, Class_icon) ->
class_status(In, warning, Class, Class_icon).
-file("src\\gbr\\ui\\alert.gleam", 207).
?DOC(
" Set alert status class style\n"
"\n"
" - in: Alert info\n"
" - class: Alert status class style\n"
" - class_icon: Alert icon class style, only if `icon_show = True`\n"
).
-spec class_status_error(u_i_alert(), binary(), binary()) -> u_i_alert().
class_status_error(In, Class, Class_icon) ->
class_status(In, error, Class, Class_icon).
-file("src\\gbr\\ui\\alert.gleam", 132).
?DOC(
" Set alert content class style\n"
"\n"
" in: Alert info\n"
" class: Alert content class\n"
).
-spec class_content(u_i_alert(), binary()) -> u_i_alert().
class_content(In, Class) ->
El = gbr@ui@core@el:class_key(
erlang:element(2, In),
<<"alert-content"/utf8>>,
Class
),
{u_i_alert,
El,
erlang:element(3, In),
erlang:element(4, In),
erlang:element(5, In),
erlang:element(6, In)}.
-file("src\\gbr\\ui\\alert.gleam", 277).
?DOC(
" Set attribute el.classes by status\n"
"\n"
" Render super alert element to `lustre/element/html.{div}`.\n"
).
-spec render(u_i_alert_render(QYS)) -> lustre@vdom@vnode:element(QYS).
render(At) ->
{u_i_alert_render, In, Inner} = At,
{u_i_alert, El, Info, Status, Open, Icon_show} = In,
gleam@bool:guard(
not Open,
lustre@element:none(),
fun() ->
{Status_key, Status_key_icon} = status_key(Status),
El_attrs = gbr@ui@core@el:attrs(El),
El_attrs_content = gbr@ui@core@el:attrs_key(
El,
<<"alert-content"/utf8>>
),
El_attrs_icon = gbr@ui@core@el:attrs_key(El, <<"alert-icon"/utf8>>),
El_attrs_status = gbr@ui@core@el:attrs_key(El, Status_key),
El_attrs_status_icon = gbr@ui@core@el:attrs_key(El, Status_key_icon),
El_attrs@1 = begin
_pipe = El_attrs,
lists:append(_pipe, El_attrs_status)
end,
El_attrs_icon@1 = begin
_pipe@1 = El_attrs_icon,
lists:append(_pipe@1, El_attrs_status_icon)
end,
Status_icon = status_icon(Status, El_attrs_icon@1, Icon_show),
Status_info = begin
_pipe@2 = gbr@ui@desc:at(Info, Inner),
gbr@ui@desc:render(_pipe@2)
end,
lustre@element@html:'div'(
El_attrs@1,
[lustre@element@html:'div'(
El_attrs_content,
[Status_icon, Status_info]
)]
)
end
).