From de26bd9e3e725e505fd07b4d61d792672e7ce8e6 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Thu, 20 Jul 2023 23:22:09 +0100 Subject: :recycle: Namespace the html and svg modules under the element module. --- src/lustre/element/html.gleam | 1197 +++++++++++++++++++++++++++++++++++++++++ src/lustre/element/svg.gleam | 351 ++++++++++++ src/lustre/html.gleam | 1197 ----------------------------------------- src/lustre/svg.gleam | 351 ------------ 4 files changed, 1548 insertions(+), 1548 deletions(-) create mode 100644 src/lustre/element/html.gleam create mode 100644 src/lustre/element/svg.gleam delete mode 100644 src/lustre/html.gleam delete mode 100644 src/lustre/svg.gleam (limited to 'src') diff --git a/src/lustre/element/html.gleam b/src/lustre/element/html.gleam new file mode 100644 index 0000000..9eb4f5e --- /dev/null +++ b/src/lustre/element/html.gleam @@ -0,0 +1,1197 @@ +// IMPORTS --------------------------------------------------------------------- + +import lustre/element.{Element, element, namespaced, text} +import lustre/attribute.{Attribute} + +// The doc comments (and order) for functions in this module are taken from the +// MDN Element reference: +// +// https://developer.mozilla.org/en-US/docs/Web/HTML/Element +// + +// 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) { + element("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) { + element("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) { + element("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) { + element("link", attrs, []) +} + +/// Represents metadata that cannot be represented by other HTML meta-related +/// elements, like , ,