-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added place link and image attribution tag
- Loading branch information
1 parent
48856d2
commit b4e2a30
Showing
7 changed files
with
255 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* To rotate text vertically and align it to the bottom of the page | ||
* we rotate the parent container with a right, bottom origin and | ||
* match the right and height property to make the element be aligned | ||
* with the right edge of the page. | ||
*/ | ||
.image-attribution { | ||
display: inline-block; | ||
position: absolute; | ||
z-index: 10; | ||
|
||
height: 1rem; | ||
right: 1rem; | ||
bottom: 0; | ||
|
||
transform: rotate(90deg); | ||
transform-origin: right bottom; | ||
} | ||
|
||
/** | ||
* The text is rotated, but we need to flip it so that | ||
* it reads from bottom to top. This is really difficult to do with | ||
* transform and origin properties on the parent, so we just flip | ||
* the child content with the scale property | ||
*/ | ||
.image-attribution-link { | ||
transition: opacity 0.3s ease; | ||
|
||
opacity: 0.3; | ||
display: block; | ||
position: relative; | ||
|
||
right: 14px; | ||
top: 10px; | ||
transform: scale(-1, -1); | ||
|
||
color: white; | ||
font-size: 12px; | ||
font-family: "Platform Regular"; | ||
text-transform: uppercase; | ||
letter-spacing: 0.12em; | ||
text-decoration: none; | ||
|
||
&:hover { | ||
opacity: 1; | ||
} | ||
} |
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,65 @@ | ||
import React from "react"; | ||
import { Place } from "Types"; | ||
import { motion } from "framer-motion"; | ||
import { BASE_URL } from "Constants"; | ||
import "./ImageAttribution.scss"; | ||
|
||
type Props = { | ||
attribution: Place["image_attribution"]; | ||
}; | ||
|
||
const getAttributionLink = (attribution: string) => { | ||
const match = /href="(.+)"/.exec(attribution); // Find link | ||
|
||
if (!match) { | ||
return null; | ||
} | ||
|
||
// Get link from firt capturing group. | ||
const [, link] = match; | ||
|
||
// If the link attribute starts with /users/, prefix it with atlas obscura base URL. | ||
if (/^\/users\//.test(link)) { | ||
return BASE_URL + link; | ||
} | ||
|
||
return link; | ||
}; | ||
|
||
const parseAttribution = (attribution: string) => { | ||
const text = attribution.replace(/<.*?>/g, ""); // Remove all HTML tags | ||
|
||
return { | ||
link: getAttributionLink(attribution), | ||
text, | ||
}; | ||
}; | ||
|
||
const ImageAttribution = ({ attribution }: Props) => { | ||
if (!attribution) { | ||
return null; | ||
} | ||
|
||
const data = parseAttribution(attribution); | ||
|
||
return ( | ||
<div className="image-attribution"> | ||
<motion.div | ||
initial={true} | ||
animate={{ | ||
opacity: 1, | ||
}} | ||
transition={{ duration: 0.8 }} | ||
style={{ | ||
opacity: 0, | ||
}} | ||
> | ||
<a className="image-attribution-link" href={data.link || "#"}> | ||
{data.text} | ||
</a> | ||
</motion.div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImageAttribution; |
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 @@ | ||
export { default } from "./ImageAttribution"; |
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,13 +1,20 @@ | ||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", | ||
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", | ||
"Helvetica Neue", sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
monospace; | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
monospace; | ||
} | ||
|
||
.link-unstyled { | ||
text-decoration: none; | ||
color: inherit; | ||
font-size: inherit; | ||
font-family: inherit; | ||
} |