Current section
Files
Jump to
Current section
Files
src/glaze@oat@badge.erl
-module(glaze@oat@badge).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/oat/badge.gleam").
-export([instance/3, badge/2, secondary/0, outline/0, success/0, warning/0, danger/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/badge/>\n"
"\n"
" The [`badge`](#badge) element, sometimes called a \"tag\", is used to attach\n"
" short contextual information to nearby content.\n"
"\n"
" Common examples include labels like \"New\", \"Beta\", \"Paid\", or status chips\n"
" in lists and cards.\n"
"\n"
" ## Anatomy\n"
"\n"
" A badge is a compact inline container for short labels.\n"
" In practice this is usually a single word or short phrase, sometimes with\n"
" an icon.\n"
"\n"
" ## Recipes\n"
"\n"
" ### A basic badge\n"
"\n"
" ```gleam\n"
" import glaze/oat/badge\n"
" import lustre/element/html\n"
"\n"
" fn new_label() {\n"
" badge.badge([], [html.text(\"New\")])\n"
" }\n"
" ```\n"
"\n"
" ### A success badge\n"
"\n"
" ```gleam\n"
" import glaze/oat/badge\n"
" import lustre/element/html\n"
"\n"
" fn sync_status() {\n"
" badge.badge([badge.success()], [html.text(\"Synced\")])\n"
" }\n"
" ```\n"
"\n"
" ## Variants\n"
"\n"
" - [`secondary`](#secondary)\n"
" - [`outline`](#outline)\n"
" - [`success`](#success)\n"
" - [`warning`](#warning)\n"
" - [`danger`](#danger)\n"
"\n"
).
-file("src/glaze/oat/badge.gleam", 67).
?DOC(
" Render badge styling on a custom element.\n"
"\n"
" This is useful when your markup needs a different wrapper tag.\n"
).
-spec instance(
fun((list(lustre@vdom@vattr:attribute(OZB)), list(lustre@vdom@vnode:element(OZB))) -> lustre@vdom@vnode:element(OZB)),
list(lustre@vdom@vattr:attribute(OZB)),
list(lustre@vdom@vnode:element(OZB))
) -> lustre@vdom@vnode:element(OZB).
instance(Element, Attrs, Children) ->
Element([lustre@attribute:class(<<"badge"/utf8>>) | Attrs], Children).
-file("src/glaze/oat/badge.gleam", 56).
?DOC(
" Render a badge.\n"
"\n"
" Use this for compact labels such as \"New\", \"Beta\", or status text.\n"
).
-spec badge(
list(lustre@vdom@vattr:attribute(OYV)),
list(lustre@vdom@vnode:element(OYV))
) -> lustre@vdom@vnode:element(OYV).
badge(Attrs, Children) ->
instance(fun lustre@element@html:span/2, Attrs, Children).
-file("src/glaze/oat/badge.gleam", 75).
-spec secondary() -> lustre@vdom@vattr:attribute(any()).
secondary() ->
lustre@attribute:class(<<"secondary"/utf8>>).
-file("src/glaze/oat/badge.gleam", 79).
-spec outline() -> lustre@vdom@vattr:attribute(any()).
outline() ->
lustre@attribute:class(<<"outline"/utf8>>).
-file("src/glaze/oat/badge.gleam", 83).
-spec success() -> lustre@vdom@vattr:attribute(any()).
success() ->
lustre@attribute:class(<<"success"/utf8>>).
-file("src/glaze/oat/badge.gleam", 87).
-spec warning() -> lustre@vdom@vattr:attribute(any()).
warning() ->
lustre@attribute:class(<<"warning"/utf8>>).
-file("src/glaze/oat/badge.gleam", 91).
-spec danger() -> lustre@vdom@vattr:attribute(any()).
danger() ->
lustre@attribute:class(<<"danger"/utf8>>).