Current section
Files
Jump to
Current section
Files
src/glaze@oat@tooltip.erl
-module(glaze@oat@tooltip).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glaze/oat/tooltip.gleam").
-export([tooltip/1, title/1]).
-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/tooltip/>\n"
"\n"
" Tooltip helpers for short helper text on interactive elements.\n"
"\n"
" ## Anatomy\n"
"\n"
" Use [`tooltip`](#tooltip) for Oat-styled tooltip content and optionally pair\n"
" it with [`title`](#title) so native browser tooltip behavior still exists as\n"
" a fallback.\n"
"\n"
" ## Recipe\n"
"\n"
" ```gleam\n"
" import glaze/oat/tooltip\n"
" import lustre/attribute\n"
" import lustre/element/html\n"
"\n"
" html.button([\n"
" attribute.type_(\"button\"),\n"
" tooltip.tooltip(\"Delete this item\"),\n"
" tooltip.title(\"Delete this item\"),\n"
" ], [html.text(\"Delete\")])\n"
" ```\n"
"\n"
" ## References\n"
"\n"
" - MDN `title` global attribute:\n"
" <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title>\n"
).
-file("src/glaze/oat/tooltip.gleam", 36).
?DOC(
" Add Oat tooltip text to an element.\n"
"\n"
" This sets `data-tooltip`, which Oat styles can read to show tooltip UI.\n"
).
-spec tooltip(binary()) -> lustre@vdom@vattr:attribute(any()).
tooltip(Text) ->
lustre@attribute:attribute(<<"data-tooltip"/utf8>>, Text).
-file("src/glaze/oat/tooltip.gleam", 44).
?DOC(
" Add the native HTML `title` attribute.\n"
"\n"
" Use this when you want browser-default tooltip behavior or a fallback.\n"
).
-spec title(binary()) -> lustre@vdom@vattr:attribute(any()).
title(Text) ->
lustre@attribute:title(Text).