diff --git a/src/core/client/stream/components/PermalinkPopover.tsx b/src/core/client/stream/components/PermalinkPopover.tsx index 7d9bf8ade..776edbccf 100644 --- a/src/core/client/stream/components/PermalinkPopover.tsx +++ b/src/core/client/stream/components/PermalinkPopover.tsx @@ -7,21 +7,56 @@ interface InnerProps { commentId: string; } +interface State { + copied: boolean; + showBody: boolean; +} + class PermalinkPopover extends React.Component { + public state: State = { + copied: false, + showBody: false, + }; + + public onCopy = async () => { + await this.toggleCopied(); + setTimeout(() => { + this.toggleCopied(); + }, 800); + }; + + public onClick = () => this.toggleShow(); + + public toggleShow = () => { + this.setState((state: State) => ({ + showBody: !state.showBody, + })); + }; + + public toggleCopied = () => { + this.setState((state: State) => ({ + copied: !state.copied, + })); + }; + public render() { const { commentId } = this.props; + const { copied, showBody } = this.state; return ( - - + + } > - + ); } diff --git a/src/core/client/ui/components/Popover/Popover.css b/src/core/client/ui/components/Popover/Popover.css index 1a1553256..708964cdb 100644 --- a/src/core/client/ui/components/Popover/Popover.css +++ b/src/core/client/ui/components/Popover/Popover.css @@ -13,7 +13,3 @@ border-top-color: transparent !important; } } - -.clickable { - pointer-events: all; -} diff --git a/src/core/client/ui/components/Popover/Popover.tsx b/src/core/client/ui/components/Popover/Popover.tsx index 8b55931c2..84be78c8f 100644 --- a/src/core/client/ui/components/Popover/Popover.tsx +++ b/src/core/client/ui/components/Popover/Popover.tsx @@ -1,10 +1,11 @@ import React from "react"; import { Manager, Popper, Reference } from "react-popper"; -// import * as styles from "./Popover.css"; +import * as styles from "./Popover.css"; interface InnerProps { body: React.ReactElement; children: React.ReactElement; + showBody: boolean; placement?: | "auto-start" | "auto" @@ -25,25 +26,28 @@ interface InnerProps { class Popover extends React.Component { public render() { - const { children, body, placement = "top" } = this.props; + const { children, body, placement = "top", showBody = true } = this.props; return ( {({ ref }) => React.cloneElement(children, { ref })} - - {({ ref, style }) => - React.cloneElement(body, { - ref, - style, - }) - } - + {showBody && ( + + {({ ref, style }) => + React.cloneElement(body, { + ref, + style, + className: styles.root, + }) + } + + )} ); }