diff --git a/appview/pages/htmx.go b/appview/pages/htmx.go --- a/appview/pages/htmx.go +++ b/appview/pages/htmx.go @@ -4,6 +4,7 @@ "fmt" "html" "net/http" + "strings" ) // Notice performs a hx-oob-swap to replace the content of an element with a message. @@ -23,6 +24,18 @@ w.Header().Set("Content-Type", "text/html") w.WriteHeader(http.StatusOK) w.Write([]byte(markup)) +} + +func (s *Pages) NoticeHTMLWithClears(w http.ResponseWriter, id string, trustedHTML string, clearIDs ...string) { + var b strings.Builder + b.WriteString(fmt.Sprintf(`%s`, id, trustedHTML)) + for _, clearID := range clearIDs { + b.WriteString(fmt.Sprintf(``, clearID)) + } + + w.Header().Set("Content-Type", "text/html") + w.WriteHeader(http.StatusOK) + w.Write([]byte(b.String())) } // HxRefresh is a client-side full refresh of the page. diff --git a/appview/signup/signup.go b/appview/signup/signup.go --- a/appview/signup/signup.go +++ b/appview/signup/signup.go @@ -332,9 +332,9 @@ // if we get here, we've successfully created the account and added the email success = true - s.pages.NoticeHTML(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now + s.pages.NoticeHTMLWithClears(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now login - with %s.tngl.sh.`, username)) + with %s.tngl.sh.`, username), "signup-error") // clean up inflight signup asynchronously go func() {