Skip to content

Commit

Permalink
UI - Refactor to TooltipWrapper and add offset to the tooltips on hov…
Browse files Browse the repository at this point in the history
…er of the profile aggregate status indicators (#25039)

## #25038 

Refactor to TooltipWrapper and add offset to the tooltips on hover of
the profile aggregate status indicators.

<img width="1345" alt="Screenshot 2024-12-29 at 9 00 38 PM"
src="https://github.com/user-attachments/assets/3bf5cf3c-e9fc-47dc-aa07-9cef42edcae0"
/>

- [x] Changes file added for user-visible changes in `changes/`, 
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
  • Loading branch information
jacobshandling and Jacob Shandling authored Dec 30, 2024
1 parent 1725eff commit c2bd802
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add offset to the tooltips on hover of the profile aggregate status indicators.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React from "react";
import ReactTooltip from "react-tooltip";
import { uniqueId } from "lodash";
import classnames from "classnames";

import { IconNames } from "components/icons";
import Icon from "components/Icon";
import { COLORS } from "styles/var/colors";
import TooltipWrapper from "components/TooltipWrapper";

const baseClass = "status-indicator-with-icon";

Expand Down Expand Up @@ -46,7 +44,6 @@ const StatusIndicatorWithIcon = ({
valueClassName,
}: IStatusIndicatorWithIconProps) => {
const classNames = classnames(baseClass, className);
const id = `status-${uniqueId()}`;

const valueClasses = classnames(`${baseClass}__value`, valueClassName, {
[`${baseClass}__value-vertical`]: layout === "vertical",
Expand All @@ -59,21 +56,18 @@ const StatusIndicatorWithIcon = ({
);

const indicatorContent = tooltip ? (
<>
<span data-tip data-for={id}>
{valueContent}
</span>
<ReactTooltip
className={`${baseClass}__tooltip`}
place={tooltip?.position ? tooltip.position : "top"}
type="dark"
effect="solid"
id={id}
backgroundColor={COLORS["tooltip-bg"]}
>
{tooltip.tooltipText}
</ReactTooltip>
</>
<TooltipWrapper
className={`${baseClass}__tooltip`}
tooltipClass="indicator-tip-text"
position="top"
tipContent={tooltip.tooltipText}
tipOffset={10}
showArrow
underline={false}
fixedPositionStrategy
>
{valueContent}
</TooltipWrapper>
) : (
<span>{valueContent}</span>
);
Expand Down
4 changes: 4 additions & 0 deletions frontend/components/StatusIndicatorWithIcon/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
flex-direction: column;
gap: $pad-xsmall;
}

.indicator-tip-text {
text-align: center;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@
&__status-indicator-value {
font-weight: $bold;
}

.icon {
margin-right: initial;
}
}

0 comments on commit c2bd802

Please sign in to comment.