summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-24 19:56:27 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-24 19:56:27 +0200
commit4c7ed7102aa5fdf3245ce1113614fee2d15fbd07 (patch)
tree8ea3f0d611c0e9b1f4f2aa1d368ef69a9a029d98 /animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js
parentfc4151a6c9d1ce7a29fa6c640a711d4b24e81f0c (diff)
checklist dropdown
Diffstat (limited to 'animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js')
-rw-r--r--animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js b/animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js
new file mode 100644
index 0000000..0ed2f0d
--- /dev/null
+++ b/animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js
@@ -0,0 +1,51 @@
+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, currentSection } = this.props
+ const { open } = this.state
+ return (
+ <div className="checklist-dropdown-column">
+ <div className="checklist-dropdown-container">
+ <div className="checklist-dropdown" onClick={() => this.handleOpen()}>
+ {currentSection === 'all' ? 'View All' : 'Section ' + ROMAN_NUMERALS[currentSection]}
+ <div className='arrow-box'>
+ <Arrow type={open ? 'up' : 'down'} />
+ </div>
+ </div>
+ <div
+ className={open ? "checklist-dropdown-options open" : "checklist-dropdown-options"}
+ style={{ height: open ? ((sections.length * 2) + 'rem') : 0 }}
+ >
+ {sections.map(section => (
+ <div key={section.index} onClick={() => this.handleSelect(section.index)}>
+ {'Section '}{ROMAN_NUMERALS[section.index]}
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+ }
+}
+
+const mapStateToProps = state => ({
+ sections: state.viewer.sections,
+})
+
+export default connect(mapStateToProps)(ChecklistDropdown)