diff --git a/packages/global-styles-ui/CHANGELOG.md b/packages/global-styles-ui/CHANGELOG.md index 10c04fbd7ad34f..72fb5e240df592 100644 --- a/packages/global-styles-ui/CHANGELOG.md +++ b/packages/global-styles-ui/CHANGELOG.md @@ -6,6 +6,7 @@ - Element screens: add an "Overridden by" list of the block types whose own styles override the element, linking to each block's screen ([#84671](https://github.com/WordPress/gutenberg/pull/84671)). - Show icons for elements in the Blocks & Elements list, and rename Input, Select and Button (element) to Form input, Form select and Form button ([#85363](https://github.com/WordPress/gutenberg/pull/85363)). +- Font Library: Paginate installed fonts in the Library tab, like in the Install tab ([#86063](https://github.com/WordPress/gutenberg/pull/86063)). ## 2.0.0 (2026-10-20) diff --git a/packages/global-styles-ui/src/font-library/font-collection.tsx b/packages/global-styles-ui/src/font-library/font-collection.tsx index 319c2b24af65ed..f4d64d7d891d99 100644 --- a/packages/global-styles-ui/src/font-library/font-collection.tsx +++ b/packages/global-styles-ui/src/font-library/font-collection.tsx @@ -1,10 +1,4 @@ -import { - useContext, - useEffect, - useState, - useMemo, - createInterpolateElement, -} from '@wordpress/element'; +import { useContext, useEffect, useState, useMemo } from '@wordpress/element'; import { __experimentalSpacer as Spacer, __experimentalText as WCText, @@ -23,17 +17,10 @@ import { // eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135. Menu, Progress, - Select, } from '@wordpress/ui'; import { debounce } from '@wordpress/compose'; -import { sprintf, __, _x, isRTL } from '@wordpress/i18n'; -import { - moreVertical, - next, - previous, - chevronLeft, - chevronRight, -} from '@wordpress/icons'; +import { __, _x, isRTL } from '@wordpress/i18n'; +import { moreVertical, chevronLeft, chevronRight } from '@wordpress/icons'; import { useEntityRecord } from '@wordpress/core-data'; import type { FontCollection as FontCollectionType, @@ -43,6 +30,7 @@ import type { } from '@wordpress/core-data'; import { FontLibraryContext } from './context'; import FontCard from './font-card'; +import Pagination, { getFontsPerPage } from './pagination'; import filterFonts from './utils/filter-fonts'; import { toggleFont } from './utils/toggleFont'; import { @@ -61,7 +49,6 @@ const DEFAULT_CATEGORY = { }; const LOCAL_STORAGE_ITEM = 'wp-font-library-google-fonts-permission'; -const MIN_WINDOW_HEIGHT = 500; function FontCollection( { slug }: { slug: string } ) { const requiresPermission = slug === 'google-fonts'; @@ -136,10 +123,7 @@ function FontCollection( { slug }: { slug: string } ) { [ collectionFonts, filters ] ); - // NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px - // The height of each font family item is 61px. - const windowHeight = Math.max( window.innerHeight, MIN_WINDOW_HEIGHT ); - const pageSize = Math.floor( ( windowHeight - 417 ) / 61 ); + const pageSize = getFontsPerPage(); const totalPages = Math.ceil( fonts.length / pageSize ); const itemsStart = ( page - 1 ) * pageSize; const itemsLimit = page * pageSize; @@ -546,91 +530,11 @@ function FontCollection( { slug }: { slug: string } ) { justify="end" spacing={ 6 } > - - { createInterpolateElement( - sprintf( - // translators: 1: Current page number, 2: Total number of pages. - _x( - '
Page
%1$s
of %2$d
', - 'paging' - ), - '', - totalPages - ), - { - div:
, - // @ts-expect-error — Tag injected via sprintf argument, not visible in format string. - CurrentPage: ( - { - if ( newPage !== null ) { - setPage( - parseInt( newPage ) - ); - } - } } - > - - - { [ - ...Array( totalPages ), - ].map( ( e, i ) => { - const value = ( - i + 1 - ).toString(); - return ( - - - { value } - - - ); - } ) } - - - ), - } - ) } - - -