Skip to content

Commit 8d99dcf

Browse files
aferciat-hamanojameskosterrichtaborcolorful-tones
authored
Make the fonts management modal dialog more discoverable (#62129)
* Replace Manage fonts icon button with visible text button. * Fix after rebase. * Male buttons use the next 40 pixels height. Co-authored-by: afercia <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: jameskoster <[email protected]> Co-authored-by: richtabor <[email protected]> Co-authored-by: colorful-tones <[email protected]> Co-authored-by: noisysocks <[email protected]> Co-authored-by: annezazu <[email protected]>
1 parent 73a9d35 commit 8d99dcf

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

packages/edit-site/src/components/global-styles/font-families.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import { __ } from '@wordpress/i18n';
55
import {
66
__experimentalItemGroup as ItemGroup,
77
__experimentalVStack as VStack,
8-
__experimentalHStack as HStack,
98
Button,
109
} from '@wordpress/components';
1110
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
12-
import { settings } from '@wordpress/icons';
1311
import { useContext } from '@wordpress/element';
1412

1513
/**
@@ -51,30 +49,41 @@ function FontFamilies() {
5149
) }
5250

5351
<VStack spacing={ 2 }>
54-
<HStack justify="space-between">
55-
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
56-
<Button
57-
onClick={ () => setModalTabOpen( 'installed-fonts' ) }
58-
label={ __( 'Manage fonts' ) }
59-
icon={ settings }
60-
size="small"
61-
/>
62-
</HStack>
52+
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
6353
{ hasFonts ? (
64-
<ItemGroup isBordered isSeparated>
65-
{ customFonts.map( ( font ) => (
66-
<FontFamilyItem key={ font.slug } font={ font } />
67-
) ) }
68-
{ themeFonts.map( ( font ) => (
69-
<FontFamilyItem key={ font.slug } font={ font } />
70-
) ) }
71-
</ItemGroup>
54+
<>
55+
<ItemGroup isBordered isSeparated>
56+
{ customFonts.map( ( font ) => (
57+
<FontFamilyItem
58+
key={ font.slug }
59+
font={ font }
60+
/>
61+
) ) }
62+
{ themeFonts.map( ( font ) => (
63+
<FontFamilyItem
64+
key={ font.slug }
65+
font={ font }
66+
/>
67+
) ) }
68+
</ItemGroup>
69+
<Button
70+
className="edit-site-global-styles-font-families__manage-fonts"
71+
variant="secondary"
72+
__next40pxDefaultSize
73+
onClick={ () =>
74+
setModalTabOpen( 'installed-fonts' )
75+
}
76+
>
77+
{ __( 'Manage fonts' ) }
78+
</Button>
79+
</>
7280
) : (
7381
<>
7482
{ __( 'No fonts installed.' ) }
7583
<Button
7684
className="edit-site-global-styles-font-families__add-fonts"
7785
variant="secondary"
86+
__next40pxDefaultSize
7887
onClick={ () => setModalTabOpen( 'upload-fonts' ) }
7988
>
8089
{ __( 'Add fonts' ) }

packages/edit-site/src/components/global-styles/style.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
color: $gray-700;
4242
}
4343

44-
.edit-site-global-styles-font-families__add-fonts {
44+
.edit-site-global-styles-font-families__add-fonts,
45+
.edit-site-global-styles-font-families__manage-fonts {
4546
justify-content: center;
4647
}
4748

test/e2e/specs/site-editor/font-library.spec.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ test.describe( 'Font Library', () => {
1414
await editor.canvas.locator( 'body' ).click();
1515
} );
1616

17-
test( 'should display the "Manage Fonts" icon', async ( { page } ) => {
17+
test( 'should display the "Add fonts" button', async ( { page } ) => {
1818
await page.getByRole( 'button', { name: 'Styles' } ).click();
1919
await page
2020
.getByRole( 'button', { name: 'Typography Styles' } )
2121
.click();
22-
const manageFontsIcon = page.getByRole( 'button', {
23-
name: 'Manage Fonts',
22+
const addFontsButton = page.getByRole( 'button', {
23+
name: 'Add fonts',
2424
} );
25-
await expect( manageFontsIcon ).toBeVisible();
25+
await expect( addFontsButton ).toBeVisible();
2626
} );
2727
} );
2828

@@ -36,18 +36,20 @@ test.describe( 'Font Library', () => {
3636
await editor.canvas.locator( 'body' ).click();
3737
} );
3838

39-
test( 'should display the "Manage Fonts" icon', async ( { page } ) => {
39+
test( 'should display the "Manage fonts" button', async ( {
40+
page,
41+
} ) => {
4042
await page.getByRole( 'button', { name: 'Styles' } ).click();
4143
await page
4244
.getByRole( 'button', { name: 'Typography Styles' } )
4345
.click();
44-
const manageFontsIcon = page.getByRole( 'button', {
45-
name: 'Manage Fonts',
46+
const manageFontsButton = page.getByRole( 'button', {
47+
name: 'Manage fonts',
4648
} );
47-
await expect( manageFontsIcon ).toBeVisible();
49+
await expect( manageFontsButton ).toBeVisible();
4850
} );
4951

50-
test( 'should open the "Manage Fonts" modal when clicking the "Manage Fonts" icon', async ( {
52+
test( 'should open the "Manage fonts" modal when clicking the "Manage fonts" button', async ( {
5153
page,
5254
} ) => {
5355
await page.getByRole( 'button', { name: 'Styles' } ).click();
@@ -56,7 +58,7 @@ test.describe( 'Font Library', () => {
5658
.click();
5759
await page
5860
.getByRole( 'button', {
59-
name: 'Manage Fonts',
61+
name: 'Manage fonts',
6062
} )
6163
.click();
6264
await expect( page.getByRole( 'dialog' ) ).toBeVisible();
@@ -74,7 +76,7 @@ test.describe( 'Font Library', () => {
7476
.click();
7577
await page
7678
.getByRole( 'button', {
77-
name: 'Manage Fonts',
79+
name: 'Manage fonts',
7880
} )
7981
.click();
8082
await page.getByRole( 'button', { name: 'System Font' } ).click();
@@ -120,12 +122,11 @@ test.describe( 'Font Library', () => {
120122
.click();
121123
await page
122124
.getByRole( 'button', {
123-
name: 'Manage Fonts',
125+
name: 'Add fonts',
124126
} )
125127
.click();
126128

127129
// Upload local fonts.
128-
await page.getByRole( 'tab', { name: 'Upload' } ).click();
129130
const fileChooserPromise = page.waitForEvent( 'filechooser' );
130131
await page.getByRole( 'button', { name: 'Upload Font' } ).click();
131132
const fileChooser = await fileChooserPromise;
@@ -163,7 +164,7 @@ test.describe( 'Font Library', () => {
163164
await page.getByRole( 'button', { name: 'Back' } ).click();
164165
await page
165166
.getByRole( 'button', {
166-
name: 'Manage Fonts',
167+
name: 'Manage fonts',
167168
} )
168169
.click();
169170

0 commit comments

Comments
 (0)