/** * Add Font modal — the only place a font is ever added to the library. * Nothing is bulk-loaded: picking a font from the full Google Fonts catalog * (GoogleFontsTab) or uploading a custom file (UploadFontTab) here is the * sole way a font becomes available (see FontLibrarySection / * Font_Pairings::font_choices() on the PHP side). * * The Upload tab only renders when `customUploadsAllowed` is true — the * theme itself never grants font-file upload capability (WordPress.org's * Theme Review handbook prohibits registering custom MIME types outright); * that comes from the Aureon Nexus companion plugin. See * Aureon\Modules\Font_Library\Font_Library's docblock. */ import { useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Modal } from '@wordpress/components'; import GoogleFontsTab from './google-fonts-tab'; import UploadFontTab from './upload-font-tab'; import type { FontLibraryCatalogEntry, FontLibraryEntry } from '../../types'; interface AddFontModalProps { catalog: FontLibraryCatalogEntry[]; existingSlugs: string[]; customUploadsAllowed?: boolean; onAdd: ( entry: FontLibraryEntry ) => void; onClose: () => void; } type ModalTab = 'catalog' | 'upload'; export default function AddFontModal( { catalog, existingSlugs, customUploadsAllowed, onAdd, onClose, }: AddFontModalProps ) { const [ tab, setTab ] = useState< ModalTab >( 'catalog' ); return ( { customUploadsAllowed && (
) } { ( 'catalog' === tab || ! customUploadsAllowed ) && ( ) } { customUploadsAllowed && 'upload' === tab && ( ) }
); }