From e7ed697def90e67ae031247546c31384dca8a6eb Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 12 Oct 2017 19:32:42 -0700 Subject: [PATCH] categorical fires an action --- src/components/categorical/categorical.css | 0 src/components/categorical/categorical.js | 94 +++++++++++++--------- 2 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 src/components/categorical/categorical.css diff --git a/src/components/categorical/categorical.css b/src/components/categorical/categorical.css new file mode 100644 index 00000000..e69de29b diff --git a/src/components/categorical/categorical.js b/src/components/categorical/categorical.js index 46242774..96dac589 100644 --- a/src/components/categorical/categorical.js +++ b/src/components/categorical/categorical.js @@ -6,48 +6,42 @@ import * as globals from "../../globals"; import styles from "./categorical.css"; import SectionHeader from "../framework/sectionHeader" import createCategoryCounts from "./createCategoryCounts"; -import { updateCategoricalQueryParams } from "../../util"; +import { alphabeticallySortedValues } from "../../util"; import cells from "../../../data/GBM_metadata.js"; -const Button = ({category, value, count, i}) => ( - -) - -const alphabeticallySortedValues = (values) => { - return Object.keys(values).sort((a, b) => { - var textA = a.toUpperCase(); - var textB = b.toUpperCase(); - return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; - }) +class Button extends React.Component { + render () { + return ( + + ) + } } -const Category = ({category, values}) => ( +const Category = ({category, values, handleClick}) => (
( marginRight: 20 }}>{category}:

- { _.map(alphabeticallySortedValues(values), (v, i) =>
) @@ -77,15 +83,27 @@ class Categorical extends React.Component { }; } + handleClick(category, value) { + return () => { + this.props.dispatch({type: "category changed", data: {category, value}}) + } + } render () { return (
+

Sort by: Alphabetical / Count || Show counts: true / false || Collapse: all / none

{ _.map(createCategoryCounts(cells), (value, key) => { - return + return ( + + ) }) }