feat: allow the hiding of default fonts

This commit is contained in:
Ryan Di
2025-07-16 17:48:12 +10:00
parent 580622709d
commit 00c6599a71

View File

@@ -58,6 +58,7 @@ interface FontPickerProps {
onHover: (fontFamily: FontFamilyValues) => void; onHover: (fontFamily: FontFamilyValues) => void;
onLeave: () => void; onLeave: () => void;
onPopupChange: (open: boolean) => void; onPopupChange: (open: boolean) => void;
compactMode?: boolean;
} }
export const FontPicker = React.memo( export const FontPicker = React.memo(
@@ -69,6 +70,7 @@ export const FontPicker = React.memo(
onHover, onHover,
onLeave, onLeave,
onPopupChange, onPopupChange,
compactMode = false,
}: FontPickerProps) => { }: FontPickerProps) => {
const defaultFonts = useMemo(() => DEFAULT_FONTS, []); const defaultFonts = useMemo(() => DEFAULT_FONTS, []);
const onSelectCallback = useCallback( const onSelectCallback = useCallback(
@@ -82,15 +84,17 @@ export const FontPicker = React.memo(
return ( return (
<div role="dialog" aria-modal="true" className="FontPicker__container"> <div role="dialog" aria-modal="true" className="FontPicker__container">
<div className="buttonList"> {!compactMode && (
<RadioSelection<FontFamilyValues | false> <div className="buttonList">
type="button" <RadioSelection<FontFamilyValues | false>
options={defaultFonts} type="button"
value={selectedFontFamily} options={defaultFonts}
onClick={onSelectCallback} value={selectedFontFamily}
/> onClick={onSelectCallback}
</div> />
<ButtonSeparator /> </div>
)}
{!compactMode && <ButtonSeparator />}
<Popover.Root open={isOpened} onOpenChange={onPopupChange}> <Popover.Root open={isOpened} onOpenChange={onPopupChange}>
<FontPickerTrigger selectedFontFamily={selectedFontFamily} /> <FontPickerTrigger selectedFontFamily={selectedFontFamily} />
{isOpened && ( {isOpened && (