blob: aa105d1e4cb7957073ebb0dd8806b803fa3899db (
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
51
52
53
54
55
56
57
58
59
60
61
|
import React, { Component } from 'react'
import { connect } from 'react-redux'
import actions from 'app/actions'
import { ROMAN_NUMERALS } from 'app/constants'
import { Arrow } from '../nav/viewer.icons'
class ChecklistDropdown extends Component {
state = {
open: false,
}
handleOpen() {
this.setState({ open: !this.state.open })
}
handleSelect(index) {
this.props.onChange(index)
this.setState({ open: false })
}
render() {
const { sections, checklistSection } = this.props
const { open } = this.state
const showingAll = checklistSection === 'all'
let dropdownHeight = sections.length * 2
if (!showingAll) {
dropdownHeight += 2
}
return (
<div className="checklist-dropdown-column">
<div className="checklist-dropdown-container">
<div className="checklist-dropdown" onClick={() => this.handleOpen()}>
{showingAll ? 'View All' : 'Section ' + ROMAN_NUMERALS[checklistSection]}
<div className='arrow-box'>
<Arrow type={open ? 'up' : 'down'} />
</div>
</div>
<div
className={open ? "checklist-dropdown-options open" : "checklist-dropdown-options"}
style={{ height: open ? ((dropdownHeight) + 'rem') : 0 }}
>
{sections.map(section => (
<div key={section.index} onClick={() => this.handleSelect(section.index)}>
{'Section '}{ROMAN_NUMERALS[section.index]}
</div>
))}
{!showingAll &&
<div onClick={() => this.handleSelect('all')}>
{'View All'}
</div>
}
</div>
</div>
</div>
)
}
}
const mapStateToProps = state => ({
sections: state.viewer.sections,
})
export default connect(mapStateToProps)(ChecklistDropdown)
|