Packages

🍩 Lustre Bindings to Oat UI Components

Current section

Files

Jump to
glaze_oat src glaze@oat@card.erl
Raw

src/glaze@oat@card.erl

-module(glaze@oat@card).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/oat/card.gleam").
-export([instance/3, card/2, header/2, content/2, footer/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/card/>\n"
"\n"
" The [`card`](#card) helpers compose grouped content blocks such as summaries,\n"
" settings sections, and dashboard tiles.\n"
"\n"
" ## Anatomy\n"
"\n"
" A card is typically an outer container with optional `header`, `content`,\n"
" and `footer` regions. You can use only the regions you need.\n"
"\n"
" ## Recipes\n"
"\n"
" ### A basic card\n"
"\n"
" ```gleam\n"
" import glaze/oat/card\n"
" import lustre/element/html\n"
"\n"
" fn profile_card() {\n"
" card.card([], [\n"
" card.header([], [html.h3([], [html.text(\"Profile\")])]),\n"
" card.content([], [html.p([], [html.text(\"Update your details.\")])]),\n"
" card.footer([], [html.button([], [html.text(\"Save\")])]),\n"
" ])\n"
" }\n"
" ```\n"
"\n"
" ### Content-only card\n"
"\n"
" ```gleam\n"
" import glaze/oat/card\n"
" import lustre/element/html\n"
"\n"
" fn simple_card() {\n"
" card.card([], [\n"
" card.content([], [html.text(\"Just content\")]),\n"
" ])\n"
" }\n"
" ```\n"
).
-file("src/glaze/oat/card.gleam", 60).
?DOC(
" Render card styling on a custom container element.\n"
"\n"
" Use this when your layout needs a different wrapper tag.\n"
).
-spec instance(
fun((list(lustre@vdom@vattr:attribute(PFQ)), list(lustre@vdom@vnode:element(PFQ))) -> lustre@vdom@vnode:element(PFQ)),
list(lustre@vdom@vattr:attribute(PFQ)),
list(lustre@vdom@vnode:element(PFQ))
) -> lustre@vdom@vnode:element(PFQ).
instance(Element, Attrs, Children) ->
Element([lustre@attribute:class(<<"card"/utf8>>) | Attrs], Children).
-file("src/glaze/oat/card.gleam", 49).
?DOC(
" Render a card container.\n"
"\n"
" Use this for grouped content blocks such as summaries and settings panels.\n"
).
-spec card(
list(lustre@vdom@vattr:attribute(PFK)),
list(lustre@vdom@vnode:element(PFK))
) -> lustre@vdom@vnode:element(PFK).
card(Attrs, Children) ->
instance(fun lustre@element@html:article/2, Attrs, Children).
-file("src/glaze/oat/card.gleam", 68).
-spec header(
list(lustre@vdom@vattr:attribute(PGB)),
list(lustre@vdom@vnode:element(PGB))
) -> lustre@vdom@vnode:element(PGB).
header(Attrs, Children) ->
lustre@element@html:header(Attrs, Children).
-file("src/glaze/oat/card.gleam", 75).
-spec content(
list(lustre@vdom@vattr:attribute(PGH)),
list(lustre@vdom@vnode:element(PGH))
) -> lustre@vdom@vnode:element(PGH).
content(Attrs, Children) ->
lustre@element@html:main(Attrs, Children).
-file("src/glaze/oat/card.gleam", 82).
-spec footer(
list(lustre@vdom@vattr:attribute(PGN)),
list(lustre@vdom@vnode:element(PGN))
) -> lustre@vdom@vnode:element(PGN).
footer(Attrs, Children) ->
lustre@element@html:footer(Attrs, Children).