-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs/learn): add user research survey banner (#9405)
https://mozilla-hub.atlassian.net/browse/MP-538 prevent images being inlined, our csp doesn't support it
- Loading branch information
Showing
5 changed files
with
99 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.user-research-banner { | ||
--icon-primary: #696969; | ||
background: #e6deff; | ||
border-radius: 0.5rem; | ||
color: #1b1b1b; | ||
margin-bottom: 2rem; | ||
padding: 1rem; | ||
padding-left: 5.5rem; | ||
padding-right: 3rem; | ||
position: relative; | ||
|
||
&::before { | ||
background-image: url("../../../assets/icons/user-research.png"); | ||
background-position: center center; | ||
background-repeat: no-repeat; | ||
background-size: contain; | ||
content: ""; | ||
display: block; | ||
height: 3.5rem; | ||
left: 1rem; | ||
position: absolute; | ||
width: 3.5rem; | ||
} | ||
|
||
.dismiss { | ||
position: absolute; | ||
right: 1rem; | ||
top: 1rem; | ||
|
||
button { | ||
cursor: pointer; | ||
} | ||
|
||
.icon { | ||
margin-top: -0.25rem; | ||
} | ||
} | ||
|
||
a { | ||
color: #6800cf !important; | ||
|
||
&.external::after { | ||
display: none; | ||
} | ||
} | ||
} |
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,50 @@ | ||
import { useEffect, useState } from "react"; | ||
import { Doc } from "../../../../../libs/types/document"; | ||
import { Icon } from "../../atoms/icon"; | ||
|
||
import "./index.scss"; | ||
|
||
const LOCAL_STORAGE_KEY = "user_research.2023_07.hidden"; | ||
|
||
export function UserResearchSurvey({ doc }: { doc: Doc }) { | ||
const [hidden, setHidden] = useState(true); | ||
|
||
useEffect(() => { | ||
if (/en-US\/docs\/Learn(\/|$)/i.test(doc.mdn_url)) { | ||
setHidden( | ||
Boolean(JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY) || "false")) | ||
); | ||
} | ||
}, [doc.mdn_url]); | ||
|
||
const dismiss = () => { | ||
setHidden(true); | ||
localStorage.setItem(LOCAL_STORAGE_KEY, "true"); | ||
}; | ||
|
||
return hidden ? null : ( | ||
<div className="user-research-banner"> | ||
We want to hear from you! Help guide development on MDN and participate in | ||
our{" "} | ||
<a | ||
href="https://survey.alchemer.com/s3/7444036/MDN-User-Research" | ||
className="external" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
user research survey | ||
</a> | ||
. | ||
<div className="dismiss"> | ||
<button | ||
type="button" | ||
aria-label={"Hide this survey"} | ||
onClick={() => dismiss()} | ||
title={"Hide this survey"} | ||
> | ||
<Icon name={"cancel"} /> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} |