-
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
Show transforms as a vertical list #23028
Merged
ellatrix
merged 34 commits into
WordPress:master
from
ntsekouras:fix/show-transforms-as-vertical-list
Jun 22, 2020
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
19374c2
Move Styles below transform options.
ntsekouras 0aab098
revert preview in BlockStyles as they are reused
ntsekouras d6b93ab
Hide BlockStyles preview only from BlockTypes list.
ntsekouras 577cfd2
Change BlockStyles position next to style options
ntsekouras 8af59ea
Show Preview styles properly and on smaller viewports.
ntsekouras 298275b
Add line break
ntsekouras 8f11e28
Revert changes from other blocks and override in Block Switcher
ntsekouras baa6541
Add arrow navigation to blocks and BlockStyles
ntsekouras 2a64cfe
Push a little polish.
jasmussen c9339fe
Fix scrolling window on arrow navigation
ntsekouras fc42b4b
Destructure items' properties
ntsekouras 08e3b22
Fix aria role related e2e tests
ntsekouras a958a9e
reverse destructuring
ntsekouras 6e092ff
Use DropdownMenu instead of Dropdown.
ntsekouras 92fa685
Add class property to support the override styles with DropdownMenu
ntsekouras 37ac84e
Add role attribute support for BlockStyleItem
ntsekouras a195fee
Add Preview to a Popover component.
ntsekouras 2b44bf9
Added container elements to change Preview Popover position.
ntsekouras 189b35a
Introduce 'skipchildrenfocus' attribute to Focusable.
ntsekouras 938e1ef
Add filter for tabindex -1 in focusable
ntsekouras 22f4141
revert BlockTypesList and remove extra role attribute
ntsekouras 3101ccd
add the Styles Preview popover
ntsekouras 7d7e864
Hide popover on mobile + move styles on top
ntsekouras adb4ed2
Add labels to MenuGroups
ntsekouras 8273999
Wrap icon with BlockIcon
ntsekouras 83045c3
minor Firefox style fix
ntsekouras c8ac83c
Rename BlockStyles role to itemRole
ntsekouras af166a7
turn PreviewBlockPopover to function component
ntsekouras b56c05d
Fix BlockSwitcher tests
ntsekouras 0da2829
Adjust outer block with new Popover functionality
ntsekouras a64b44e
make skipFocus function more specific to our use case.
ntsekouras 0cbba47
use toLowerCase fn
ntsekouras 50cf323
fix BlockSwitcher e2e tests
ntsekouras 2a2b2c8
add block menu default class + fix toolbar roving tabindex e2e tests
ntsekouras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,5 +53,5 @@ | |
|
||
.block-editor-block-styles__item-label { | ||
text-align: center; | ||
padding: 4px 2px; | ||
padding: 4px 0; | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/block-editor/src/components/block-switcher/block-transformations-menu.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { MenuGroup, MenuItem } from '@wordpress/components'; | ||
import { getBlockMenuDefaultClassName } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockIcon from '../block-icon'; | ||
|
||
const BlockTransformationsMenu = ( { | ||
className, | ||
possibleBlockTransformations, | ||
onSelect, | ||
} ) => { | ||
return ( | ||
<MenuGroup label={ __( 'Transform to' ) } className={ className }> | ||
{ possibleBlockTransformations.map( ( item ) => { | ||
const { name, icon, title } = item; | ||
return ( | ||
<MenuItem | ||
key={ name } | ||
className={ getBlockMenuDefaultClassName( name ) } | ||
icon={ <BlockIcon icon={ icon } showColors /> } | ||
onClick={ ( event ) => { | ||
event.preventDefault(); | ||
onSelect( name ); | ||
} } | ||
> | ||
{ title } | ||
</MenuItem> | ||
); | ||
} ) } | ||
</MenuGroup> | ||
); | ||
}; | ||
|
||
export default BlockTransformationsMenu; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this class necessary here?
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.
This class is used in
BlockTypesList
( it was used before ). I came across some failing e2e tests that were using thetransform
functionality and this class seemed a good idea to preserve, as it might be used by other e2e tests in the future.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.
I don’t think that e2e test should shape production code, and I’m sure you can use accessible labels to achieve the same result as block names are unique. It isn’t a big issue but if we can remove unused code with little effort we should always aim for it.
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.
I definitely agree with this!
In this specific case though (
MenuItem
) there is not any accessible labels to match, besides the content itself.MenuItem
has an info property but this would end up adding stuff again.So, would it be preferable to search through the content?
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.
Well, the content is the accessible label, this is what is going to be announced when users depend on screen readers. By using this approach, we also ensure that UI is accessible. It's harder to target elements by content, but there are many existing tests that do it.