From c05f49f1cd5683b868c82e453a76aec185bcbe01 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Oct 2020 15:19:17 +0200 Subject: refactor viewer sections list, share, subscribe, subscription form --- .../views/viewer/sections/viewer.sections.share.js | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 animism-align/frontend/app/views/viewer/sections/viewer.sections.share.js (limited to 'animism-align/frontend/app/views/viewer/sections/viewer.sections.share.js') diff --git a/animism-align/frontend/app/views/viewer/sections/viewer.sections.share.js b/animism-align/frontend/app/views/viewer/sections/viewer.sections.share.js new file mode 100644 index 0000000..607d4d5 --- /dev/null +++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.share.js @@ -0,0 +1,71 @@ +import React, { Component } from 'react' + +import actions from 'app/actions' +import { writeToClipboard } from 'app/utils' +import { Arrow } from '../nav/viewer.icons' + +export default class ViewerSectionsShare 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 ( +
+
+ Email +
+
+ Facebook +
+
+ Twitter +
+
+
+ Copy Link + success +
+
+
actions.viewer.hideComponent('share')}> + + {'Share'} +
+
+ ) + } +} -- cgit v1.2.3-70-g09d2