Current section
Files
Jump to
Current section
Files
src/glaze_oat@spinner.erl
-module(glaze_oat@spinner).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze_oat/spinner.gleam").
-export([busy/0, size/1, overlay/0, size_overlay/1]).
-export_type([size/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.
?MODULEDOC(
" Oat documentation: <https://oat.ink/components/spinner/>\n"
"\n"
" Spinner attribute helpers for loading states.\n"
"\n"
" ## Anatomy\n"
"\n"
" Apply these attributes to the element that visually represents loading.\n"
" Use [`busy`](#busy) for accessibility state and one of the size helpers to\n"
" control presentation.\n"
"\n"
" ## Recipes\n"
"\n"
" ```gleam\n"
" import glaze_oat/spinner\n"
" import lustre/element/html\n"
"\n"
" html.div([spinner.busy(), spinner.size(spinner.Large)], [])\n"
" ```\n"
"\n"
" ```gleam\n"
" import glaze_oat/spinner\n"
" import lustre/attribute\n"
" import lustre/element/html\n"
"\n"
" html.div([attribute.class(\"relative\")], [\n"
" html.div([], [html.text(\"Loading profile...\")]),\n"
" html.div([spinner.busy(), spinner.size_overlay(spinner.Small)], []),\n"
" ])\n"
" ```\n"
"\n"
" ## References\n"
"\n"
" - MDN `aria-busy`:\n"
" <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-busy>\n"
).
-type size() :: small | large.
-file("src/glaze_oat/spinner.gleam", 47).
?DOC(" Set `aria-busy=\"true\"` to mark content as loading.\n").
-spec busy() -> lustre@vdom@vattr:attribute(any()).
busy() ->
lustre@attribute:attribute(<<"aria-busy"/utf8>>, <<"true"/utf8>>).
-file("src/glaze_oat/spinner.gleam", 53).
?DOC(" Set spinner size styling.\n").
-spec size(size()) -> lustre@vdom@vattr:attribute(any()).
size(Size) ->
case Size of
small ->
lustre@attribute:data(<<"data-spinner"/utf8>>, <<"small"/utf8>>);
large ->
lustre@attribute:data(<<"data-spinner"/utf8>>, <<"large"/utf8>>)
end.
-file("src/glaze_oat/spinner.gleam", 62).
?DOC(" Enable overlay spinner styling.\n").
-spec overlay() -> lustre@vdom@vattr:attribute(any()).
overlay() ->
lustre@attribute:data(<<"data-spinner"/utf8>>, <<"overlay"/utf8>>).
-file("src/glaze_oat/spinner.gleam", 68).
?DOC(" Set spinner size with overlay styling.\n").
-spec size_overlay(size()) -> lustre@vdom@vattr:attribute(any()).
size_overlay(Size) ->
case Size of
small ->
lustre@attribute:data(
<<"data-spinner"/utf8>>,
<<"small overlay"/utf8>>
);
large ->
lustre@attribute:data(
<<"data-spinner"/utf8>>,
<<"large overlay"/utf8>>
)
end.