portfolio/components/Subscribe.tsx

37 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-02-05 21:52:03 +00:00
import {useRef, SyntheticEvent, MutableRefObject, useState} from 'react'
import {Cta} from '@/components/Cta'
2023-02-04 22:32:01 +00:00
import {MailIcon} from '@/components/icons/MailIcon'
import {Button} from '@/components/Button'
export function Subscribe() {
2023-02-05 21:52:03 +00:00
const inputRef = useRef() as MutableRefObject<HTMLInputElement>
const [message, setMessage] = useState('')
const subscribe = async (e: SyntheticEvent) => {
e.preventDefault()
inputRef.current.value = ''
}
2023-02-04 22:32:01 +00:00
return (
2023-02-05 21:52:03 +00:00
<Cta icon={MailIcon} title="Subscribe">
2023-02-04 22:32:01 +00:00
<p className="mt-2 text-sm text-zinc-600 dark:text-zinc-400">
Get notified when I publish something new, and unsubscribe at any time.
</p>
2023-02-05 21:52:03 +00:00
{/*<p className="mt-2 text-sm text-green-500">Success! 🎉 You are now subscribed to the newsletter.</p>*/}
<form className="mt-6 flex" onSubmit={subscribe}>
2023-02-04 22:32:01 +00:00
<input
type="email"
placeholder="Email address"
aria-label="Email address"
required
className="min-w-0 flex-auto appearance-none rounded-md border border-zinc-900/10 bg-white px-3 py-[calc(theme(spacing.2)-1px)] shadow-md shadow-zinc-800/5 placeholder:text-zinc-400 focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 dark:border-zinc-700 dark:bg-zinc-700/[0.15] dark:text-zinc-200 dark:placeholder:text-zinc-500 dark:focus:border-indigo-400 dark:focus:ring-indigo-400/10 sm:text-sm"
2023-02-05 21:52:03 +00:00
ref={inputRef}
2023-02-04 22:32:01 +00:00
/>
<Button className="ml-4 flex-none" variant="secondary">
Join
</Button>
2023-02-05 21:52:03 +00:00
</form>
</Cta>
2023-02-04 22:32:01 +00:00
)
}