Packages
high_mountains
1.0.0
High Mountains is a Gleam library for working with Alpine JS through Lustre attributes.
Current section
Files
Jump to
Current section
Files
src/high_mountains@transition_modifier.erl
-module(high_mountains@transition_modifier).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/high_mountains/transition_modifier.gleam").
-export([scale_origin_to_string/1, to_string/1]).
-export_type([transition_modifier/0, scale_origin/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type transition_modifier() :: {duration, integer()} |
{delay, integer()} |
opacity |
{scale, gleam@option:option(integer()), list(scale_origin())}.
-type scale_origin() :: top | right | left | bottom.
-file("src/high_mountains/transition_modifier.gleam", 40).
?DOC(false).
-spec scale_origin_to_string(scale_origin()) -> binary().
scale_origin_to_string(Origin) ->
case Origin of
bottom ->
<<".bottom"/utf8>>;
left ->
<<".left"/utf8>>;
right ->
<<".right"/utf8>>;
top ->
<<".top"/utf8>>
end.
-file("src/high_mountains/transition_modifier.gleam", 20).
?DOC(false).
-spec to_string(transition_modifier()) -> binary().
to_string(Mod) ->
case Mod of
{delay, Ms} ->
<<<<".delay."/utf8, (erlang:integer_to_binary(Ms))/binary>>/binary,
"ms"/utf8>>;
{duration, Ms@1} ->
<<<<".duration."/utf8, (erlang:integer_to_binary(Ms@1))/binary>>/binary,
"ms"/utf8>>;
opacity ->
<<".opacity"/utf8>>;
{scale, {some, Percentage}, Origin} ->
<<<<".scale."/utf8, (erlang:integer_to_binary(Percentage))/binary>>/binary,
(gleam@list:fold(
Origin,
<<""/utf8>>,
fun(Acc, Origin@1) ->
<<Acc/binary,
(scale_origin_to_string(Origin@1))/binary>>
end
))/binary>>;
{scale, none, Origin@2} ->
<<".scale."/utf8,
(gleam@list:fold(
Origin@2,
<<""/utf8>>,
fun(Acc@1, Origin@3) ->
<<Acc@1/binary,
(scale_origin_to_string(Origin@3))/binary>>
end
))/binary>>
end.