Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font family preview in the font family picker #67118

Merged
merged 8 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions packages/block-editor/src/components/font-family/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';
import { CustomSelectControl } from '@wordpress/components';
import deprecated from '@wordpress/deprecated';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -30,13 +30,15 @@ export default function FontFamilyControl( {
}

const options = [
{ value: '', label: __( 'Default' ) },
...fontFamilies.map( ( { fontFamily, name } ) => {
return {
value: fontFamily,
label: name || fontFamily,
};
} ),
{
key: '',
name: __( 'Default' ),
},
...fontFamilies.map( ( { fontFamily, name } ) => ( {
key: fontFamily,
name: name || fontFamily,
style: { fontFamily },
} ) ),
];

if ( ! __nextHasNoMarginBottom ) {
Expand All @@ -51,14 +53,12 @@ export default function FontFamilyControl( {
}

return (
<SelectControl
<CustomSelectControl
__next40pxDefaultSize={ __next40pxDefaultSize }
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
label={ __( 'Font' ) }
options={ options }
value={ value }
onChange={ onChange }
labelPosition="top"
onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
options={ options }
{ ...props }
/>
);
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/specs/site-editor/font-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ test.describe( 'Font Library', () => {
await page
.getByRole( 'button', { name: 'Headings', exact: true } )
.click();
await page.getByLabel( 'Font' ).selectOption( 'Exo 2' );
await page.getByRole( 'combobox', { name: 'Font' } ).click();
await page.getByRole( 'option', { name: 'Exo 2' } ).click();
await expect(
editor.canvas.locator( '.is-root-container h1' )
).toHaveCSS( 'font-family', '"Exo 2"' );
Expand Down
Loading