Skip to content

Commit d54e1aa

Browse files
committed
Use the shared subscribe form on the homepage
The homepage form sent only the email and the tag to Mailcoach, so subscribers landed on the Mailcoach result pages. It now uses the SubscribeForm component with a dark variant. It redirects to the bref.sh result pages and has the honeypot field. Claude-Session: https://claude.ai/code/session_015w3NerK2Ejb5Z73hKotBoQ
1 parent d1cfa59 commit d54e1aa

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

website/src/components/home/case-studies.jsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import SubscribeForm from '../news/SubscribeForm';
2+
13
const posts = [
24
{
35
id: 2,
@@ -38,20 +40,7 @@ export default function CaseStudies() {
3840
Support & consulting <span aria-hidden="true">&rarr;</span>
3941
</a>
4042
</div>
41-
<form action="https://bref.mailcoach.app/subscribe/be83c960-8fee-43fa-abfa-29669e9f433a"
42-
className="w-full flex flex-col items-start mt-8"
43-
method="post">
44-
<input type="hidden" name="tags" value="bref_website" />
45-
<div className="flex flex-col sm:flex-row w-full sm:w-auto gap-2">
46-
<input
47-
className="min-w-0 flex-auto rounded-md border-0 bg-white/10 px-3.5 py-2 text-white shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-white/75 focus:ring-2 focus:ring-inset focus:ring-white sm:text-sm sm:leading-6"
48-
name="email" aria-label="Email" placeholder="you@example.com" required type="email" />
49-
<button type="submit"
50-
className="flex-none rounded-md !bg-gray-500 hover:!bg-gray-400 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500">
51-
Subscribe to the newsletter
52-
</button>
53-
</div>
54-
</form>
43+
<SubscribeForm tag="bref_website" onDark className="mt-8 sm:w-fit" />
5544
</div>
5645
<div className="mx-auto w-full border-t border-gray-900/10 pt-12 sm:pt-16 lg:mx-0 lg:max-w-none lg:border-t-0 lg:pt-0 text-gray-300">
5746
<div className="-my-4 divide-y divide-gray-900/10">

website/src/components/news/SubscribeForm.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@ const MAILCOACH_SUBSCRIBE_URL = 'https://bref.mailcoach.app/subscribe/be83c960-8
1212
// - `tag`: Mailcoach subscriber tag, to measure where subscribers come from.
1313
// - `label`: visible label above the field. Without it the form is a single row
1414
// (placeholder + button).
15+
// - `onDark`: styles for a dark background (the homepage section), instead of
16+
// following the site theme.
1517
// - The migration email links to /news/subscribe?email=... : the address is
1618
// prefilled but nothing is submitted until the reader clicks the button, so
1719
// email prefetchers (which only GET the link) cannot subscribe anyone.
1820
// - Mailcoach sends its double opt-in email and redirects to the bref.sh
1921
// result pages below.
20-
export default function SubscribeForm({ tag, label, className = 'my-8' }) {
22+
const INPUT_CLASS = {
23+
light: 'text-gray-900 ring-gray-300 placeholder:text-gray-400 focus:ring-blue-500 dark:bg-white/5 dark:text-white dark:ring-white/10 dark:placeholder:text-white/50',
24+
dark: 'bg-white/10 text-white ring-white/10 placeholder:text-white/75 focus:ring-white',
25+
}
26+
const BUTTON_CLASS = {
27+
light: 'bg-blue-500 hover:bg-blue-400',
28+
dark: '!bg-gray-500 hover:!bg-gray-400',
29+
}
30+
31+
export default function SubscribeForm({ tag, label, onDark = false, className = 'my-8' }) {
32+
const variant = onDark ? 'dark' : 'light'
2133
const emailRef = useRef(null)
2234
const honeypotRef = useRef(null)
2335

@@ -66,11 +78,11 @@ export default function SubscribeForm({ tag, label, className = 'my-8' }) {
6678
autoComplete="email"
6779
aria-label={label ? undefined : 'Email'}
6880
placeholder="you@example.com"
69-
className="min-w-0 flex-auto rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-500 sm:text-sm sm:leading-6 dark:bg-white/5 dark:text-white dark:ring-white/10 dark:placeholder:text-white/50"
81+
className={`min-w-0 flex-auto rounded-md border-0 px-3.5 py-2 shadow-sm ring-1 ring-inset focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6 ${INPUT_CLASS[variant]}`}
7082
/>
7183
<button
7284
type="submit"
73-
className="flex-none rounded-md bg-blue-500 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500"
85+
className={`flex-none rounded-md px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 ${BUTTON_CLASS[variant]}`}
7486
>
7587
Subscribe to the Bref newsletter
7688
</button>

0 commit comments

Comments
 (0)