-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(blog): show newsletter form or link below posts (#8920)
- Loading branch information
Showing
6 changed files
with
93 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import React, { useState } from "react"; | ||
import React, { createElement, useState } from "react"; | ||
|
||
import { useIsServer } from "../hooks"; | ||
import { useIsServer, useLocale } from "../hooks"; | ||
import { Button } from "../ui/atoms/button"; | ||
import { MainContentContainer } from "../ui/atoms/page-content"; | ||
import { useUserData } from "../user-context"; | ||
|
||
import "./index.scss"; | ||
|
||
export function Newsletter() { | ||
return ( | ||
<MainContentContainer className="main-newsletter"> | ||
<MainContentContainer className="section-newsletter"> | ||
<SignUpForm /> | ||
</MainContentContainer> | ||
); | ||
} | ||
|
||
function SignUpForm() { | ||
function SignUpForm({ sendUsersToSettings = false, section = false }) { | ||
const isServer = useIsServer(); | ||
const user = useUserData(); | ||
const locale = useLocale(); | ||
const [pending, setPending] = useState(false); | ||
const [error, setError] = useState(false); | ||
const [submitted, setSubmitted] = useState(false); | ||
|
@@ -44,7 +47,7 @@ function SignUpForm() { | |
|
||
return submitted ? ( | ||
<> | ||
<h1>Thanks!</h1> | ||
{createElement(section ? "h2" : "h1", null, "Thanks!")} | ||
<p> | ||
If you haven't previously confirmed a subscription to a Mozilla-related | ||
newsletter, you may have to do so. Please check your inbox or your spam | ||
|
@@ -53,53 +56,70 @@ function SignUpForm() { | |
</> | ||
) : ( | ||
<> | ||
<h1>Stay Informed with MDN</h1> | ||
{createElement(section ? "h2" : "h1", null, "Stay Informed with MDN")} | ||
<p> | ||
Get the MDN newsletter and never miss an update on the latest web | ||
development trends, tips, and best practices. | ||
</p> | ||
<form className="mdn-form mdn-form-big" onSubmit={submit}> | ||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_email">Your email address:</label> | ||
{sendUsersToSettings && user?.isAuthenticated ? ( | ||
<p> | ||
Sign up via the{" "} | ||
<a href={`/${locale}/plus/settings#newsletter`} rel="_blank"> | ||
Settings Page. | ||
</a> | ||
</p> | ||
) : ( | ||
<form className="mdn-form mdn-form-big" onSubmit={submit}> | ||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_email">Your email address:</label> | ||
|
||
<input | ||
type="email" | ||
name="email" | ||
required={true} | ||
placeholder="[email protected]" | ||
id="newsletter_email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
disabled={pending} | ||
/> | ||
</div> | ||
|
||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_privacy"> | ||
<input | ||
type="checkbox" | ||
id="newsletter_privacy" | ||
name="privacy" | ||
type="email" | ||
name="email" | ||
required={true} | ||
placeholder="[email protected]" | ||
id="newsletter_email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
disabled={pending} | ||
/>{" "} | ||
I’m okay with Mozilla handling my info as explained in this{" "} | ||
<a | ||
href="https://www.mozilla.org/en-US/privacy/websites/" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Privacy Notice | ||
</a> | ||
</label> | ||
</div> | ||
/> | ||
</div> | ||
|
||
<div className="mdn-form-item"> | ||
<label htmlFor="newsletter_privacy"> | ||
<input | ||
type="checkbox" | ||
id="newsletter_privacy" | ||
name="privacy" | ||
required={true} | ||
disabled={pending} | ||
/>{" "} | ||
I’m okay with Mozilla handling my info as explained in this{" "} | ||
<a | ||
href="https://www.mozilla.org/en-US/privacy/websites/" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Privacy Notice | ||
</a> | ||
</label> | ||
</div> | ||
|
||
<div className="mdn-form-item"> | ||
<Button buttonType="submit" isDisabled={pending || isServer}> | ||
{error ? "Something went wrong, try again" : "Sign Up Now"} | ||
</Button> | ||
</div> | ||
</form> | ||
<div className="mdn-form-item"> | ||
<Button buttonType="submit" isDisabled={pending || isServer}> | ||
{error ? "Something went wrong, try again" : "Sign Up Now"} | ||
</Button> | ||
</div> | ||
</form> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export function SignUpSection() { | ||
return ( | ||
<section className="section-newsletter"> | ||
<SignUpForm sendUsersToSettings={true} section={true} /> | ||
</section> | ||
); | ||
} |
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