diff --git a/.eslintrc.js b/.eslintrc.js index 2328397..ec3a53b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -129,7 +129,8 @@ module.exports = { "react/jsx-no-literals": ["off"], "react/jsx-max-depth": ["off"], // rule throws exception in single-dimension-measure "react/jsx-filename-extension": ["warn"], - "react/prefer-stateless-function": ["warn"] + "react/prefer-stateless-function": ["warn"], + "react/no-set-state": ["warn"] }, extends: [ "eslint:all", diff --git a/src/data-table/data-cell.jsx b/src/data-table/data-cell.jsx index adde657..c82b5f4 100644 --- a/src/data-table/data-cell.jsx +++ b/src/data-table/data-cell.jsx @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { ApplyPreMask } from '../masking'; import { addSeparators } from '../utilities'; - +import Tooltip from '../tooltip/index.jsx'; function formatMeasurementValue (measurement, styling) { // TODO: measurement.name is a horrible propertyname, it's actually the column header const isColumnPercentageBased = measurement.parents.measurement.header.substring(0, 1) === '%'; @@ -61,14 +61,27 @@ function getSemaphoreColors (measurement, semaphoreColors) { } return semaphoreColors.statusColors.normal; } - -class DataCell extends React.PureComponent { +class DataCell extends React.Component { constructor (props) { super(props); - + this.state = { + bool: false, + mouseXPosition: 0, + mouseYPosition: 0 + }; + this.handleEnter = this.handleEnter.bind(this); + this.handleLeave = this.handleLeave.bind(this); this.handleSelect = this.handleSelect.bind(this); } + shouldComponentUpdate (nextProps, nextState) { + const { bool } = this.state; + if (bool === nextState.bool) { + return false; + } + return true; + } + handleSelect () { const { data: { meta: { dimensionCount } }, general: { allowFilteringByClick }, measurement, qlik } = this.props; const hasSecondDimension = dimensionCount > 1; @@ -83,8 +96,26 @@ class DataCell extends React.PureComponent { } } + handleEnter (event) { + this.setState({ bool: true, + mouseXPosition: event.clientX, + mouseYPosition: event.clientY }); + } + + handleLeave () { + this.setState({ bool: false }); + } + render () { - const { data, general, measurement, styleBuilder, styling } = this.props; + const { bool, mouseXPosition, mouseYPosition } = this.state; + const { + data, + general, + measurement, + styleBuilder, + styling + } = this.props; + const isColumnPercentageBased = measurement.name.substring(0, 1) === '%'; let formattedMeasurementValue = formatMeasurementValue(measurement, styling); if (styleBuilder.hasComments()) { @@ -123,9 +154,18 @@ class DataCell extends React.PureComponent {
+ {data} +
+