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]).
-export([heading/7, map_rows/2]).
-file("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 11).
-spec heading(
binary(),
binary(),
APRP,
APRP,
spectator@internal@api:sort_direction(),
fun((APRP) -> APRQ),
boolean()
) -> lustre@internals@vdom:element(APRQ).
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("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 54).
-spec map_and_append(list(APRX), fun((APRX) -> APRZ), list(APRZ), APRZ) -> list(APRZ).
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("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 45).
-spec map_rows(list(APRS), fun((APRS) -> lustre@internals@vdom:element(APRU))) -> list(lustre@internals@vdom:element(APRU)).
map_rows(List, Fun) ->
map_and_append(
List,
Fun,
[],
lustre@element@html:tr(
[lustre@attribute:class(<<"buffer-row"/utf8>>)],
[lustre@element@html:td([], [])]
)
).