about summary refs log tree commit diff stats
path: root/examples/dot-import/dot-import.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-12-10 14:27:10 +0100
committerGitHub2020-12-10 14:27:10 +0100
commit428a2519eaa8e16767f86b417abd5af007f24fc6 (patch)
tree7458b63507259b0225c0e41d249aeb7b36ebeff8 /examples/dot-import/dot-import.go
parentfebffb600db7fbfd81827ded1b8fa3774bf42107 (diff)
downloadgomponents-428a2519eaa8e16767f86b417abd5af007f24fc6.tar.lz
gomponents-428a2519eaa8e16767f86b417abd5af007f24fc6.tar.zst
gomponents-428a2519eaa8e16767f86b417abd5af007f24fc6.zip
Change main example to be the dot-import version (#56)
Diffstat (limited to 'examples/dot-import/dot-import.go')
-rw-r--r--examples/dot-import/dot-import.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/examples/dot-import/dot-import.go b/examples/dot-import/dot-import.go
deleted file mode 100644
index d735785..0000000
--- a/examples/dot-import/dot-import.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-import (
-	"net/http"
-
-	g "github.com/maragudk/gomponents"
-	. "github.com/maragudk/gomponents/components"
-	. "github.com/maragudk/gomponents/html"
-)
-
-func main() {
-	_ = http.ListenAndServe("localhost:8080", http.HandlerFunc(handler))
-}
-
-func handler(w http.ResponseWriter, r *http.Request) {
-	page := Page("Hi!", r.URL.Path)
-	_ = page.Render(w)
-}
-
-func Page(title, currentPath string) g.Node {
-	return HTML5(HTML5Props{
-		Title:    title,
-		Language: "en",
-		Head: []g.Node{
-			StyleEl(Type("text/css"), g.Raw(".is-active{ font-weight: bold }")),
-		},
-		Body: []g.Node{
-			Navbar(currentPath),
-			H1(title),
-			P(g.Textf("Welcome to the page at %v.", currentPath)),
-		},
-	})
-}
-
-func Navbar(currentPath string) g.Node {
-	return Nav(
-		NavbarLink("/", "Home", currentPath),
-		NavbarLink("/about", "About", currentPath),
-	)
-}
-
-func NavbarLink(href, name, currentPath string) g.Node {
-	return A(Href(href), Classes{"is-active": currentPath == href}, g.Text(name))
-}