Current section
Files
Jump to
Current section
Files
src/glaze@oat@tabs.erl
-module(glaze@oat@tabs).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/oat/tabs.gleam").
-export([tabs/2, tablist/2, tab/2, tabpanel/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(
" Oat documentation: <https://oat.ink/components/tabs/>\n"
"\n"
" Tabs helpers for grouped content views.\n"
"\n"
" ## Anatomy\n"
"\n"
" A tab view usually has a [`tablist`](#tablist) containing one or more\n"
" [`tab`](#tab) controls, plus matching [`tabpanel`](#tabpanel) sections.\n"
"\n"
" ## Recipe\n"
"\n"
" ```gleam\n"
" import glaze/oat/tabs\n"
" import lustre/attribute\n"
" import lustre/element/html\n"
"\n"
" tabs.tabs([], [\n"
" tabs.tablist([], [\n"
" tabs.tab([attribute(\"aria-selected\", \"true\")], [html.text(\"Overview\")]),\n"
" tabs.tab([], [html.text(\"Details\")]),\n"
" ]),\n"
" tabs.tabpanel([], [html.text(\"Overview content\")]),\n"
" tabs.tabpanel([], [html.text(\"Details content\")]),\n"
" ])\n"
" ```\n"
"\n"
" ## References\n"
"\n"
" - MDN ARIA `tablist` role:\n"
" <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tablist_role>\n"
" - MDN ARIA `tab` role:\n"
" <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tab_role>\n"
" - MDN ARIA `tabpanel` role:\n"
" <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tabpanel_role>\n"
).
-file("src/glaze/oat/tabs.gleam", 40).
-spec tabs(
list(lustre@vdom@vattr:attribute(PZZ)),
list(lustre@vdom@vnode:element(PZZ))
) -> lustre@vdom@vnode:element(PZZ).
tabs(Attrs, Children) ->
lustre@element:element(<<"ot-tabs"/utf8>>, Attrs, Children).
-file("src/glaze/oat/tabs.gleam", 47).
-spec tablist(
list(lustre@vdom@vattr:attribute(QAF)),
list(lustre@vdom@vnode:element(QAF))
) -> lustre@vdom@vnode:element(QAF).
tablist(Attrs, Children) ->
lustre@element@html:'div'(
[lustre@attribute:role(<<"tablist"/utf8>>) | Attrs],
Children
).
-file("src/glaze/oat/tabs.gleam", 54).
-spec tab(
list(lustre@vdom@vattr:attribute(QAL)),
list(lustre@vdom@vnode:element(QAL))
) -> lustre@vdom@vnode:element(QAL).
tab(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:role(<<"tab"/utf8>>) | Attrs],
Children
).
-file("src/glaze/oat/tabs.gleam", 61).
-spec tabpanel(
list(lustre@vdom@vattr:attribute(QAR)),
list(lustre@vdom@vnode:element(QAR))
) -> lustre@vdom@vnode:element(QAR).
tabpanel(Attrs, Children) ->
lustre@element@html:'div'(
[lustre@attribute:role(<<"tabpanel"/utf8>>) | Attrs],
Children
).