import * as React from "react"; import {useContext} from "react"; const cssStyle = require("./Heighlight.scss"); const HighlightContext = React.createContext(undefined); export const HighlightContainer = (props: { children: React.ReactNode | React.ReactNode[], classList?: string, highlightedId?: string, onClick?: () => void }) => { return (
{props.children}
); }; export const HighlightRegion = (props: React.HTMLProps & { highlightId: string }) => { const wProps = Object.assign({}, props); delete wProps["highlightId"]; const highlightedId = useContext(HighlightContext); const highlighted = highlightedId === props.highlightId; wProps.className = (props.className || "") + " " + cssStyle.highlightable + " " + (highlighted ? cssStyle.highlighted : ""); return React.createElement("div", wProps); }; export const HighlightText = (props: { highlightId: string, className?: string, children?: React.ReactNode | React.ReactNode[] }) => { const highlightedId = useContext(HighlightContext); const highlighted = highlightedId === props.highlightId; return (
{props.children}
) };