about summary refs log tree commit diff stats
path: root/el
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-09-25 17:36:21 +0200
committerGitHub2020-09-25 17:36:21 +0200
commit4448a48d85e15895ce68c3d2b9ca009a222fcd2a (patch)
treec59978bc25ce95b3df1129f5fffb8fc0bf510b5c /el
parent83faa4caa3e2686ecbfb54ab9c9024c408453563 (diff)
downloadgomponents-4448a48d85e15895ce68c3d2b9ca009a222fcd2a.tar.lz
gomponents-4448a48d85e15895ce68c3d2b9ca009a222fcd2a.tar.zst
gomponents-4448a48d85e15895ce68c3d2b9ca009a222fcd2a.zip
Add remaining sectioning elements as helpers (#25)
Fixes #22.
Diffstat (limited to 'el')
-rw-r--r--el/section.go51
-rw-r--r--el/section_test.go54
2 files changed, 105 insertions, 0 deletions
diff --git a/el/section.go b/el/section.go
index 53e9890..3c31ebc 100644
--- a/el/section.go
+++ b/el/section.go
@@ -4,26 +4,77 @@ import (
 	g "github.com/maragudk/gomponents"
 )
 
+// Address returns an element with name "address" and the given children.
+func Address(children ...g.Node) g.NodeFunc {
+	return g.El("address", children...)
+}
+
+// Article returns an element with name "article" and the given children.
+func Article(children ...g.Node) g.NodeFunc {
+	return g.El("article", children...)
+}
+
+// Aside returns an element with name "aside" and the given children.
+func Aside(children ...g.Node) g.NodeFunc {
+	return g.El("aside", children...)
+}
+
+// Footer returns an element with name "footer" and the given children.
+func Footer(children ...g.Node) g.NodeFunc {
+	return g.El("footer", children...)
+}
+
+// Header returns an element with name "header" and the given children.
+func Header(children ...g.Node) g.NodeFunc {
+	return g.El("header", children...)
+}
+
+// H1 returns an element with name "h1", the given text content, and the given children.
 func H1(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h1", prepend(g.Text(text), children)...)
 }
 
+// H2 returns an element with name "h2", the given text content, and the given children.
 func H2(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h2", prepend(g.Text(text), children)...)
 }
 
+// H3 returns an element with name "h3", the given text content, and the given children.
 func H3(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h3", prepend(g.Text(text), children)...)
 }
 
+// H4 returns an element with name "h4", the given text content, and the given children.
 func H4(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h4", prepend(g.Text(text), children)...)
 }
 
+// H5 returns an element with name "h5", the given text content, and the given children.
 func H5(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h5", prepend(g.Text(text), children)...)
 }
 
+// H6 returns an element with name "h6", the given text content, and the given children.
 func H6(text string, children ...g.Node) g.NodeFunc {
 	return g.El("h6", prepend(g.Text(text), children)...)
 }
+
+// HGroup returns an element with name "hgroup" and the given children.
+func HGroup(children ...g.Node) g.NodeFunc {
+	return g.El("hgroup", children...)
+}
+
+// Main returns an element with name "main" and the given children.
+func Main(children ...g.Node) g.NodeFunc {
+	return g.El("main", children...)
+}
+
+// Nav returns an element with name "nav" and the given children.
+func Nav(children ...g.Node) g.NodeFunc {
+	return g.El("nav", children...)
+}
+
+// Section returns an element with name "section" and the given children.
+func Section(children ...g.Node) g.NodeFunc {
+	return g.El("section", children...)
+}
diff --git a/el/section_test.go b/el/section_test.go
index 5147e04..11c60fb 100644
--- a/el/section_test.go
+++ b/el/section_test.go
@@ -8,6 +8,36 @@ import (
 	"github.com/maragudk/gomponents/el"
 )
 
+func TestAddress(t *testing.T) {
+	t.Run("returns an address element", func(t *testing.T) {
+		assert.Equal(t, `<address />`, el.Address())
+	})
+}
+
+func TestArticle(t *testing.T) {
+	t.Run("returns an article element", func(t *testing.T) {
+		assert.Equal(t, `<article />`, el.Article())
+	})
+}
+
+func TestAside(t *testing.T) {
+	t.Run("returns an aside element", func(t *testing.T) {
+		assert.Equal(t, `<aside />`, el.Aside())
+	})
+}
+
+func TestFooter(t *testing.T) {
+	t.Run("returns a footer element", func(t *testing.T) {
+		assert.Equal(t, `<footer />`, el.Footer())
+	})
+}
+
+func TestHeader(t *testing.T) {
+	t.Run("returns a header element", func(t *testing.T) {
+		assert.Equal(t, `<header />`, el.Header())
+	})
+}
+
 func TestH1(t *testing.T) {
 	t.Run("returns an h1 element", func(t *testing.T) {
 		assert.Equal(t, `<h1 id="headline">hat</h1>`, el.H1("hat", g.Attr("id", "headline")))
@@ -43,3 +73,27 @@ func TestH6(t *testing.T) {
 		assert.Equal(t, `<h6 id="headline">hat</h6>`, el.H6("hat", g.Attr("id", "headline")))
 	})
 }
+
+func TestHGroup(t *testing.T) {
+	t.Run("returns an hgroup element", func(t *testing.T) {
+		assert.Equal(t, `<hgroup />`, el.HGroup())
+	})
+}
+
+func TestMainEl(t *testing.T) {
+	t.Run("returns a main element", func(t *testing.T) {
+		assert.Equal(t, `<main />`, el.Main())
+	})
+}
+
+func TestNav(t *testing.T) {
+	t.Run("returns a nav element", func(t *testing.T) {
+		assert.Equal(t, `<nav />`, el.Nav())
+	})
+}
+
+func TestSection(t *testing.T) {
+	t.Run("returns a section element", func(t *testing.T) {
+		assert.Equal(t, `<section />`, el.Section())
+	})
+}