"use client"; import { Input } from "components/Input"; import { useState } from "react"; import { Menu } from "components/Menu"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; import { useIsMobile } from "src/hooks/isMobile"; import { fonts, defaultFontId, FontConfig, isCustomFontId, parseGoogleFontInput, createCustomFontId, getFontConfig, } from "src/fonts"; export const FontPicker = (props: { label: string; value: string | undefined; onChange: (fontId: string) => void; }) => { let isMobile = useIsMobile(); let [showCustomInput, setShowCustomInput] = useState(false); let [customFontValue, setCustomFontValue] = useState(""); let fontId = props.value || defaultFontId; let font = getFontConfig(fontId); let isCustom = isCustomFontId(fontId); let fontList = Object.values(fonts).sort((a, b) => a.displayName.localeCompare(b.displayName), ); const handleCustomSubmit = () => { const parsed = parseGoogleFontInput(customFontValue); if (parsed) { const customId = createCustomFontId( parsed.fontName, parsed.googleFontsFamily, ); props.onChange(customId); setShowCustomInput(false); setCustomFontValue(""); } }; return (
); }; const FontOption = (props: { onSelect: () => void; font: FontConfig; selected: boolean; }) => { return (