From 83bc7b862451863a848caaeb6edb5c7b1b8079f9 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Sun, 8 Apr 2018 21:12:25 -0700 Subject: [PATCH] implements category expansion for categorical metadata --- src/components/categorical/categorical.js | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/components/categorical/categorical.js b/src/components/categorical/categorical.js index 54b7f65b..58cf8a9b 100644 --- a/src/components/categorical/categorical.js +++ b/src/components/categorical/categorical.js @@ -17,7 +17,8 @@ class Category extends React.Component { constructor(props) { super(props); this.state = { - isChecked: true + isChecked: true, + isExpanded: false }; } @@ -42,6 +43,18 @@ class Category extends React.Component { }) this.setState({isChecked: false}) } + renderCategoryItems() { + return _.map(alphabeticallySortedValues(this.props.values), (v, i) => { + return ( + + ) + }) + } render() { return ( @@ -63,6 +76,13 @@ class Category extends React.Component { // fontStyle: "italic", marginRight: 10, }}> + { + this.setState({isExpanded: !this.state.isExpanded}) + }}> + {this.state.isExpanded ? "⯆ " : "⯈ "} + {this.props.metadataField}
{ - _.map(alphabeticallySortedValues(this.props.values), (v, i) => { - return ( - - ) - }) + this.state.isExpanded ? this.renderCategoryItems() : null }