-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(home): design, copy tweaks + subscribe section (#20)
* fix(ticker): simplify + correct values * fixup * fix(home): design, copy tweaks + subscribe section * fixup * review requests
- Loading branch information
Showing
22 changed files
with
213 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const MAILCHIMP_API_KEY = process.env.MAILCHIMP_API_KEY; | ||
export const MAILCHIMP_API_SERVER = process.env.MAILCHIMP_API_SERVER; | ||
export const MAILCHIMP_AUDIENCE_ID = process.env.MAILCHIMP_AUDIENCE_ID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { z } from "zod"; | ||
|
||
import { | ||
MAILCHIMP_API_KEY, | ||
MAILCHIMP_API_SERVER, | ||
MAILCHIMP_AUDIENCE_ID, | ||
} from "./_constants"; | ||
|
||
export async function POST(request: Request) { | ||
const body = await request.json(); | ||
const email = body.email; | ||
|
||
const parsedEmail = z.string().email().safeParse(email); | ||
|
||
if (!parsedEmail.success) { | ||
return new Response("Invalid email address", { | ||
status: 400, | ||
}); | ||
} | ||
|
||
const response = await fetch( | ||
`https://${MAILCHIMP_API_SERVER}.api.mailchimp.com/3.0/lists/${MAILCHIMP_AUDIENCE_ID}/members`, | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `api_key ${MAILCHIMP_API_KEY}`, | ||
}, | ||
body: JSON.stringify({ | ||
email_address: parsedEmail.data, | ||
status: "subscribed", | ||
}), | ||
}, | ||
); | ||
|
||
if (response.status == 200) { | ||
return new Response("Successfully subscribed", { | ||
status: 201, | ||
}); | ||
} | ||
|
||
return new Response("Something went wrong", { | ||
status: 500, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { SVGProps } from "react"; | ||
|
||
export function DiscourseIcon(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg | ||
width="16" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path | ||
d="M8.23157 0C6.88664 0.000794599 5.56497 0.351143 4.39592 1.01675C3.22687 1.68236 2.25051 2.64041 1.56241 3.79714C0.874316 4.95386 0.498064 6.26961 0.470487 7.61559C0.44291 8.96157 0.764952 10.2917 1.40509 11.4756L0 16L5.04555 14.8591C6.10135 15.3352 7.25017 15.569 8.40789 15.5432C9.56561 15.5174 10.7029 15.2327 11.7365 14.71C12.7701 14.1874 13.6738 13.4399 14.3815 12.5223C15.0891 11.6048 15.5828 10.5405 15.8263 9.40722C16.0699 8.274 16.0571 7.10059 15.789 5.97293C15.5209 4.84528 15.0042 3.79193 14.2768 2.89002C13.5493 1.98812 12.6296 1.2605 11.5849 0.760442C10.5402 0.260388 9.39694 0.000565225 8.23894 0H8.23157Z" | ||
fill="white" | ||
/> | ||
</svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
|
||
import { Text } from "./text"; | ||
|
||
export function SubscribeSection() { | ||
const [email, setEmail] = useState(""); | ||
const [status, setStatus] = useState<"idle" | "loading" | "success" | "error">("idle"); | ||
const [responseMsg, setResponseMsg] = useState(""); | ||
|
||
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) { | ||
event.preventDefault(); | ||
setStatus("loading"); | ||
|
||
try { | ||
const response = await fetch("/across-newsletter", { | ||
method: "POST", | ||
body: JSON.stringify({ email }), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
setResponseMsg(await response.text()); | ||
|
||
if (response.ok) { | ||
setStatus("success"); | ||
} else { | ||
setStatus("error"); | ||
} | ||
} catch { | ||
setStatus("error"); | ||
} | ||
} | ||
|
||
return ( | ||
<section className="mb-24 flex flex-col items-center gap-6"> | ||
<Text variant="heading-2" className="capitalize text-light-100"> | ||
Stay up to date | ||
</Text> | ||
<Text variant="body-nums" className="text-light-300"> | ||
Sign up for our Newsletter | ||
</Text> | ||
<form className="flex flex-row gap-3" onSubmit={handleSubmit}> | ||
<input | ||
type="email" | ||
placeholder="your email" | ||
className="text-medium h-10 rounded-full border border-grey-500 bg-transparent px-6 text-xs uppercase lining-nums tabular-nums tracking-wide-4 focus:outline-none focus:ring-light-100 sm:w-[280px] sm:text-sm" | ||
onChange={(event) => setEmail(event.target.value)} | ||
value={email} | ||
/> | ||
<button | ||
type="submit" | ||
className="h-10 w-[112px] rounded-full bg-aqua-100/[.05] px-6 text-aqua-100 shadow hover:opacity-75" | ||
disabled={status === "loading"} | ||
> | ||
<Text variant="cap-case-sm">Sign up</Text> | ||
</button> | ||
</form> | ||
<div> | ||
{status === "success" ? <p className="text-aqua-100">{responseMsg}</p> : null} | ||
{status === "error" ? <p className="text-orange-100">{responseMsg}</p> : null} | ||
</div> | ||
</section> | ||
); | ||
} |
Oops, something went wrong.