Current section
Files
Jump to
Current section
Files
src/illustrious@link.erl
-module(illustrious@link).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([link/3]).
-spec link(
binary(),
list(lustre@internals@vdom:attribute(illustrious@state:illustrious_action(OTA))),
list(lustre@internals@vdom:element(illustrious@state:illustrious_action(OTA)))
) -> lustre@internals@vdom:element(illustrious@state:illustrious_action(OTA)).
link(Href, Attributes, Content) ->
lustre@element@html:a(
[lustre@attribute:href(Href),
lustre@event:on(
<<"click"/utf8>>,
fun(Ev) ->
gleam@result:'try'(
(gleam@dynamic:field(
<<"metaKey"/utf8>>,
fun gleam@dynamic:bool/1
))(Ev),
fun(Meta_down) ->
gleam@result:'try'(
(gleam@dynamic:field(
<<"ctrlKey"/utf8>>,
fun gleam@dynamic:bool/1
))(Ev),
fun(Ctrl_down) ->
gleam@result:'try'(
(gleam@dynamic:field(
<<"shiftKey"/utf8>>,
fun gleam@dynamic:bool/1
))(Ev),
fun(Shift_down) ->
case {Meta_down,
Ctrl_down,
Shift_down} of
{false, false, false} ->
lustre@event:prevent_default(
Ev
),
{ok,
illustrious@client:go_to(
Href
)};
{_, _, _} ->
{error, []}
end
end
)
end
)
end
)
end
) |
Attributes],
Content
).