blob: 8ff8181b0c81701e7db0c276ee0835a23b2839fd (
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
|
import React, { Component } from 'react'
import { connect } from 'react-redux'
// import { Link } from 'react-router-dom'
import actions from 'app/actions'
import Script from '../components/sidebar/script.component.js'
import TableOfContents from '../components/sidebar/tableOfContents.component.js'
import WaveUpload from '../components/sidebar/waveUpload.component.js'
class Sidebar extends Component {
state = {
mode: "toc",
}
componentDidMount(){
if (!this.props.peaks.length) {
this.setState({ mode: "wav" })
}
}
render() {
const { mode } = this.state
return (
<div className='sidebar'>
<div className='buttons'>
<button onClick={() => this.setState({ mode: "txt" })}>text</button>
<button onClick={() => this.setState({ mode: "wav" })}>wav</button>
<button onClick={() => this.setState({ mode: "toc" })}>contents</button>
</div>
{mode === 'toc' && <TableOfContents />}
{mode === 'txt' && <Script />}
{mode === 'wav' && <WaveUpload />}
</div>
)
}
}
const mapStateToProps = state => ({
peaks: state.align.peaks,
})
export default connect(mapStateToProps)(Sidebar)
|