All files / owid-grapher/site BackToTopic.tsx

35% Statements 7/20
100% Branches 0/0
0% Functions 0/1
35% Lines 7/20

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 221x 1x 1x 1x 1x 1x 1x                              
import React from "react"
import { SubNavId } from "../clientUtils/owidTypes"
import { getSubnavItem, subnavs } from "./SiteSubnavigation"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons/faArrowLeft"
 
export const BackToTopic = ({
    subnavId,
}: {
    subnavId: SubNavId
}): JSX.Element | null => {
    const subnavItem = getSubnavItem(subnavId, subnavs[subnavId])
    if (!subnavItem) return null

    return (
        <a className="back-to-topic" href={subnavItem.href}>
            <FontAwesomeIcon icon={faArrowLeft} />
            <span>{subnavItem.label}</span>
        </a>
    )
}