All files / owid-grapher/grapher/sparkBars SparkBarTimeSeriesValue.tsx

87.5% Statements 35/40
33.33% Branches 1/3
100% Functions 1/1
87.5% Lines 35/40

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 441x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x              
import * as React from "react"
import classnames from "classnames"
 
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons/faQuestionCircle"
 
import { Tippy } from "../chart/Tippy"
 
export const SparkBarTimeSeriesValue = ({
    value,
    latest,
    tooltip,
    className,
    displayDate,
    valueColor,
}: {
    value: string | undefined
    latest?: boolean
    tooltip?: JSX.Element | string
    className?: string
    displayDate?: string
    valueColor?: string
}): JSX.Element => (
    <div className={classnames("time-series-value", className)}>
        {value !== undefined ? (
            <>
                <span className="count">
                    <span style={{ color: valueColor }}>{value}</span>{" "}
                    {tooltip && (
                        <Tippy content={tooltip} maxWidth={250}>
                            <span className="help-icon">
                                <FontAwesomeIcon icon={faQuestionCircle} />
                            </span>
                        </Tippy>
                    )}
                </span>
                <span className={classnames("date", { latest: latest })}>
                    {displayDate}
                </span>
            </>
        ) : undefined}
    </div>
)