import React from "react"; import classnames from "classnames"; import { IconNames } from "components/icons"; import Icon from "components/Icon"; import TooltipWrapper from "components/TooltipWrapper"; const baseClass = "status-indicator-with-icon"; export type IndicatorStatus = | "success" | "successPartial" | "pending" | "pendingPartial" | "error" | "failure" | "actionRequired"; interface IStatusIndicatorWithIconProps { /** Determines which icon to display */ status: IndicatorStatus; /** The text to be displayed */ value: string; tooltip?: { tooltipText: string | JSX.Element; position?: "top" | "bottom"; }; layout?: "horizontal" | "vertical"; className?: string; /** Classname to add to the value text */ valueClassName?: string; } const statusIconNameMapping: Record = { success: "success", successPartial: "success-outline", pending: "pending", pendingPartial: "pending-outline", error: "error", failure: "error-outline", actionRequired: "error", }; const StatusIndicatorWithIcon = ({ status, value, tooltip, layout = "horizontal", className, valueClassName, }: IStatusIndicatorWithIconProps) => { const classNames = classnames(baseClass, className); const valueClasses = classnames(`${baseClass}__value`, valueClassName, { [`${baseClass}__value-vertical`]: layout === "vertical", }); const valueContent = ( {value} ); const indicatorContent = tooltip ? ( {valueContent} ) : ( {valueContent} ); return
{indicatorContent}
; }; export default StatusIndicatorWithIcon;