From 4344c738f8bb823a36fec329a26e30e98c38ba13 Mon Sep 17 00:00:00 2001 From: Marco Vettorello Date: Fri, 14 Feb 2020 15:12:55 +0100 Subject: [PATCH] chore: move tooltips component to global folder --- .../xy_chart/state/chart_state.tsx | 4 +-- src/components/_index.scss | 2 +- src/components/tooltip/_index.scss | 1 + src/components/{ => tooltip}/_tooltip.scss | 0 .../tooltip/index.tsx} | 25 +++++++++++-------- 5 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 src/components/tooltip/_index.scss rename src/components/{ => tooltip}/_tooltip.scss (100%) rename src/{chart_types/xy_chart/renderer/dom/tooltips.tsx => components/tooltip/index.tsx} (81%) diff --git a/src/chart_types/xy_chart/state/chart_state.tsx b/src/chart_types/xy_chart/state/chart_state.tsx index 83932a45ae..ef88a90609 100644 --- a/src/chart_types/xy_chart/state/chart_state.tsx +++ b/src/chart_types/xy_chart/state/chart_state.tsx @@ -1,7 +1,7 @@ import React, { RefObject } from 'react'; import { InternalChartState, GlobalChartState, BackwardRef } from '../../../state/chart_state'; import { ChartTypes } from '../..'; -import { Tooltips } from '../renderer/dom/tooltips'; +import { Tooltip } from '../../../components/tooltip'; import { htmlIdGenerator } from '../../../utils/commons'; import { Highlighter } from '../renderer/dom/highlighter'; import { Crosshair } from '../renderer/dom/crosshair'; @@ -39,7 +39,7 @@ export class XYAxisChartState implements InternalChartState { - + diff --git a/src/components/_index.scss b/src/components/_index.scss index bae81d02d7..7c487177a2 100644 --- a/src/components/_index.scss +++ b/src/components/_index.scss @@ -1,7 +1,7 @@ @import 'global'; @import 'container'; @import 'annotation'; -@import 'tooltip'; +@import 'tooltip/index'; @import 'icons/index'; @import 'legend/index'; @import 'unavailable_chart'; diff --git a/src/components/tooltip/_index.scss b/src/components/tooltip/_index.scss new file mode 100644 index 0000000000..0a06e6f1bb --- /dev/null +++ b/src/components/tooltip/_index.scss @@ -0,0 +1 @@ +@import 'tooltip'; diff --git a/src/components/_tooltip.scss b/src/components/tooltip/_tooltip.scss similarity index 100% rename from src/components/_tooltip.scss rename to src/components/tooltip/_tooltip.scss diff --git a/src/chart_types/xy_chart/renderer/dom/tooltips.tsx b/src/components/tooltip/index.tsx similarity index 81% rename from src/chart_types/xy_chart/renderer/dom/tooltips.tsx rename to src/components/tooltip/index.tsx index 8d3d14b200..ad444622e9 100644 --- a/src/chart_types/xy_chart/renderer/dom/tooltips.tsx +++ b/src/components/tooltip/index.tsx @@ -1,16 +1,19 @@ import classNames from 'classnames'; import React from 'react'; import { connect } from 'react-redux'; -import { TooltipValue, TooltipValueFormatter } from '../../utils/interactions'; -import { GlobalChartState, BackwardRef } from '../../../../state/chart_state'; -import { isTooltipVisibleSelector } from '../../state/selectors/is_tooltip_visible'; -import { getTooltipHeaderFormatterSelector } from '../../state/selectors/get_tooltip_header_formatter'; -import { getTooltipPositionSelector } from '../../state/selectors/get_tooltip_position'; -import { getTooltipValuesSelector, TooltipData } from '../../state/selectors/get_tooltip_values_highlighted_geoms'; -import { isInitialized } from '../../../../state/selectors/is_initialized'; +import { TooltipValue, TooltipValueFormatter } from '../../chart_types/xy_chart/utils/interactions'; +import { GlobalChartState, BackwardRef } from '../../state/chart_state'; +import { isTooltipVisibleSelector } from '../../chart_types/xy_chart/state/selectors/is_tooltip_visible'; +import { getTooltipHeaderFormatterSelector } from '../../chart_types/xy_chart/state/selectors/get_tooltip_header_formatter'; +import { getTooltipPositionSelector } from '../../chart_types/xy_chart/state/selectors/get_tooltip_position'; +import { + getTooltipValuesSelector, + TooltipData, +} from '../../chart_types/xy_chart/state/selectors/get_tooltip_values_highlighted_geoms'; +import { isInitialized } from '../../state/selectors/is_initialized'; import { createPortal } from 'react-dom'; -import { getFinalTooltipPosition, TooltipPosition } from '../../crosshair/crosshair_utils'; -import { isAnnotationTooltipVisibleSelector } from '../../state/selectors/is_annotation_tooltip_visible'; +import { getFinalTooltipPosition, TooltipPosition } from '../../chart_types/xy_chart/crosshair/crosshair_utils'; +import { isAnnotationTooltipVisibleSelector } from '../../chart_types/xy_chart/state/selectors/is_annotation_tooltip_visible'; interface TooltipStateProps { isTooltipVisible: boolean; @@ -24,7 +27,7 @@ interface TooltipOwnProps { } type TooltipProps = TooltipStateProps & TooltipOwnProps; -class TooltipsComponent extends React.Component { +class TooltipComponent extends React.Component { static displayName = 'Tooltips'; portalNode: HTMLDivElement | null = null; tooltipRef: React.RefObject; @@ -148,4 +151,4 @@ const mapStateToProps = (state: GlobalChartState): TooltipStateProps => { }; }; -export const Tooltips = connect(mapStateToProps)(TooltipsComponent); +export const Tooltip = connect(mapStateToProps)(TooltipComponent);