From bf1a13dee1858f2ff17bac8bf80fd870b88e29d9 Mon Sep 17 00:00:00 2001 From: aysenur-jf <54525698+aysenur-jf@users.noreply.github.com> Date: Tue, 19 May 2020 20:56:18 +0300 Subject: [PATCH] App :: Add tooltip for copy to clipboard button --- src/App.js | 24 +++++++++++++++++------- src/index.css | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index d8e504b..121ab70 100644 --- a/src/App.js +++ b/src/App.js @@ -85,6 +85,7 @@ class App extends Component { this.state = { ready: false, darkMode: false, + copied: false, sidebar: true, codeView: false, view: 'desktop', @@ -111,7 +112,7 @@ class App extends Component { } handleContentDidMount() { - setTimeout(() => { + setTimeout(() => { this.setState({ ready: true, markup: this.markupRef.current.innerHTML @@ -211,10 +212,16 @@ class App extends Component { input.select(); document.execCommand('copy'); document.body.removeChild(input); + this.setState({copied: true}); + setTimeout(() => { + this.setState({ + copied: false + }) + }, 2000); } render() { - const { darkMode, theme, blockName, blockType, sidebar, view } = this.state; + const { darkMode, theme, blockName, blockType, sidebar, view, copied } = this.state; return (