Skip to content

Commit 6fc00b0

Browse files
committed
fix(waitlist): improve signup form ergonomics
1 parent c2a2758 commit 6fc00b0

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

src/main/parts/handlers/pages.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
[:p
3939
[:strong "Parts"]
4040
" is being actively developed, and we would love to have your feedback! Please enter your email below to join the private beta test."]
41-
(partials/waitlist-signup-form ".signup")]]]]
41+
(partials/waitlist-signup-form)]]]]
4242
[:section.aboutus.container
4343
[:div.content
4444
[:h3

src/main/parts/handlers/waitlist.clj

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,21 @@
1212
[email]
1313
(re-matches #".+@.+\..+" email))
1414

15-
(defn- form-with-message
16-
"Re-render signup form with a message"
17-
[message]
18-
(html [:p "Please enter your email below to join the private beta test."]
19-
(partials/waitlist-signup-form ".signup")
20-
[:div.error
21-
[:p message]]))
22-
2315
(defn signup
2416
"Register email address in private beta waitlist"
2517
[request]
2618
(let [email (get-in request [:form-params "email"])]
2719
(cond
2820
(or (nil? email) (str/blank? email))
2921
(-> (response/response
30-
(form-with-message "Please don't forget your email address!"))
22+
(html
23+
(partials/waitlist-signup-form "Please don't forget your email address!")))
3124
(response/status 200))
3225

3326
(not (valid-email? email))
3427
(-> (response/response
35-
(form-with-message "Sorry, that's not a valid email address."))
28+
(html
29+
(partials/waitlist-signup-form "Sorry, that's not a valid email address.")))
3630
(response/status 200))
3731

3832
:else

src/main/parts/views/partials.clj

+21-16
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,24 @@
7474

7575
(defn waitlist-signup-form
7676
"Form for signing up for the waiting list"
77-
[target]
78-
[:div#signup-form
79-
[:form {:hx-post "/waitlist-signup"
80-
:hx-target target
81-
:hx-swap "innerHTML"
82-
:hx-on:submit "plausible('Waitlist Signup'); return true;"}
83-
[:input {:type "email"
84-
:id "email"
85-
:name "email"
86-
:placeholder "[email protected]"
87-
:hx-on:focus "plausible('Email Field Focus'); return true;"}]
88-
[:input {:type "hidden"
89-
:id "__anti-forgery-token"
90-
:name "__anti-forgery-token"
91-
:value *anti-forgery-token*}]
92-
[:input {:type "submit" :value "Sign me up!"}]]])
77+
([]
78+
(waitlist-signup-form nil))
79+
([message]
80+
[:div#signup-form
81+
[:form {:hx-post "/waitlist-signup"
82+
:hx-target "#signup-form"
83+
:hx-swap "outerHTML"
84+
:hx-on:submit "plausible('Waitlist Signup'); return true;"}
85+
[:input {:type "email"
86+
:id "email"
87+
:name "email"
88+
:placeholder "[email protected]"
89+
:hx-on:focus "plausible('Email Field Focus'); return true;"}]
90+
[:input {:type "hidden"
91+
:id "__anti-forgery-token"
92+
:name "__anti-forgery-token"
93+
:value *anti-forgery-token*}]
94+
[:input {:type "submit" :value "Sign me up!"}]]
95+
(when message
96+
[:div.error
97+
[:p message]])]))

0 commit comments

Comments
 (0)