diff --git a/.air.toml b/.air.toml deleted file mode 100644 index 6346c58..0000000 --- a/.air.toml +++ /dev/null @@ -1,15 +0,0 @@ -root = "." -tmp_dir = "tmp" - -[build] - bin = "./tmp/main" - cmd = "templ generate && go build -o ./tmp/main ." - exclude_dir = ["static", "migrations", "node_modules", "tmp"] - exclude_regex = ["_test.go", "_templ.go"] - include_ext = ["go", "templ"] - send_interrupt = true - kill_delay = "5s" - stop_on_error = true - -[misc] - clean_on_exit = true diff --git a/db/account.go b/db/account.go index fa14b53..5079e5e 100644 --- a/db/account.go +++ b/db/account.go @@ -4,9 +4,8 @@ import ( "spend-sparrow/log" "spend-sparrow/types" - "github.com/jmoiron/sqlx" - "github.com/google/uuid" + "github.com/jmoiron/sqlx" ) type Account interface { diff --git a/dev.sh b/dev.sh new file mode 100755 index 0000000..1c8f632 --- /dev/null +++ b/dev.sh @@ -0,0 +1,6 @@ +templ generate --watch --proxy="http://localhost:8080" --cmd="go run ." & +npm run watch + +read -n1 -s +kill $(jobs -p) + diff --git a/handler/render.go b/handler/render.go index 21e062d..969f79a 100644 --- a/handler/render.go +++ b/handler/render.go @@ -38,7 +38,7 @@ func (render *Render) RenderLayout(r *http.Request, w http.ResponseWriter, slot func (render *Render) RenderLayoutWithStatus(r *http.Request, w http.ResponseWriter, slot templ.Component, user *types.User, status int) { userComp := render.getUserComp(user) - layout := template.Layout(slot, userComp) + layout := template.Layout(slot, userComp, user != nil, r.URL.Path) render.RenderWithStatus(r, w, layout, status) } diff --git a/handler/index_and_404.go b/handler/root_and_404.go similarity index 79% rename from handler/index_and_404.go rename to handler/root_and_404.go index 82245a4..4d836dd 100644 --- a/handler/index_and_404.go +++ b/handler/root_and_404.go @@ -27,10 +27,10 @@ func NewIndex(service service.Auth, render *Render) Index { } func (handler IndexImpl) Handle(router *http.ServeMux) { - router.Handle("/", handler.handleIndexAnd404()) + router.Handle("/", handler.handleRootAnd404()) } -func (handler IndexImpl) handleIndexAnd404() http.HandlerFunc { +func (handler IndexImpl) handleRootAnd404() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { user := middleware.GetUser(r) @@ -41,7 +41,11 @@ func (handler IndexImpl) handleIndexAnd404() http.HandlerFunc { comp = template.NotFound() status = http.StatusNotFound } else { - comp = template.Index() + if user != nil { + comp = template.Dashboard() + } else { + comp = template.Index() + } status = http.StatusOK } diff --git a/package.json b/package.json index d400340..8ee90b6 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Your (almost) independent tech stack to host on a VPC.", "main": "index.js", "scripts": { - "build": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --minify", - "watch": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --watch" + "build": "cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --minify", + "watch": "cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss -i input.css -o static/css/tailwind.css --watch" }, "keywords": [], "author": "", diff --git a/template/dashboard.templ b/template/dashboard.templ new file mode 100644 index 0000000..700d65d --- /dev/null +++ b/template/dashboard.templ @@ -0,0 +1,9 @@ +package template + +templ Dashboard() { +
+

+ Dashboard +

+
+} diff --git a/template/layout.templ b/template/layout.templ index 0d5a234..b8c8869 100644 --- a/template/layout.templ +++ b/template/layout.templ @@ -1,52 +1,68 @@ package template -templ Layout(slot templ.Component, user templ.Component) { - - +func layoutLinkClass(isActive bool) string { + if isActive { + return "text-xl hover:bg-gray-100 p-1 duration-100 rounded-xl transition-colors text-gray-900" + } + return "text-xl hover:bg-gray-100 hover:text-gray-900 p-1 duration-200 rounded-xl transition-colors text-gray-400" +} - - - SpendSparrow - - - - - - - - - -
- // Header -
-
- - SpendSparrow logo - SpendSparrow - - @user + }' + /> + + + + +
+ // Header +
+ +
+
+ // Content +
+ if slot != nil { + @slot + } +
+ // Footer
-
-
- // Content -
- if slot != nil { - @slot - } -
- // Footer -
-
- -
- - - +
+ +
+ + }