From e2142c3e6a7562ef9e9e059f8c85a9c6791212f6 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:45:14 +0900 Subject: [PATCH] Font Library: Convert heading text to heading elements and group fonts as a list (#58834) * temp * Font Library: Convert heading text to heading elements and group fonts as a list Co-authored-by: t-hamano Co-authored-by: afercia Co-authored-by: colorful-tones Co-authored-by: jasmussen Co-authored-by: annezazu --- .../font-library-modal/font-collection.js | 43 ++++-- .../font-library-modal/installed-fonts.js | 136 +++++++++++------- .../font-library-modal/style.scss | 17 +++ .../specs/site-editor/font-library.spec.js | 2 +- 4 files changed, 131 insertions(+), 67 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js index 1a1853ac62a381..7d89a92cb44bac 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/font-collection.js @@ -332,18 +332,37 @@ function FontCollection( { slug } ) { ) }
- { items.map( ( font ) => ( - { - setSelectedFont( - font.font_family_settings - ); - } } - /> - ) ) } + { /* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ + /* eslint-disable jsx-a11y/no-redundant-roles */ } +
    + { items.map( ( font ) => ( +
  • + { + setSelectedFont( + font.font_family_settings + ); + } } + /> +
  • + ) ) } +
+ { /* eslint-enable jsx-a11y/no-redundant-roles */ }{ ' ' }
diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index b33bb1b639d000..cdc81aa09b7373 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -126,66 +126,94 @@ function InstalledFonts() { } > - { notice && ( - <> - + + { notice && ( setNotice( null ) } > { notice.message } - - - ) } - { baseCustomFonts.length > 0 && ( - <> - - { __( 'Installed Fonts' ) } - - - { baseCustomFonts.map( ( font ) => ( - { - handleSetLibraryFontSelected( - font - ); - } } - /> - ) ) } - - - ) } - - { baseThemeFonts.length > 0 && ( - <> - - { __( 'Theme Fonts' ) } - - - { baseThemeFonts.map( ( font ) => ( - { - handleSetLibraryFontSelected( - font - ); - } } - /> - ) ) } - - ) } + ) } + { baseCustomFonts.length > 0 && ( + +

+ { __( 'Installed Fonts' ) } +

+ { /* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ + /* eslint-disable jsx-a11y/no-redundant-roles */ } +
    + { baseCustomFonts.map( ( font ) => ( +
  • + { + handleSetLibraryFontSelected( + font + ); + } } + /> +
  • + ) ) } +
+ { /* eslint-enable jsx-a11y/no-redundant-roles */ } +
+ ) } + { baseThemeFonts.length > 0 && ( + +

+ { __( 'Theme Fonts' ) } +

+ { /* + * Disable reason: The `list` ARIA role is redundant but + * Safari+VoiceOver won't announce the list otherwise. + */ + /* eslint-disable jsx-a11y/no-redundant-roles */ } +
    + { baseThemeFonts.map( ( font ) => ( +
  • + { + handleSetLibraryFontSelected( + font + ); + } } + /> +
  • + ) ) } +
+ { /* eslint-enable jsx-a11y/no-redundant-roles */ } +
+ ) } +
diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/style.scss b/packages/edit-site/src/components/global-styles/font-library-modal/style.scss index 201d4d87a3fb16..fb87f6fae505a4 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/style.scss +++ b/packages/edit-site/src/components/global-styles/font-library-modal/style.scss @@ -66,6 +66,23 @@ $footer-height: 70px; margin-bottom: 0; } +.font-library-modal__fonts-title { + text-transform: uppercase; + font-size: 11px; + font-weight: 600; + margin-top: 0; + margin-bottom: 0; +} + +.font-library-modal__fonts-list { + margin-top: 0; + margin-bottom: 0; +} + +.font-library-modal__fonts-list-item { + margin-bottom: 0; +} + .font-library-modal__font-card { border: 1px solid $gray-200; width: 100%; diff --git a/test/e2e/specs/site-editor/font-library.spec.js b/test/e2e/specs/site-editor/font-library.spec.js index 986b400c0d6e5a..2601f66b3e0787 100644 --- a/test/e2e/specs/site-editor/font-library.spec.js +++ b/test/e2e/specs/site-editor/font-library.spec.js @@ -61,7 +61,7 @@ test.describe( 'Font Library', () => { .click(); await expect( page.getByRole( 'dialog' ) ).toBeVisible(); await expect( - page.getByRole( 'heading', { name: 'Fonts' } ) + page.getByRole( 'heading', { name: 'Fonts', exact: true } ) ).toBeVisible(); } );