From bdf231f88d114ad0756ca4a1567d44c99aea2f8a Mon Sep 17 00:00:00 2001 From: ahmed-Bazzara Date: Thu, 21 Feb 2019 12:29:16 +0100 Subject: [PATCH] code enhancements --- src/data-table/data-cell.jsx | 5 +---- src/main.less | 1 + src/tooltip/index.jsx | 25 +++++++++++-------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/data-table/data-cell.jsx b/src/data-table/data-cell.jsx index 4266827..3a50bc0 100644 --- a/src/data-table/data-cell.jsx +++ b/src/data-table/data-cell.jsx @@ -87,11 +87,9 @@ class DataCell extends React.PureComponent { general, measurement, styleBuilder, - styling, - qlik + styling } = this.props; - const inEditState = qlik.inEditState(); const isColumnPercentageBased = measurement.name.substring(0, 1) === '%'; let formattedMeasurementValue = formatMeasurementValue(measurement, styling); if (styleBuilder.hasComments()) { @@ -138,7 +136,6 @@ class DataCell extends React.PureComponent { style={cellStyle} > {formattedMeasurementValue} diff --git a/src/main.less b/src/main.less index 1cfca0f..54cb114 100644 --- a/src/main.less +++ b/src/main.less @@ -18,6 +18,7 @@ width: auto; opacity: .9; text-align: center; + transform: translate(-50%,-110%); >p{ color: #fff; } diff --git a/src/tooltip/index.jsx b/src/tooltip/index.jsx index c156c80..336c6a1 100644 --- a/src/tooltip/index.jsx +++ b/src/tooltip/index.jsx @@ -1,5 +1,13 @@ import React from 'react'; import PropTypes from 'prop-types'; + +const handleCalculateTooltipPosition = (event) => { + const tooltipClassName = 'tooltip-wrapper'; + const tooltip = document.getElementsByClassName(tooltipClassName); + + tooltip[0].style.left = event.clientX + 'px'; + tooltip[0].style.top = event.clientY + 'px'; +}; class Tooltip extends React.Component { constructor (props) { super(props); @@ -7,7 +15,6 @@ class Tooltip extends React.Component { showTooltip: false }; this.handleRenderTooltip = this.handleRenderTooltip.bind(this); - this.handleCalculateTooltipPosition = this.handleCalculateTooltipPosition.bind(this); } shouldComponentUpdate (nextProps, nextState) { @@ -23,29 +30,20 @@ class Tooltip extends React.Component { this.setState({ showTooltip: !showTooltip }); } - handleCalculateTooltipPosition (event) { - const tooltipClassName = 'tooltip-wrapper'; - let tooltip = document.getElementsByClassName(tooltipClassName); - const xPositionOffset = 25; - const yPositionOffset = 65; - - tooltip[0].style.left = event.clientX - xPositionOffset + 'px'; - tooltip[0].style.top = event.clientY - yPositionOffset + 'px'; - } render () { - const { children, tooltipText, isTooltipActive } = this.props; + const { children, tooltipText } = this.props; const { showTooltip } = this.state; return (
{children} - {showTooltip && isTooltipActive + {showTooltip ? (