summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/nav/nav.share.js
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/app/views/viewer/nav/nav.share.js')
-rw-r--r--animism-align/frontend/app/views/viewer/nav/nav.share.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/viewer/nav/nav.share.js b/animism-align/frontend/app/views/viewer/nav/nav.share.js
new file mode 100644
index 0000000..1e32860
--- /dev/null
+++ b/animism-align/frontend/app/views/viewer/nav/nav.share.js
@@ -0,0 +1,65 @@
+import React, { Component } from 'react'
+
+import { writeToClipboard } from 'app/utils'
+
+export default class NavShare extends Component {
+ state = {
+ copied: false,
+ }
+ constructor(props){
+ super(props)
+ this.copyToClipboard = this.copyToClipboard.bind(this)
+ }
+ copyToClipboard() {
+ const url = "https://e-flux.com/"
+ writeToClipboard(url).then(() =>{
+ clearTimeout(this.timeout)
+ this.setState({ copying: true, copied: false, })
+ this.timeout = setTimeout(() => {
+ this.setState({ copying: true, copied: true })
+ this.timeout = setTimeout(() => this.setState({ copied: false, copying: false, }), 2200)
+ }, 50)
+ })
+ }
+ render() {
+ const { viewer } = this.props
+ let className = "nav-share"
+ if (this.state.copying) className += " copying"
+ if (this.state.copied) className += " copied"
+ const title = "Animism Episode 1"
+ const url = "https://e-flux.com/"
+ const mailtoURL = (
+ "mailto:?subject=" + encodeURIComponent(title) +
+ "&body=" + encodeURIComponent("I want to share this post on e-flux: " + url + "\n\n\n")
+ )
+ const facebookURL = (
+ "https://www.facebook.com/sharer.php" +
+ "?u=" + encodeURIComponent(url) +
+ "&t=" + encodeURIComponent(title)
+ )
+ const twitterURL = (
+ "https://twitter.com/intent/tweet" +
+ "?url=" + encodeURIComponent(url) +
+ "&text=" + encodeURIComponent(title)
+ )
+ return (
+ <div className={className}>
+ <div className="share-option">
+ <a href={mailtoURL}>Email</a>
+ </div>
+ <div className="share-option">
+ <a href={facebookURL}>Facebook</a>
+ </div>
+ <div className="share-option">
+ <a href={twitterURL}>Twitter</a>
+ </div>
+ <div className="share-option">
+ <div className="share-copy" onClick={this.copyToClipboard}>
+ Copy Link
+ <span className="share-success">success</span>
+ </div>
+ </div>
+ </div>
+ )
+ }
+}