diff --git a/src/core/client/stream/components/Comment/Comment.spec.tsx b/src/core/client/stream/components/Comment/Comment.spec.tsx index a6183e7ac..8b409adeb 100644 --- a/src/core/client/stream/components/Comment/Comment.spec.tsx +++ b/src/core/client/stream/components/Comment/Comment.spec.tsx @@ -7,7 +7,7 @@ import Comment from "./Comment"; it("renders username and body", () => { const props: PropTypesOf = { - id: "comment-ID", + id: "comment-id", author: { username: "Marvin", }, diff --git a/src/core/client/stream/components/Comment/Comment.tsx b/src/core/client/stream/components/Comment/Comment.tsx index a3f763c08..0765a2a79 100644 --- a/src/core/client/stream/components/Comment/Comment.tsx +++ b/src/core/client/stream/components/Comment/Comment.tsx @@ -1,6 +1,7 @@ +import { Localized } from "fluent-react/compat"; import React from "react"; import { StatelessComponent } from "react"; -import { Typography } from "talk-ui/components"; +import { Popover, Typography } from "talk-ui/components"; import PermalinkPopover from "../PermalinkPopover"; import Timestamp from "./Timestamp"; import TopBar from "./TopBar"; @@ -25,7 +26,15 @@ const Comment: StatelessComponent = props => { {props.body}
- + }> + {({ toggleShow }) => ( + + )} +
); diff --git a/src/core/client/stream/components/PermalinkPopover.tsx b/src/core/client/stream/components/PermalinkPopover.tsx index 0f7e19ba7..85e3bdd06 100644 --- a/src/core/client/stream/components/PermalinkPopover.tsx +++ b/src/core/client/stream/components/PermalinkPopover.tsx @@ -1,22 +1,22 @@ -import { Localized as L } from "fluent-react/compat"; -import React from "react"; +import { Localized } from "fluent-react/compat"; +import React, { CSSProperties } from "react"; import CopyToClipboard from "react-copy-to-clipboard"; -import { Button, Popover, TextField } from "talk-ui/components"; +import { Button, TextField } from "talk-ui/components"; import * as styles from "./PermalinkPopover.css"; interface InnerProps { commentId: string; + ref?: any; + style?: CSSProperties; } interface State { copied: boolean; - showBody: boolean; } class PermalinkPopover extends React.Component { public state: State = { copied: false, - showBody: false, }; public onCopy = async () => { @@ -26,14 +26,6 @@ class PermalinkPopover extends React.Component { }, 800); }; - public onClick = () => this.toggleShow(); - - public toggleShow = () => { - this.setState((state: State) => ({ - showBody: !state.showBody, - })); - }; - public toggleCopied = () => { this.setState((state: State) => ({ copied: !state.copied, @@ -41,40 +33,27 @@ class PermalinkPopover extends React.Component { }; public render() { - const { commentId } = this.props; - const { copied, showBody } = this.state; + const { commentId, ref, style } = this.props; + const { copied } = this.state; + + console.log(this.props, "props"); return ( - - - - - - - ) : null - } - > - - +
+ + + + +
); } } diff --git a/src/core/client/ui/components/Attachment/Attachment.tsx b/src/core/client/ui/components/Attachment/Attachment.tsx index 19dbdb2b6..5af459729 100644 --- a/src/core/client/ui/components/Attachment/Attachment.tsx +++ b/src/core/client/ui/components/Attachment/Attachment.tsx @@ -25,13 +25,17 @@ interface InnerProps { | "left-start"; } +interface Props { + ref: any; +} + class Attachment extends React.Component { public render() { const { children, body, placement = "top", className } = this.props; return ( - {({ ref }) => React.cloneElement(children, { ref })} + {(props: Props) => React.cloneElement(children, { ref: props.ref })} void; +} + interface InnerProps { - body: React.ReactElement | null; - children: React.ReactElement; + body: React.ReactElement | null; + children: (props: RenderProps) => React.ReactElement; +} + +interface Props { + ref: any; +} + +interface State { + show: false; } class Popover extends React.Component { + public state: State = { + show: false, + }; + + public toggleShow = () => { + this.setState((state: State) => ({ + show: !state.show, + })); + }; + public render() { - const { body, children: reference } = this.props; + const { body, children } = this.props; + // const { show } = this.state; + console.log(children); return ( - {reference} + {({ ref }) => children({ toggleShow: this.toggleShow, ref })} ); } diff --git a/src/core/client/ui/hocs/withForwardRef.tsx b/src/core/client/ui/hocs/withForwardRef.tsx index e3eb9fe10..6b48b928b 100644 --- a/src/core/client/ui/hocs/withForwardRef.tsx +++ b/src/core/client/ui/hocs/withForwardRef.tsx @@ -9,14 +9,12 @@ import { * the `React.forwardRef` api. */ function withForwardRef(): InferableComponentEnhancerWithProps< - { forwardRef: any }, + { forwardRef: Ref }, {} > { return WrappedComponent => { return React.forwardRef((props, ref) => ( - ref as button={ref} className="FancyButton"> - {props.children} - + )); }; }