From 3158872f1e90bb293eab4a09aab14316d599ef67 Mon Sep 17 00:00:00 2001 From: notnull Date: Sat, 23 Mar 2019 18:28:33 -0400 Subject: [PATCH] added popup --- src/components/captions/CaptionList.js | 6 +- src/components/captions/Captions.js | 98 ++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 15 deletions(-) diff --git a/src/components/captions/CaptionList.js b/src/components/captions/CaptionList.js index eb0cad7..bbe51d8 100644 --- a/src/components/captions/CaptionList.js +++ b/src/components/captions/CaptionList.js @@ -1,16 +1,18 @@ import React from 'react' const CaptionList = props => { - const { captions } = props + const {togglePopup, captions} = props return ( {Object.keys(captions).map(key => { return captions[key].map(caption => { return ( + onClick={() => { + togglePopup({ nick: caption.nick, text: caption.text }) console.log({ nick: caption.nick, text: caption.text }) } + } > {caption.nick} {caption.text} diff --git a/src/components/captions/Captions.js b/src/components/captions/Captions.js index a601356..12e0311 100644 --- a/src/components/captions/Captions.js +++ b/src/components/captions/Captions.js @@ -2,24 +2,94 @@ import React from 'react' import CaptionList from './CaptionList' import Table from 'react-bootstrap/Table' import {connect} from 'react-redux' -const Captions = props => { +import {Card, Form, Row, Col, Button} from 'react-bootstrap' - const captions = props.captions.all.find(captionSet=>captionSet.slug===props.match.params.slug) - - if(!captions) return
No show with that id.
+// const Popup = props => { +// return ( +// +// +// +// Edit Comment +// {props.text ? props.text : 'no comment.'} +// +// +// +// +// ) +// } +const Popup = props => { return ( - - - - - - - - -
NickComment
+
+
+ + + {props.slug} +
+ + + Nick + + + + + + + + + +
+
+ +
+
+
) } +class Captions extends React.Component { + constructor() { + super() + this.state = {showPopup: false} + this.togglePopup = this.togglePopup.bind(this) + } + + togglePopup(comment) { + console.log('toggling popup!') + this.setState({ + showPopup: !this.state.showPopup, + nick: comment.nick, + text: comment.text + + }) + } + + + render() { + const captions = this.props.captions.all.find(captionSet=>captionSet.slug===this.props.match.params.slug) + if(!captions) return
No show with that id.
+ return ( +
+ {this.state.showPopup ? + + : null + } + + + + + + + + +
NickComment
+ +
+ ) + }} const mapState = state => { return { @@ -28,4 +98,6 @@ const mapState = state => { } } + + export default connect(mapState)(Captions)