From fa72c95eeab8351892bbbf56a6052acd77aa7d9b Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sat, 27 Apr 2024 12:13:21 +0900 Subject: [PATCH 1/2] temp --- .../font-library-modal/font-collection.js | 43 +++++-- .../font-library-modal/installed-fonts.js | 113 +++++++++++------- .../font-library-modal/style.scss | 19 ++- 3 files changed, 121 insertions(+), 54 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..6f54c08ac9e123 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 @@ -139,52 +139,83 @@ function InstalledFonts() { ) } { baseCustomFonts.length > 0 && ( - <> - + +

{ __( 'Installed Fonts' ) } - - - { baseCustomFonts.map( ( font ) => ( - { - handleSetLibraryFontSelected( - font - ); - } } - /> - ) ) } - - +

+ { /* + * 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' ) } - - - { baseThemeFonts.map( ( font ) => ( - { - handleSetLibraryFontSelected( - font - ); - } } - /> - ) ) } - +

+ { /* + * 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..01ee16911189f4 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,12 +66,29 @@ $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-top: -1px; /* To collapse the margin with the previous element */ + margin-bottom: 0; +} + .font-library-modal__font-card { border: 1px solid $gray-200; width: 100%; height: auto; padding: $grid-unit-20; - margin-top: -1px; /* To collapse the margin with the previous element */ &:hover { background-color: $gray-100; From 31fc51cfea8e270caeff198bd2ce79443dc0571b Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sat, 27 Apr 2024 12:40:45 +0900 Subject: [PATCH 2/2] Font Library: Convert heading text to heading elements and group fonts as a list --- .../font-library-modal/installed-fonts.js | 163 +++++++++--------- .../font-library-modal/style.scss | 2 +- .../specs/site-editor/font-library.spec.js | 2 +- 3 files changed, 82 insertions(+), 85 deletions(-) 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 6f54c08ac9e123..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,97 +126,94 @@ function InstalledFonts() { } > - { notice && ( - <> - + + { notice && ( setNotice( null ) } > { notice.message } - - - ) } - { 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( + ) } + { 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 ) => ( +
    • + -
    • - ) ) } -
    - { /* 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( + ) } + onClick={ () => { + 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 ) => ( +
    • + -
    • - ) ) } -
    - { /* eslint-enable jsx-a11y/no-redundant-roles */ } -
    - ) } + ) } + onClick={ () => { + 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 01ee16911189f4..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 @@ -80,7 +80,6 @@ $footer-height: 70px; } .font-library-modal__fonts-list-item { - margin-top: -1px; /* To collapse the margin with the previous element */ margin-bottom: 0; } @@ -89,6 +88,7 @@ $footer-height: 70px; width: 100%; height: auto; padding: $grid-unit-20; + margin-top: -1px; /* To collapse the margin with the previous element */ &:hover { background-color: $gray-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(); } );