From 17ae71488442590b5d92248b14328ed8008912df Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Tue, 18 Jul 2023 00:19:10 +0100 Subject: :truck: Move html-related constructors into a separate module. --- src/lustre/html.gleam | 1191 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1191 insertions(+) create mode 100644 src/lustre/html.gleam (limited to 'src') diff --git a/src/lustre/html.gleam b/src/lustre/html.gleam new file mode 100644 index 0000000..0f64b08 --- /dev/null +++ b/src/lustre/html.gleam @@ -0,0 +1,1191 @@ +// IMPORTS --------------------------------------------------------------------- + +import lustre/element.{Element, h, t} +import lustre/attribute.{Attribute} + +// HTML ELEMENTS: MAIN ROOT ---------------------------------------------------- + +/// Represents the root (top-level element) of an HTML document, so it is also +/// referred to as the root element. All other elements must be descendants of +/// this element. +/// +pub fn html( + attrs: List(Attribute(msg)), + children: List(Element(msg)), +) -> Element(msg) { + h("html", attrs, children) +} + +// HTML ELEMENTS: DOCUMENT METADATA -------------------------------------------- + +/// Specifies the base URL to use for all relative URLs in a document. There can +/// be only one such element in a document. +/// +pub fn base(attrs: List(Attribute(msg))) -> Element(msg) { + h("base", attrs, []) +} + +/// Contains machine-readable information (metadata) about the document, like its +/// title, scripts, and style sheets. +/// +pub fn head(attrs: List(Attribute(msg))) -> Element(msg) { + h("head", attrs, []) +} + +/// Specifies relationships between the current document and an external resource. +/// This element is most commonly used to link to CSS but is also used to establish +/// site icons (both "favicon" style icons and icons for the home screen and apps +/// on mobile devices) among other things. +/// +pub fn link(attrs: List(Attribute(msg))) -> Element(msg) { + h("link", attrs, []) +} + +/// Represents metadata that cannot be represented by other HTML meta-related +/// elements, like , ,