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 6 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 @@
await page
.getByRole( 'button', { name: 'Headings', exact: true } )
.click();
await page.getByLabel( 'Font' ).selectOption( 'Exo 2' );
await page.getByRole( 'button', { name: 'Font' } ).click();

Check failure on line 189 in test/e2e/specs/site-editor/font-library.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 5

[chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files

1) [chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('button', { name: 'Font' }) 187 | .getByRole( 'button', { name: 'Headings', exact: true } ) 188 | .click(); > 189 | await page.getByRole( 'button', { name: 'Font' } ).click(); | ^ 190 | await page.getByRole( 'option', { name: 'Exo 2' } ).click(); 191 | await expect( 192 | editor.canvas.locator( '.is-root-container h1' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/font-library.spec.js:189:55

Check failure on line 189 in test/e2e/specs/site-editor/font-library.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 5

[chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files

1) [chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('button', { name: 'Font' }) 187 | .getByRole( 'button', { name: 'Headings', exact: true } ) 188 | .click(); > 189 | await page.getByRole( 'button', { name: 'Font' } ).click(); | ^ 190 | await page.getByRole( 'option', { name: 'Exo 2' } ).click(); 191 | await expect( 192 | editor.canvas.locator( '.is-root-container h1' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/font-library.spec.js:189:55

Check failure on line 189 in test/e2e/specs/site-editor/font-library.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 5

[chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files

1) [chromium] › site-editor/font-library.spec.js:145:3 › Font Library › When a user manages custom fonts via the UI › should allow user to add and remove multiple local font files Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('button', { name: 'Font' }) 187 | .getByRole( 'button', { name: 'Headings', exact: true } ) 188 | .click(); > 189 | await page.getByRole( 'button', { name: 'Font' } ).click(); | ^ 190 | await page.getByRole( 'option', { name: 'Exo 2' } ).click(); 191 | await expect( 192 | editor.canvas.locator( '.is-root-container h1' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/font-library.spec.js:189:55
matiasbenedetto marked this conversation as resolved.
Show resolved Hide resolved
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