From 46d9ff26dd30c509b471197abf491ef10e6c2045 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 29 Mar 2026 15:16:58 +0200 Subject: [PATCH] Add svelte-heros icon library - Install svelte-heros for consistent Heroicons usage - Replace inline SVGs for password toggle with Eye/EyeOff icons - Fix USE_EMBEDDED mode to serve frontend from filesystem --- backend/cmd/server/frontend.go | 11 +++- backend/cmd/server/main.go | 18 +++--- frontend/bun.lock | 3 + frontend/package.json | 1 + .../routes/domains/[name]/users/+page.svelte | 61 ++++++++----------- 5 files changed, 49 insertions(+), 45 deletions(-) diff --git a/backend/cmd/server/frontend.go b/backend/cmd/server/frontend.go index c524b3c..1574ece 100644 --- a/backend/cmd/server/frontend.go +++ b/backend/cmd/server/frontend.go @@ -4,15 +4,22 @@ import ( "embed" "io/fs" "net/http" + "os" ) //go:embed all:embed var Files embed.FS -func FrontendFileSystem() http.FileSystem { - return http.FS(Files) +func FrontendFileSystem() (http.FileSystem, string) { + if os.Getenv("USE_EMBEDDED") == "false" { + return http.Dir("../frontend/build"), "" + } + return http.FS(Files), "embed/" } func FrontendFS() fs.FS { + if os.Getenv("USE_EMBEDDED") == "false" { + return os.DirFS("../frontend/build") + } return Files } diff --git a/backend/cmd/server/main.go b/backend/cmd/server/main.go index e5323fa..6ff6b10 100644 --- a/backend/cmd/server/main.go +++ b/backend/cmd/server/main.go @@ -120,7 +120,7 @@ func main() { // Get the embedded filesystem containing the frontend. // The frontend is compiled into the binary during build time. - frontendFS := FrontendFileSystem() + frontendFS, frontendPrefix := FrontendFileSystem() // Set Gin mode based on environment. // USE_EMBEDDED=false means development mode (e.g., via air hot-reloader). @@ -142,31 +142,31 @@ func main() { // Set up SPA fallback for non-API routes. // This must be the last route to catch all unmatched paths. engine.NoRoute(func(c *gin.Context) { - path := c.Request.URL.Path + reqPath := c.Request.URL.Path // If it's an API path, return 404. // The API router should have handled /api/* routes. - if strings.HasPrefix(path, "/api/") { + if strings.HasPrefix(reqPath, "/api/") { c.JSON(http.StatusNotFound, gin.H{"error": "not found"}) return } // Serve SvelteKit hashed assets at /_app/* - if strings.HasPrefix(path, "/_app/") { - assetPath := "embed/_app/" + strings.TrimPrefix(path, "/_app/") - serveGinStaticFile(c, frontendFS, assetPath) + if strings.HasPrefix(reqPath, "/_app/") { + filePath := frontendPrefix + "_app/" + strings.TrimPrefix(reqPath, "/_app/") + serveGinStaticFile(c, frontendFS, filePath) return } // Serve favicon - if path == "/favicon.png" { - serveGinStaticFile(c, frontendFS, "embed/favicon.png") + if reqPath == "/favicon.png" { + serveGinStaticFile(c, frontendFS, frontendPrefix+"favicon.png") return } // For all other paths, serve the SPA index.html. // This allows client-side routing (e.g., /domains/example.org). - serveGinStaticFile(c, frontendFS, "embed/index.html") + serveGinStaticFile(c, frontendFS, frontendPrefix+"index.html") }) // Build the address string for binding: "IP:PORT" diff --git a/frontend/bun.lock b/frontend/bun.lock index e8566bf..112a1ad 100644 --- a/frontend/bun.lock +++ b/frontend/bun.lock @@ -14,6 +14,7 @@ "daisyui": "^5.5.19", "postcss": "^8.5.8", "svelte": "^5.0.0", + "svelte-heros": "^8.0.1", "tailwindcss": "^4.2.2", "typescript": "^5.0.0", "vite": "^5.0.0", @@ -289,6 +290,8 @@ "svelte": ["svelte@5.55.0", "", { "dependencies": { "@jridgewell/remapping": "^2.3.4", "@jridgewell/sourcemap-codec": "^1.5.0", "@sveltejs/acorn-typescript": "^1.0.5", "@types/estree": "^1.0.5", "@types/trusted-types": "^2.0.7", "acorn": "^8.12.1", "aria-query": "5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", "devalue": "^5.6.4", "esm-env": "^1.2.1", "esrap": "^2.2.2", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", "zimmerframe": "^1.1.2" } }, "sha512-SThllKq6TRMBwPtat7ASnm/9CDXnIhBR0NPGw0ujn2DVYx9rVwsPZxDaDQcYGdUz/3BYVsCzdq7pZarRQoGvtw=="], + "svelte-heros": ["svelte-heros@8.0.1", "", { "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-67rDThxmdbjvJxKDqDUnkTsmyI5JtXcS0S0Ryg/EmTlHscFyJNgJyEARX5/xt3ONsZA0i6+dWnq+EX5jH9Wq1Q=="], + "tailwindcss": ["tailwindcss@4.2.2", "", {}, "sha512-KWBIxs1Xb6NoLdMVqhbhgwZf2PGBpPEiwOqgI4pFIYbNTfBXiKYyWoTsXgBQ9WFg/OlhnvHaY+AEpW7wSmFo2Q=="], "tapable": ["tapable@2.3.2", "", {}, "sha512-1MOpMXuhGzGL5TTCZFItxCc0AARf1EZFQkGqMm7ERKj8+Hgr5oLvJOVFcC+lRmR8hCe2S3jC4T5D7Vg/d7/fhA=="], diff --git a/frontend/package.json b/frontend/package.json index eed1631..e0f2a6b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,6 +18,7 @@ "daisyui": "^5.5.19", "postcss": "^8.5.8", "svelte": "^5.0.0", + "svelte-heros": "^8.0.1", "tailwindcss": "^4.2.2", "typescript": "^5.0.0", "vite": "^5.0.0" diff --git a/frontend/src/routes/domains/[name]/users/+page.svelte b/frontend/src/routes/domains/[name]/users/+page.svelte index 2352f92..57f2747 100644 --- a/frontend/src/routes/domains/[name]/users/+page.svelte +++ b/frontend/src/routes/domains/[name]/users/+page.svelte @@ -1,5 +1,6 @@