Current section
Files
Jump to
Current section
Files
src/spectator@internal@views@table.erl
-module(spectator@internal@views@table).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/spectator/internal/views/table.gleam").
-export([heading/7, map_rows/2]).
-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(false).
-file("src/spectator/internal/views/table.gleam", 11).
?DOC(false).
-spec heading(
binary(),
binary(),
ADUO,
ADUO,
spectator@internal@api:sort_direction(),
fun((ADUO) -> ADUP),
boolean()
) -> lustre@vdom@vnode:element(ADUP).
heading(
Name,
Title,
Sort_criteria,
Current_sort_criteria,
Current_sort_direction,
Handle_heading_click,
Align_right
) ->
lustre@element@html:th(
[lustre@attribute:title(Title),
lustre@event:on_click(Handle_heading_click(Sort_criteria)),
gleam@bool:guard(
Align_right,
lustre@attribute:class(<<"cell-right"/utf8>>),
fun lustre@attribute:none/0
)],
[case Current_sort_criteria =:= Sort_criteria of
true ->
case Current_sort_direction of
ascending ->
lustre@element@html:text(<<"⬆"/utf8>>);
descending ->
lustre@element@html:text(<<"⬇"/utf8>>)
end;
false ->
lustre@element@html:text(<<""/utf8>>)
end, lustre@element@html:text(Name)]
).
-file("src/spectator/internal/views/table.gleam", 54).
?DOC(false).
-spec map_and_append(list(ADUW), fun((ADUW) -> ADUY), list(ADUY), ADUY) -> list(ADUY).
map_and_append(L, Fun, Acc, Item) ->
case L of
[] ->
lists:reverse([Item | Acc]);
[X | Xs] ->
map_and_append(Xs, Fun, [Fun(X) | Acc], Item)
end.
-file("src/spectator/internal/views/table.gleam", 45).
?DOC(false).
-spec map_rows(list(ADUR), fun((ADUR) -> lustre@vdom@vnode:element(ADUT))) -> list(lustre@vdom@vnode:element(ADUT)).
map_rows(List, Fun) ->
map_and_append(
List,
Fun,
[],
lustre@element@html:tr(
[lustre@attribute:class(<<"buffer-row"/utf8>>)],
[lustre@element@html:td([], [])]
)
).