Skip to content

Commit 65a5b56

Browse files
committed
Add Newsletter component
1 parent 6f6fc7a commit 65a5b56

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

src/components/home/Newsletter.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import React from 'react'
2+
import { useForm, ValidationError } from '@formspree/react'
3+
import { BigText, IconContainer, Paragraph, Widont } from '@/components/home/common'
4+
import { ReactComponent as Icon } from '@/img/icons/home/newsletter.svg'
5+
import { gradients } from '@/utils/gradients'
6+
7+
export function Newsletter() {
8+
const [state, handleSubmit] = useForm('moqyyjvo', {
9+
data: {
10+
_subject: 'Someone joined the newsletter',
11+
pageTitle: function () {
12+
// This function will be evaluated at submission time
13+
return document.title
14+
},
15+
},
16+
})
17+
if (state.succeeded) {
18+
return (
19+
<div class="p-5 m-5 flex flex-wrap font-semibold hover:shadow-lg rounded-lg border border-green-400 bg-green-300 text-green-900 ">
20+
<span class="mr-2">
21+
<svg
22+
xmlns="http://www.w3.org/2000/svg"
23+
class="h-6 w-6"
24+
fill="none"
25+
viewBox="0 0 24 24"
26+
stroke="currentColor"
27+
>
28+
<path
29+
stroke-linecap="round"
30+
stroke-linejoin="round"
31+
stroke-width="2"
32+
d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5"
33+
/>
34+
</svg>
35+
</span>
36+
Congratulations!
37+
<p className="font-normal pl-2">You have successfully subscribed to our newsletter.</p>
38+
</div>
39+
)
40+
}
41+
return (
42+
<section id="newsletter">
43+
<div className="px-4 sm:px-6 md:px-8 mb-10 sm:mb-16 md:mb-20">
44+
<IconContainer className={`${gradients.blue[0]} mb-8`}>
45+
<Icon />
46+
</IconContainer>
47+
<BigText className="mb-8">
48+
<Widont>Want product news and updates?</Widont>
49+
</BigText>
50+
<Paragraph className="mb-6">Sign Up for our weekly newsletter.</Paragraph>
51+
</div>
52+
<div className="max-w-xl mx-auto">
53+
<form onSubmit={handleSubmit} class="mt-2">
54+
<div className="flex flex-center flex-wrap p-5 space-y-4 sm:space-y-4 sm:space-x-0 text-center mt-12">
55+
<input
56+
id="email"
57+
type="email"
58+
name="email"
59+
className="flex-none w-full px-4 py-4 font-medium text-lg bg-gray-100 hover:shadow-lg rounded-lg border border-gray-400 focus:outline-none"
60+
placeholder="Enter your email"
61+
required
62+
/>
63+
<ValidationError
64+
prefix="Email"
65+
field="email"
66+
errors={state.errors}
67+
className="p-5 rounded-lg w-full flex-none hover:shadow-lg font-semibold border border-red-400 bg-red-300 text-red-900"
68+
/>
69+
<button
70+
type="submit"
71+
disabled={state.submitting}
72+
className="w-full px-6 py-4 sm:w-auto flex-none bg-blue-700 hover:bg-blue-600 text-white text-lg shadow-md hover:shadow-lg leading-6 font-semibold border border-transparent rounded-lg focus:ring-2 focus:ring-offset-2 focus:ring-offset-white focus:ring-blue-600 focus:outline-none transition-colors duration-200"
73+
>
74+
Sign Up
75+
</button>
76+
<p className="pt-2 text-base flex-center">
77+
We care about the protection of your data. Read our{' '}
78+
<a className="text-blue-500 font-medium underline" href="/">
79+
Privacy Policy
80+
</a>
81+
</p>
82+
</div>
83+
</form>
84+
</div>
85+
</section>
86+
)
87+
}

src/img/icons/home/newsletter.svg

Lines changed: 1 addition & 0 deletions
Loading

src/pages/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BigText, InlineCode, Paragraph, Widont } from '@/components/home/common'
22
import { Footer } from '@/components/home/Footer'
33
import { Hero } from '@/components/home/Hero'
4+
import { Newsletter } from '@/components/home/Newsletter'
45
import { Logo } from '@/components/Logo'
56
import { Search } from '@/components/Search'
67
import { Testimonials } from '@/components/Testimonials'
@@ -138,6 +139,9 @@ export default function Home() {
138139
</div>
139140
</section>
140141
<Testimonials />
142+
<div className="max-w-screen-lg xl:max-w-screen-xl mx-auto space-y-20 sm:space-y-32 md:space-y-40 lg:space-y-44">
143+
<Newsletter />
144+
</div>
141145
<Footer />
142146
</div>
143147
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy