summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/align/containers/script.container.js
blob: fe3f27b23af5adbbdabecdd1e1d39ebb57e8fa85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, { Component } from 'react'
// import { Link } from 'react-router-dom'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'

import actions from 'app/actions'

class Timeline extends Component {
  state = {
    visible: false,
  }
  constructor(props){
    super(props)
  }
  render() {
    if (this.props.text.loading) return <div />
    if (!this.state.visible) {
      return (
        <div className='script'>
          <button onClick={() => this.setState({ visible: true })}>
            +
          </button>
        </div>
      )
    }
    return (
      <div className='script'>
        <textarea 
          className='script'
          onChange={e => actions.site.updateText(e.target.value)}
          value={this.props.text}
        />
        <button onClick={() => this.setState({ visible: false })}>
          x
        </button>
      </div>
    )
  }
}


const mapStateToProps = state => ({
  text: state.site.text,
})

const mapDispatchToProps = dispatch => ({
  // alignActions: bindActionCreators({ ...alignActions }, dispatch),
})

export default connect(mapStateToProps, mapDispatchToProps)(Timeline)