import { useRef, useState } from "react"; import { useClickAway } from "react-use"; import classNames from "classnames"; import { ChevronDownIcon } from "@heroicons/react/solid"; import { FONT_WEIGHT } from "./font-weight.constants"; export const FontWeight = ({ value, onSelect, }: { value?: any; onSelect: (t: string) => void; }) => { const [open, setOpen] = useState(false); const ref = useRef(null); const selected = FONT_WEIGHT.find((f) => f.value === value); useClickAway(ref, () => setOpen(false)); return (
setOpen(!open)} > {selected?.label}
{FONT_WEIGHT.map((font, f) => (
onSelect(font.value)} > {font.label}
))}
); };