From e45fc81faa4860bb2d4074a3b600592d7dbd8934 Mon Sep 17 00:00:00 2001 From: Tine Date: Sat, 10 Feb 2024 18:35:16 +0100 Subject: [PATCH] feat: restructure and add settings page --- cmd/server/main.go | 1 + internal/pages/settings.go | 24 ++++ internal/static/css/tailwind.css | 33 ++++- internal/ui/components/base.tmpl | 9 +- internal/ui/pages/index.tmpl | 226 +++++++++++++++---------------- internal/ui/pages/settings.tmpl | 5 + 6 files changed, 178 insertions(+), 120 deletions(-) create mode 100644 internal/pages/settings.go create mode 100644 internal/ui/pages/settings.tmpl diff --git a/cmd/server/main.go b/cmd/server/main.go index 7ac0d53..591f522 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -17,6 +17,7 @@ func main() { r.PathPrefix("/static/").Handler(http.FileServer(http.FS(internal.Static))) r.HandleFunc("/", pages.Index).Methods("GET") + r.HandleFunc("/settings", pages.Settings).Methods("GET") log.Println("Server started on :8000") log.Fatal(http.ListenAndServe(":8000", r)) diff --git a/internal/pages/settings.go b/internal/pages/settings.go new file mode 100644 index 0000000..ed2db3a --- /dev/null +++ b/internal/pages/settings.go @@ -0,0 +1,24 @@ +package pages + +import ( + "net/http" + "text/template" + + "code.tjo.space/mentos1386/zdravko/internal" +) + +func Settings(w http.ResponseWriter, r *http.Request) { + ts, err := template.ParseFS(internal.Templates, + "ui/components/base.tmpl", + "ui/pages/settings.tmpl", + ) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + err = ts.ExecuteTemplate(w, "base", nil) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } +} diff --git a/internal/static/css/tailwind.css b/internal/static/css/tailwind.css index 4079de5..f4930fd 100644 --- a/internal/static/css/tailwind.css +++ b/internal/static/css/tailwind.css @@ -599,12 +599,16 @@ video { margin-right: auto; } -.mt-20 { - margin-top: 5rem; +.mr-1 { + margin-right: 0.25rem; } -.mt-6 { - margin-top: 1.5rem; +.mt-10 { + margin-top: 2.5rem; +} + +.mt-20 { + margin-top: 5rem; } .mt-8 { @@ -623,6 +627,10 @@ video { height: 5rem; } +.h-5 { + height: 1.25rem; +} + .h-8 { height: 2rem; } @@ -631,6 +639,10 @@ video { width: 5rem; } +.w-5 { + width: 1.25rem; +} + .max-w-screen-md { max-width: 768px; } @@ -724,6 +736,11 @@ video { background-color: rgb(134 239 172 / var(--tw-bg-opacity)); } +.bg-green-400 { + --tw-bg-opacity: 1; + background-color: rgb(74 222 128 / var(--tw-bg-opacity)); +} + .bg-green-500 { --tw-bg-opacity: 1; background-color: rgb(34 197 94 / var(--tw-bg-opacity)); @@ -739,6 +756,14 @@ video { background-color: rgb(239 68 68 / var(--tw-bg-opacity)); } +.stroke-\[3\] { + stroke-width: 3; +} + +.p-1 { + padding: 0.25rem; +} + .p-4 { padding: 1rem; } diff --git a/internal/ui/components/base.tmpl b/internal/ui/components/base.tmpl index 5459464..91e9084 100644 --- a/internal/ui/components/base.tmpl +++ b/internal/ui/components/base.tmpl @@ -9,7 +9,14 @@ - {{template "main" .}} + +
+ {{template "main" .}} +