From 41f6c9a245c58cdb5b18308bafbb05f6e95eaa53 Mon Sep 17 00:00:00 2001 From: darius Date: Thu, 14 Mar 2024 21:32:27 +0100 Subject: [PATCH] dark/light mode toggle with htmx --- .idea/portfolio.iml | 1 + api/webHandler/homepageHandler.go | 5 +++ api/webRoutes.go | 1 + templates/homepage/index.html | 54 ++---------------------------- templates/navbar/index.html | 35 ------------------- templates/themeSelector/index.html | 27 +++++++++++++++ 6 files changed, 37 insertions(+), 86 deletions(-) create mode 100644 templates/themeSelector/index.html diff --git a/.idea/portfolio.iml b/.idea/portfolio.iml index aab2721..977e05a 100644 --- a/.idea/portfolio.iml +++ b/.idea/portfolio.iml @@ -8,5 +8,6 @@ + \ No newline at end of file diff --git a/api/webHandler/homepageHandler.go b/api/webHandler/homepageHandler.go index 8dd6ec9..3561c5c 100644 --- a/api/webHandler/homepageHandler.go +++ b/api/webHandler/homepageHandler.go @@ -10,6 +10,7 @@ func InitHomepage(w http.ResponseWriter, r *http.Request) { tmpl := template.Must(template.ParseFiles( "./templates/homepage/index.html", "./templates/navbar/index.html", + "./templates/themeSelector/index.html", )) err := tmpl.Execute(w, nil) @@ -22,11 +23,15 @@ func InitHomepage(w http.ResponseWriter, r *http.Request) { } } +func UpdateTheme(w http.ResponseWriter, r *http.Request) { +} + func Test(w http.ResponseWriter, r *http.Request) { tmpl := template.Must(template.ParseFiles( "./templates/homepage/index.html", "./templates/navbar/index.html", + "./templates/themeSelector/index.html", )) err := tmpl.Execute(w, nil) diff --git a/api/webRoutes.go b/api/webRoutes.go index 1faeeec..013629f 100644 --- a/api/webRoutes.go +++ b/api/webRoutes.go @@ -10,6 +10,7 @@ func WebRoutes(mux **http.ServeMux) { // Register the routes and webHandler m.HandleFunc("GET /{$}", webHandler.InitHomepage) m.HandleFunc("GET /projecten/{$}", webHandler.InitProjectpage) + m.HandleFunc("POST /theme", webHandler.UpdateTheme) m.HandleFunc("GET /test", webHandler.Test) diff --git a/templates/homepage/index.html b/templates/homepage/index.html index 4eec81b..d7eb51b 100644 --- a/templates/homepage/index.html +++ b/templates/homepage/index.html @@ -7,6 +7,7 @@ Portfolio Darius + @@ -92,57 +93,8 @@ {{template "navbar"}} - - - - - - - - - - - - - - - - - - + {{template "themeSelector" + }} diff --git a/templates/navbar/index.html b/templates/navbar/index.html index 94d6ba2..938a46a 100644 --- a/templates/navbar/index.html +++ b/templates/navbar/index.html @@ -1,34 +1,4 @@ {{define "navbar"}} - - - - - - - - - - - - - - - - - - - - - {{end}} diff --git a/templates/themeSelector/index.html b/templates/themeSelector/index.html new file mode 100644 index 0000000..ebd4ddb --- /dev/null +++ b/templates/themeSelector/index.html @@ -0,0 +1,27 @@ +{{define "themeSelector"}} + + + + + + + + + + + + + + + + + +
+ + +
+{{end}} \ No newline at end of file