-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block warning: add ellipsis menu and convert to classic block #7741
Changes from 3 commits
01852be
09fc65a
41c6a45
2d7533a
2374f05
e1623e7
29153d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,23 +7,53 @@ import classnames from 'classnames'; | |
* WordPress dependencies | ||
*/ | ||
import { Children } from '@wordpress/element'; | ||
import { Dropdown, IconButton, MenuGroup, MenuItem } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
function Warning( { className, actions, children } ) { | ||
function Warning( { className, primaryActions, children, hiddenActions } ) { | ||
return ( | ||
<div className={ classnames( className, 'editor-warning' ) }> | ||
<div className="editor-warning__contents"> | ||
<p className="editor-warning__message">{ children }</p> | ||
|
||
{ Children.count( actions ) > 0 && ( | ||
{ Children.count( primaryActions ) > 0 && ( | ||
<div className="editor-warning__actions"> | ||
{ Children.map( actions, ( action, i ) => ( | ||
{ Children.map( primaryActions, ( action, i ) => ( | ||
<span key={ i } className="editor-warning__action"> | ||
{ action } | ||
</span> | ||
) ) } | ||
</div> | ||
) } | ||
</div> | ||
|
||
{ hiddenActions && ( | ||
<div className="editor-warning__hidden"> | ||
<Dropdown | ||
className="edit-post-more-menu" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same class used in https://github.com/WordPress/gutenberg/blob/master/edit-post/components/header/more-menu/index.js, making the ellipsis vertical rather than horizontal. I can file a separate issue if that also needs changing to match the guidelines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should rely on classnames styled in other components. We should aim to reuse components instead of classnames instead. So two options:
|
||
position="bottom left" | ||
renderToggle={ ( { isOpen, onToggle } ) => ( | ||
<IconButton | ||
icon="ellipsis" | ||
label={ __( 'More options' ) } | ||
onClick={ onToggle } | ||
aria-expanded={ isOpen } | ||
/> | ||
) } | ||
renderContent={ () => ( | ||
<div className="edit-post-more-menu__content"> | ||
<MenuGroup label={ __( 'More options' ) }> | ||
{ hiddenActions.map( ( item, pos ) => | ||
<MenuItem onClick={ item.onClick } key={ pos }> | ||
{ item.title } | ||
</MenuItem> | ||
) } | ||
</MenuGroup> | ||
</div> | ||
) } | ||
/> | ||
</div> | ||
) } | ||
</div> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,8 @@ | |
margin: 0 6px 0 0; | ||
margin-left: 0; | ||
} | ||
|
||
.editor-warning__hidden { | ||
margin-top: 3px; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be secondaryActions (to match the "primaryActions" prop)?