about summary refs log tree commit diff stats
path: root/examples/simple/simple.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-12-10 13:00:23 +0100
committerGitHub2020-12-10 13:00:23 +0100
commita76262652b227c95ce140f3698c46f59b79354ac (patch)
tree15987ad4a4a4f830f0df9fc110faf667fe83514a /examples/simple/simple.go
parenta7e24c6cddaafb98091c3989c9da7779eeba30b5 (diff)
downloadgomponents-a76262652b227c95ce140f3698c46f59b79354ac.tar.lz
gomponents-a76262652b227c95ce140f3698c46f59b79354ac.tar.zst
gomponents-a76262652b227c95ce140f3698c46f59b79354ac.zip
Move elements and attributes into html package (#52)
This makes it easier to use dot-imports.

Also updated the readme and examples with new usage, and move the `Classes` helper into the `components` package.
Diffstat (limited to 'examples/simple/simple.go')
-rw-r--r--examples/simple/simple.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/simple/simple.go b/examples/simple/simple.go
index dd6dd58..535fa6e 100644
--- a/examples/simple/simple.go
+++ b/examples/simple/simple.go
@@ -5,8 +5,8 @@ import (
 	"time"
 
 	g "github.com/maragudk/gomponents"
-	"github.com/maragudk/gomponents/attr"
-	"github.com/maragudk/gomponents/el"
+	c "github.com/maragudk/gomponents/components"
+	h "github.com/maragudk/gomponents/html"
 )
 
 func main() {
@@ -27,22 +27,22 @@ type props struct {
 }
 
 func page(p props) g.Node {
-	return el.Document(
-		el.HTML(attr.Lang("en"),
-			el.Head(
-				el.Title(p.title),
-				el.Style(attr.Type("text/css"),
+	return h.Document(
+		h.HTML(h.Lang("en"),
+			h.Head(
+				h.TitleEl(p.title),
+				h.StyleEl(h.Type("text/css"),
 					g.Raw(".is-active{font-weight: bold}"),
 					g.Raw("ul.nav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; }"),
 					g.Raw("ul.nav li { display: block;  padding: 8px; float: left; }"),
 				),
 			),
-			el.Body(
+			h.Body(
 				navbar(navbarProps{path: p.path}),
-				el.Hr(),
-				el.H1(p.title),
-				el.P(g.Textf("Welcome to the page at %v.", p.path)),
-				el.P(g.Textf("Rendered at %v", time.Now())),
+				h.Hr(),
+				h.H1(p.title),
+				h.P(g.Textf("Welcome to the page at %v.", p.path)),
+				h.P(g.Textf("Rendered at %v", time.Now())),
 			),
 		),
 	)
@@ -63,9 +63,9 @@ func navbar(props navbarProps) g.Node {
 	}
 	lis := g.Map(len(items), func(i int) g.Node {
 		item := items[i]
-		return el.Li(
-			el.A(item.path, attr.Classes(map[string]bool{"is-active": props.path == item.path}), g.Text(item.text)),
+		return h.Li(
+			h.A(item.path, c.Classes(map[string]bool{"is-active": props.path == item.path}), g.Text(item.text)),
 		)
 	})
-	return el.Ul(attr.Class("nav"), g.Group(lis))
+	return h.Ul(h.Class("nav"), g.Group(lis))
 }