Skip to content

Commit

Permalink
Revert the manage fonts button. (WordPress#66107)
Browse files Browse the repository at this point in the history
Co-authored-by: ndiego <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: kevin940726 <[email protected]>
Co-authored-by: afercia <[email protected]>
Co-authored-by: carolinan <[email protected]>
Co-authored-by: colorful-tones <[email protected]>
Co-authored-by: richtabor <[email protected]>
  • Loading branch information
8 people authored Oct 15, 2024
1 parent 43417f3 commit 98f3f6a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
51 changes: 30 additions & 21 deletions packages/edit-site/src/components/global-styles/font-families.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {
__experimentalText as Text,
__experimentalItemGroup as ItemGroup,
__experimentalVStack as VStack,
__experimentalHStack as HStack,
Button,
} from '@wordpress/components';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import { settings } from '@wordpress/icons';
import { useContext } from '@wordpress/element';

/**
Expand Down Expand Up @@ -67,10 +69,18 @@ function FontFamilies() {
/>
) }

<VStack spacing={ 4 }>
<VStack spacing={ 2 }>
<HStack justify="space-between">
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
<Button
onClick={ () => setModalTabOpen( 'installed-fonts' ) }
label={ __( 'Manage fonts' ) }
icon={ settings }
size="small"
/>
</HStack>
{ activeFonts.length > 0 && (
<>
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
<ItemGroup size="large" isBordered isSeparated>
{ activeFonts.map( ( font ) => (
<FontFamilyItem
Expand All @@ -82,31 +92,30 @@ function FontFamilies() {
</>
) }
{ ! hasFonts && (
<VStack>
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
<>
<Text as="p">
{ hasInstalledFonts
? __( 'No fonts activated.' )
: __( 'No fonts installed.' ) }
</Text>
</VStack>
<Button
className="edit-site-global-styles-font-families__manage-fonts"
variant="secondary"
__next40pxDefaultSize
onClick={ () => {
setModalTabOpen(
hasInstalledFonts
? 'installed-fonts'
: 'upload-fonts'
);
} }
>
{ hasInstalledFonts
? __( 'Manage fonts' )
: __( 'Add fonts' ) }
</Button>
</>
) }
<Button
className="edit-site-global-styles-font-families__manage-fonts"
variant="secondary"
__next40pxDefaultSize
onClick={ () => {
setModalTabOpen(
hasInstalledFonts
? 'installed-fonts'
: 'upload-fonts'
);
} }
>
{ hasInstalledFonts
? __( 'Manage fonts' )
: __( 'Add fonts' ) }
</Button>
</VStack>
</>
);
Expand Down
18 changes: 8 additions & 10 deletions test/e2e/specs/site-editor/font-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ test.describe( 'Font Library', () => {
).toBeVisible();
} );

test( 'should display the "Add fonts" button', async ( { page } ) => {
test( 'should display the "Manage fonts" icon', async ( { page } ) => {
await page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Styles' } )
.click();
await page
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
const addFontsButton = page.getByRole( 'button', {
name: 'Add fonts',
const manageFontsIcon = page.getByRole( 'button', {
name: 'Manage fonts',
} );
await expect( addFontsButton ).toBeVisible();
await expect( manageFontsIcon ).toBeVisible();
} );
} );

Expand All @@ -66,23 +66,21 @@ test.describe( 'Font Library', () => {
} );
} );

test( 'should display the "Manage fonts" button', async ( {
page,
} ) => {
test( 'should display the "Manage fonts" icon', async ( { page } ) => {
await page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Styles' } )
.click();
await page
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
const manageFontsButton = page.getByRole( 'button', {
const manageFontsIcon = page.getByRole( 'button', {
name: 'Manage fonts',
} );
await expect( manageFontsButton ).toBeVisible();
await expect( manageFontsIcon ).toBeVisible();
} );

test( 'should open the "Manage fonts" modal when clicking the "Manage fonts" button', async ( {
test( 'should open the "Manage fonts" modal when clicking the "Manage fonts" icon', async ( {
page,
} ) => {
await page
Expand Down

0 comments on commit 98f3f6a

Please sign in to comment.