Skip to content

Conversation

@johnhooks
Copy link
Collaborator

@johnhooks johnhooks commented Apr 26, 2023

What?

Render the bell icon on the server.

Why?

The bell icon would appear after the JavaScript loaded and cause the icon to jump on every page transition.

How?

@erikyo helped me with the code required to render the bell in the admin bar.

TODO

  • The bell icon initially renders a little high and adjusts once the React component is rendered. Some style that is applied on the client isn't in the PHP code.

@johnhooks johnhooks requested a review from erikyo April 26, 2023 02:05
@johnhooks johnhooks self-assigned this Apr 26, 2023
@johnhooks johnhooks force-pushed the refactor/bell-icon branch 2 times, most recently from c674bac to 3b47950 Compare April 26, 2023 20:47
@johnhooks johnhooks force-pushed the refactor/bell-icon branch from 3b47950 to 289896f Compare April 26, 2023 20:49
Comment on lines 66 to 83
<div className="ab-item ab-empty-item" tabIndex={ 0 }>
<ShortcutProvider
className={ classNames( [
'notifications',
isActive ? 'active' : '',
] ) }
>
<NotificationHubIcon
toggle={ toggleDrawer }
isActive={ isActive }
/>
<Drawer
instance={ drawerRef }
focus={ () => setIsActive( true ) }
blur={ () => setIsActive( false ) }
/>
</ShortcutProvider>
</div>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wrapping this in div.ab-item.ab-empty-item creates the same HTML structure as WordPress creates for the menu item.


/* the bell icon */
.ab-item {
.hub-icon {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changing this name to reflect it's purpose, and the case ab-item has been moved up higher in the DOM structure.

appearance: none;
height: 32px;
display: block;
padding: 0 10px;
Copy link
Collaborator Author

@johnhooks johnhooks Apr 26, 2023

Choose a reason for hiding this comment

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

The ab-empty-item class provides the padding. The ab-empty-item class is applied to menu items that do not have a link.

@johnhooks johnhooks force-pushed the refactor/bell-icon branch from 0291fab to 5b9f64e Compare April 27, 2023 10:53
Copy link
Collaborator

@erikyo erikyo left a comment

Choose a reason for hiding this comment

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

LGTM!

@johnhooks johnhooks merged commit c0e4ef0 into WordPress:develop Apr 27, 2023
@johnhooks johnhooks deleted the refactor/bell-icon branch April 27, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants