@@ -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