"use client"; import * as React from "react"; import fonts from "../assets/fonts.json"; import { CaretSortIcon, CheckIcon, } from "@radix-ui/react-icons"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { useEffect } from "react"; type PopoverTriggerProps = React.ComponentPropsWithoutRef< typeof PopoverTrigger >; type Props = PopoverTriggerProps; export function FontFamilyPicker({}: Props) { const [open, setOpen] = React.useState(false); const [selectedFont, setSelectedFont] = React.useState("Roboto"); useEffect(() => { fonts.items.map((font): void => { const fontLink = font.files.regular; const newFont = new FontFace(font.family, `url(${fontLink})`); newFont .load() .then((loadedFont) => { document.fonts.add(loadedFont); }) .catch((e) => console.error(e)); }); }, []); return ( No team found. {fonts.items.map((font) => ( { setSelectedFont(font.family); setOpen(false); }} className="text-sm" style={{ fontFamily: font.family }} > {font.family} ))} ); }