Skip to content

Admin UI: Add logo prop to Page header component#76469

Open
CGastrell wants to merge 7 commits intoWordPress:trunkfrom
CGastrell:add/page-header-logo
Open

Admin UI: Add logo prop to Page header component#76469
CGastrell wants to merge 7 commits intoWordPress:trunkfrom
CGastrell:add/page-header-logo

Conversation

@CGastrell
Copy link
Contributor

@CGastrell CGastrell commented Mar 12, 2026

What?

Adds a logo prop to the Page component's header, allowing consumers to display a logo or symbol alongside the title or breadcrumbs.

See #76448

Note: This PR depends on #76467 (Storybook stories for admin-ui). The story files in this diff include both the base stories from that PR and the new logo stories. The implementation changes are in header.tsx, index.tsx, and style.scss.

image image

Why?

As described in #76448, consumers currently pass logos inside the title prop, which places them inside the h2 tag. This is fragile and creates accessibility issues — when the title contains non-text content, a separate ariaLabel must be passed to maintain good semantics (see #75898).

An officially supported logo prop renders the logo outside the h2 tag, ensuring:

  • Consistent logo placement across consumers
  • Proper semantic structure (logo is not part of the heading)
  • No need for a separate ariaLabel workaround

How?

  • Added logo?: React.ReactNode prop to Page (index.tsx) and Header (header.tsx)
  • Logo renders before the title/breadcrumbs in the header row, wrapped in a div.admin-ui-page__header-logo
  • Added CSS for the logo container: flex-centered, non-shrinking, with object-fit: contain for img/svg children
  • Added Storybook stories demonstrating the logo with title, with breadcrumbs, and with a Jetpack logo

Testing Instructions

  1. Run npm run storybook:dev
  2. Navigate to Admin UI > Page in the sidebar
  3. Check the following stories:
    • With Logo: globe icon + "Page title" heading
    • With Jetpack Logo: Jetpack icon + "Jetpack" heading
    • With Logo And Breadcrumbs: globe icon + breadcrumb navigation
    • With Jetpack Logo And Breadcrumbs: Jetpack icon + breadcrumb navigation
  4. Verify the logo appears to the left of the title/breadcrumbs
  5. Inspect the DOM — the logo should be outside the h2 element

Testing Instructions for Keyboard

  1. Tab through the stories — the logo container should not be focusable (it's decorative
  2. The heading and breadcrumb links should remain keyboard accessible
    EOF
    )

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 12, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: CGastrell <cgastrell@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@simison
Copy link
Member

simison commented Mar 13, 2026

Thinking if icon as prop name would be more aligned with other components (e.g. button)

defaultNotFoundComponent: () => null,
} );

const JetpackLogo = ( {
Copy link
Member

@simison simison Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's swap this to something neutral please, AcmeLogo or just W or globe icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, I thought it could come in handy to have it there. We can stick to WordPress icon.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CGastrell CGastrell force-pushed the add/page-header-logo branch from 94549b1 to e40fd17 Compare March 13, 2026 13:51
Move admin-ui stylesheet loading from direct imports in story files
to the storybook/package-styles config system for proper isolation,
dependency management, and RTL support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CGastrell CGastrell force-pushed the add/page-header-logo branch from 97ed4ef to 4bbd77c Compare March 13, 2026 15:41
CGastrell and others added 4 commits March 13, 2026 12:47
ThemeProvider is not needed since styles are loaded via the
package-styles config system.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace custom GlobeLogo SVG with the WordPress icon from @wordpress/icons
and remove the image-based logo story that didn't render well.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename the Page header logo prop to icon for consistency. Remove the
JetpackLogo component and its stories as brand logos don't belong in
the component library. Rename CSS class accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CGastrell CGastrell force-pushed the add/page-header-logo branch from 4bbd77c to afba908 Compare March 13, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants