Skip to content

Commit

Permalink
fix(tooltip): opac color in tooltip to match chart
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Jun 8, 2020
1 parent 0a91351 commit 58cf176
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';

import { Example } from '../stories/treemap/6_custom_style';
import { Example } from '../stories/stylings/20_partition_background';

export class Playground extends React.Component {
render() {
Expand Down
24 changes: 21 additions & 3 deletions src/components/tooltip/_tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,28 @@

&__item {
display: flex;
padding: 3px;
box-sizing: border-box;
border-left: $euiSizeXS solid transparent;
min-width: 1px;

&--container {
display: flex;
padding: 3px;
padding-left: 0;
min-width: 1px;
}

&--backgroundColor {
position: relative;
width: $euiSizeXS;
margin-right: 3px;
}

&--color {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}

&__label {
Expand Down
32 changes: 23 additions & 9 deletions src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TooltipValueFormatter, TooltipSettings, TooltipValue } from '../../spec
import { onPointerMove } from '../../state/actions/mouse';
import { GlobalChartState, BackwardRef } from '../../state/chart_state';
import { getChartRotationSelector } from '../../state/selectors/get_chart_rotation';
import { getChartThemeSelector } from '../../state/selectors/get_chart_theme';
import { getInternalIsInitializedSelector } from '../../state/selectors/get_internal_is_intialized';
import { getInternalIsTooltipVisibleSelector } from '../../state/selectors/get_internal_is_tooltip_visible';
import { getInternalTooltipAnchorPositionSelector } from '../../state/selectors/get_internal_tooltip_anchor_position';
Expand All @@ -48,6 +49,7 @@ interface TooltipStateProps {
settings: TooltipSettings;
rotation: Rotation;
chartId: string;
backgroundColor: string;
}

interface TooltipOwnProps {
Expand All @@ -66,6 +68,7 @@ const TooltipComponent = ({
rotation,
chartId,
onPointerMove,
backgroundColor,
}: TooltipProps) => {
const chartRef = getChartContainerRef();

Expand Down Expand Up @@ -109,15 +112,24 @@ const TooltipComponent = ({
borderLeftColor: color,
}}
>
<span className="echTooltip__label">{label}</span>
<span className="echTooltip__value">{value}</span>
{markValue && (
<span className="echTooltip__markValue">
&nbsp;(
{markValue}
)
</span>
)}
<div className="echTooltip__item--backgroundColor" style={{ backgroundColor }}>
<div
className="echTooltip__item--color"
style={{ backgroundColor: color }}
/>
</div>

<div className="echTooltip__item--container">
<span className="echTooltip__label">{label}</span>
<span className="echTooltip__value">{value}</span>
{markValue && (
<span className="echTooltip__markValue">
&nbsp;(
{markValue}
)
</span>
)}
</div>
</div>
);
},
Expand Down Expand Up @@ -204,6 +216,7 @@ const HIDDEN_TOOLTIP_PROPS = {
settings: {},
rotation: 0 as Rotation,
chartId: '',
backgroundColor: 'transparent',
};

const mapDispatchToProps = (dispatch: Dispatch): TooltipDispatchProps =>
Expand All @@ -221,6 +234,7 @@ const mapStateToProps = (state: GlobalChartState): TooltipStateProps => {
settings: getSettingsSpecSelector(state).tooltip,
rotation: getChartRotationSelector(state),
chartId: state.chartId,
backgroundColor: getChartThemeSelector(state).background.color,
};
};

Expand Down

0 comments on commit 58cf176

Please sign in to comment.