From 4c7ed7102aa5fdf3245ce1113614fee2d15fbd07 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 24 Jul 2020 19:56:27 +0200 Subject: checklist dropdown --- .../views/viewer/checklist/checklist.container.js | 43 +++++++++--------- .../views/viewer/checklist/checklist.content.js | 30 +++++++++++++ .../app/views/viewer/checklist/checklist.css | 49 +++++++++++++++++++++ .../views/viewer/checklist/checklist.dropdown.js | 51 ++++++++++++++++++++++ 4 files changed, 151 insertions(+), 22 deletions(-) create mode 100644 animism-align/frontend/app/views/viewer/checklist/checklist.content.js create mode 100644 animism-align/frontend/app/views/viewer/checklist/checklist.dropdown.js (limited to 'animism-align/frontend/app/views/viewer/checklist') diff --git a/animism-align/frontend/app/views/viewer/checklist/checklist.container.js b/animism-align/frontend/app/views/viewer/checklist/checklist.container.js index da4d6c3..3a441fa 100644 --- a/animism-align/frontend/app/views/viewer/checklist/checklist.container.js +++ b/animism-align/frontend/app/views/viewer/checklist/checklist.container.js @@ -1,36 +1,35 @@ 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' -// import * as uploadActions from './upload.actions' + +import ChecklistDropdown from './checklist.dropdown' +import ChecklistContent from './checklist.content' class Checklist extends Component { - componentDidMount() { + state = { + currentSection: 'all', + } + constructor(props) { + super(props) + this.handleSectionChange = this.handleSectionChange.bind(this) + } + handleSectionChange(currentSection) { + this.setState({ currentSection }) } render() { - const { } = this.props + const { currentSection } = this.state return (
-
-
-
-
-
-
-
-
+ +
) } } -const mapStateToProps = state => ({ -}) - -const mapDispatchToProps = dispatch => ({ - // uploadActions: bindActionCreators({ ...uploadActions }, dispatch), -}) - -export default connect(mapStateToProps, mapDispatchToProps)(Checklist) +export default Checklist diff --git a/animism-align/frontend/app/views/viewer/checklist/checklist.content.js b/animism-align/frontend/app/views/viewer/checklist/checklist.content.js new file mode 100644 index 0000000..ae72adf --- /dev/null +++ b/animism-align/frontend/app/views/viewer/checklist/checklist.content.js @@ -0,0 +1,30 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' + +import actions from 'app/actions' + +class ChecklistContent extends Component { + render() { + const { sections, currentSection } = this.props + return ( +
+
+
+ {sections.map(section => { + if (currentSection !== "all" || section.index !== currentSection) return + return ( +
+ ) + })} +
+
+
+ ) + } +} + +const mapStateToProps = state => ({ + sections: state.viewer.sections, +}) + +export default connect(mapStateToProps)(ChecklistContent) diff --git a/animism-align/frontend/app/views/viewer/checklist/checklist.css b/animism-align/frontend/app/views/viewer/checklist/checklist.css index b6ea6f1..4e87335 100644 --- a/animism-align/frontend/app/views/viewer/checklist/checklist.css +++ b/animism-align/frontend/app/views/viewer/checklist/checklist.css @@ -9,7 +9,56 @@ transition: transform 0.2s; background: white; color: black; + font-size: 16px; + padding: 1.5rem; } .checklist-open .checklist { transform: translateZ(0) translateY(0); } + + +/* dropdown */ + +.checklist-dropdown-container { + width: 12rem; + cursor: pointer; +} +.checklist-dropdown { + display: flex; + flex-flow: row nowrap; + justify-content: space-between; + align-items: center; + border: 1px solid black; + padding-left: 0.5rem; +} +.checklist-dropdown .arrow-box { + display: flex; + justify-content: center; + align-items: center; + padding: 0 0.5rem; + border-left: 1px solid black; +} +.checklist-dropdown .arrow { + width: 2.5rem; + height: 2rem; +} +.checklist-dropdown-options { + border-left: 1px solid black; + border-right: 1px solid black; + border-bottom: 1px solid black; + transition: height 0.2s; + overflow: hidden; + position: relative; + top: -1px; +} +.checklist-dropdown-options.open { + top: 0; +} +.checklist-dropdown-options div { + padding: 0.25rem 0.5rem; + transition: all 0.1s; +} +.checklist-dropdown-options div:hover { + color: white; + background: black; +} 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 ( +
+
+
this.handleOpen()}> + {currentSection === 'all' ? 'View All' : 'Section ' + ROMAN_NUMERALS[currentSection]} +
+ +
+
+
+ {sections.map(section => ( +
this.handleSelect(section.index)}> + {'Section '}{ROMAN_NUMERALS[section.index]} +
+ ))} +
+
+
+ ) + } +} + +const mapStateToProps = state => ({ + sections: state.viewer.sections, +}) + +export default connect(mapStateToProps)(ChecklistDropdown) -- cgit v1.2.3-70-g09d2