Current section
Files
Jump to
Current section
Files
src/glaze@oat@sidebar.erl
-module(glaze@oat@sidebar).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/oat/sidebar.gleam").
-export([sidebar/3, sidebar_always/3, toggle/2, nav/2, topnav/2, aside/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/sidebar/>\n"
"\n"
" Sidebar layout helpers for responsive app navigation.\n"
"\n"
" ## Anatomy\n"
"\n"
" A sidebar layout usually includes a layout wrapper, a toggle control, a\n"
" sidebar `aside`, and navigation content.\n"
"\n"
" [`sidebar`](#sidebar) enables collapsible behavior on smaller screens,\n"
" while [`sidebar_always`](#sidebar_always) keeps the sidebar visible.\n"
"\n"
" ## Recipe\n"
"\n"
" ```gleam\n"
" import glaze/oat/sidebar\n"
" import lustre/element/html\n"
"\n"
" sidebar.sidebar(html.div, [], [\n"
" sidebar.toggle([], [html.text(\"Menu\")]),\n"
" sidebar.aside([], [sidebar.nav([], [html.text(\"Navigation\")])]),\n"
" html.main([], [html.text(\"Content\")]),\n"
" ])\n"
" ```\n"
).
-file("src/glaze/oat/sidebar.gleam", 34).
?DOC(
" Render a responsive sidebar layout wrapper.\n"
"\n"
" Use this for layouts that collapse to a toggleable sidebar on small screens.\n"
).
-spec sidebar(
fun((list(lustre@vdom@vattr:attribute(PTG)), list(lustre@vdom@vnode:element(PTG))) -> lustre@vdom@vnode:element(PTG)),
list(lustre@vdom@vattr:attribute(PTG)),
list(lustre@vdom@vnode:element(PTG))
) -> lustre@vdom@vnode:element(PTG).
sidebar(Element, Attrs, Children) ->
Element(
[lustre@attribute:attribute(<<"data-sidebar-layout"/utf8>>, <<""/utf8>>) |
Attrs],
Children
).
-file("src/glaze/oat/sidebar.gleam", 46).
?DOC(
" Render a sidebar layout that is always visible.\n"
"\n"
" Use this for desktop-first layouts where the sidebar should never collapse.\n"
).
-spec sidebar_always(
fun((list(lustre@vdom@vattr:attribute(PTR)), list(lustre@vdom@vnode:element(PTR))) -> lustre@vdom@vnode:element(PTR)),
list(lustre@vdom@vattr:attribute(PTR)),
list(lustre@vdom@vnode:element(PTR))
) -> lustre@vdom@vnode:element(PTR).
sidebar_always(Element, Attrs, Children) ->
Element(
[lustre@attribute:attribute(
<<"data-sidebar-layout"/utf8>>,
<<"always"/utf8>>
) |
Attrs],
Children
).
-file("src/glaze/oat/sidebar.gleam", 54).
-spec toggle(
list(lustre@vdom@vattr:attribute(PUC)),
list(lustre@vdom@vnode:element(PUC))
) -> lustre@vdom@vnode:element(PUC).
toggle(Attrs, Children) ->
lustre@element@html:button(
[lustre@attribute:attribute(<<"data-sidebar-toggle"/utf8>>, <<""/utf8>>) |
Attrs],
Children
).
-file("src/glaze/oat/sidebar.gleam", 61).
-spec nav(
list(lustre@vdom@vattr:attribute(PUI)),
list(lustre@vdom@vnode:element(PUI))
) -> lustre@vdom@vnode:element(PUI).
nav(Attrs, Children) ->
lustre@element@html:nav(Attrs, Children).
-file("src/glaze/oat/sidebar.gleam", 68).
-spec topnav(
list(lustre@vdom@vattr:attribute(PUO)),
list(lustre@vdom@vnode:element(PUO))
) -> lustre@vdom@vnode:element(PUO).
topnav(Attrs, Children) ->
lustre@element@html:nav(
[lustre@attribute:attribute(<<"data-topnav"/utf8>>, <<""/utf8>>) |
Attrs],
Children
).
-file("src/glaze/oat/sidebar.gleam", 75).
-spec aside(
list(lustre@vdom@vattr:attribute(PUU)),
list(lustre@vdom@vnode:element(PUU))
) -> lustre@vdom@vnode:element(PUU).
aside(Attrs, Children) ->
lustre@element@html:aside(
[lustre@attribute:attribute(<<"data-sidebar"/utf8>>, <<""/utf8>>) |
Attrs],
Children
).