diff --git a/components/index.html b/components/index.html
index b93bd0d..e22a826 100644
--- a/components/index.html
+++ b/components/index.html
@@ -50,7 +50,7 @@
{{range $word, $color := .}}
+ cursor: pointer;
+ " hx-get="/show-color?word={{$word}}" hx-trigger="click" hx-swap="outerHTML">
{{$word}}
{{end}}
diff --git a/handlers/handlers.go b/handlers/handlers.go
index b6053d7..609984f 100644
--- a/handlers/handlers.go
+++ b/handlers/handlers.go
@@ -36,6 +36,29 @@ func HandlePing(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("pong"))
}
+func HandleShowColor(w http.ResponseWriter, r *http.Request) {
+ word := r.URL.Query().Get("word")
+ color, exists := roundWords[word]
+ if !exists {
+ http.Error(w, "word not found", http.StatusNotFound)
+ return
+ }
+
+ w.Header().Set("Content-Type", "text/html")
+ w.Write([]byte(
+ fmt.Sprintf(`
%s
`, color, word)))
+}
+
func HandleHome(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.ParseGlob("components/*.html")
if err != nil {