client/src/components/CategoriesTooltip.js
author Alexandre Segura <mex.zktk@gmail.com>
Thu, 08 Jun 2017 11:13:41 +0200
changeset 21 284e866f55c7
child 25 e04714a1d4eb
permissions -rw-r--r--
First version of categories tooltip. - Use react-portal to display hovering menu. - Add custom Mark to store category data.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
import React, { Component } from 'react';
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     2
import { FormGroup, FormControl, Button } from 'react-bootstrap';
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     3
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     4
class CategoriesTooltip extends Component {
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     5
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     6
  onButtonClick = (category) => {
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     7
    if (typeof this.props.onCategoryClick === 'function') {
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     8
      this.props.onCategoryClick(category)
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     9
    }
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    10
  }
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    11
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    12
  render() {
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    13
    return (
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    14
      <div className="categories-tooltip">
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    15
        <FormGroup className="buttons">
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    16
        {this.props.categories.map((category) =>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    17
          <Button key={ category.name } bsStyle="primary" style={{ backgroundColor: category.color }}
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    18
            onClick={this.onButtonClick.bind(this, category)}>{ category.name }</Button>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    19
        )}
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    20
        </FormGroup>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    21
        <FormGroup>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    22
          <FormControl />
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    23
        </FormGroup>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    24
      </div>
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    25
    );
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    26
  }
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    27
}
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    28
284e866f55c7 First version of categories tooltip.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    29
export default CategoriesTooltip