Implement hybrid CSS architecture to fix white-on-white modal issue on sites with CSS resets

- Migrate from inline CSS to external insertr.css with cascade layer architecture
- Add CSS CDN serving capability (ServeInsertrCSS handler and /insertr.css route)
- Implement hybrid approach: @layer insertr for modern browsers + html body selectors for legacy browsers
- Remove scattered inline CSS from JavaScript modules for better maintainability
- Solve form element spacing conflicts with aggressive site CSS resets like '* {margin:0; padding:0}'
- Enable proper CSS caching and separation of concerns
This commit is contained in:
2025-09-17 14:39:34 +02:00
parent cd202ebb1d
commit 1bf597266e
11 changed files with 785 additions and 694 deletions

View File

@@ -731,3 +731,30 @@ func (h *ContentHandler) ServeInsertrJS(w http.ResponseWriter, r *http.Request)
// Copy file contents to response
io.Copy(w, file)
}
// ServeInsertrCSS handles GET /insertr.css - serves the insertr CSS stylesheet
func (h *ContentHandler) ServeInsertrCSS(w http.ResponseWriter, r *http.Request) {
// Path to the built insertr.css file
cssPath := "lib/dist/insertr.css"
// Check if file exists
if _, err := os.Stat(cssPath); os.IsNotExist(err) {
http.Error(w, "insertr.css not found - run 'just build-lib' to build the library", http.StatusNotFound)
return
}
// Open and serve the file
file, err := os.Open(cssPath)
if err != nil {
http.Error(w, fmt.Sprintf("Failed to open insertr.css: %v", err), http.StatusInternalServerError)
return
}
defer file.Close()
// Set appropriate headers
w.Header().Set("Content-Type", "text/css")
w.Header().Set("Cache-Control", "no-cache") // For development
// Copy file contents to response
io.Copy(w, file)
}