-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Move legacy meta boxes to toggle #59242
Changes from all commits
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 |
---|---|---|
|
@@ -19,9 +19,9 @@ import { | |
privateApis as editorPrivateApis, | ||
} from '@wordpress/editor'; | ||
import { useEffect, useRef, useState } from '@wordpress/element'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { next, previous } from '@wordpress/icons'; | ||
import { next, previous, metabox } from '@wordpress/icons'; | ||
import { PinnedItems } from '@wordpress/interface'; | ||
import { useViewportMatch } from '@wordpress/compose'; | ||
import { | ||
|
@@ -65,6 +65,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { | |
isTextEditor, | ||
blockSelectionStart, | ||
hasActiveMetaboxes, | ||
showMetaBoxes, | ||
isPublishSidebarOpened, | ||
showIconLabels, | ||
hasHistory, | ||
|
@@ -77,6 +78,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { | |
blockSelectionStart: | ||
select( blockEditorStore ).getBlockSelectionStart(), | ||
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), | ||
showMetaBoxes: select( editPostStore ).showMetaBoxes(), | ||
hasHistory: | ||
!! select( editorStore ).getEditorSettings() | ||
.onNavigateToPreviousEntityRecord, | ||
|
@@ -85,6 +87,7 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { | |
showIconLabels: getPreference( 'core', 'showIconLabels' ), | ||
}; | ||
}, [] ); | ||
const { toggleMetaBoxes } = useDispatch( editPostStore ); | ||
|
||
const { showFixedToolbar } = useShowBlockTools(); | ||
const showTopToolbar = isLargeViewport && showFixedToolbar; | ||
|
@@ -189,6 +192,16 @@ function Header( { setEntitiesSavedStatesCallback, initialPost } ) { | |
setEntitiesSavedStatesCallback | ||
} | ||
/> | ||
{ hasActiveMetaboxes && ( | ||
<Button | ||
icon={ metabox } | ||
onClick={ () => { | ||
toggleMetaBoxes(); | ||
} } | ||
label={ __( 'Show meta boxes' ) } | ||
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. As pointed out, I would consider a different label as |
||
isPressed={ showMetaBoxes } | ||
/> | ||
) } | ||
{ ( isWideViewport || ! showIconLabels ) && ( | ||
<PinnedItems.Slot scope="core/edit-post" /> | ||
) } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/primitives'; | ||
|
||
const metabox = ( | ||
<SVG width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<Path | ||
fill-rule="evenodd" | ||
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. When I apply the PR I see a JavaScript warning in the block editor: 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. Ah, thanks you :) |
||
clip-rule="evenodd" | ||
d="M20 14v4c0 1.1-.9 2-2 2H6c-1.1 0-2-.9-2-2v-4h16Zm0-1.5V6c0-1.1-.9-2-2-2H6c-1.1 0-2 .9-2 2v6.5h1.5V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v6.5H20ZM5.5 18c0 .3.2.5.5.5h12c.3 0 .5-.2.5-.5v-2.5h-13V18Z" | ||
/> | ||
</SVG> | ||
); | ||
|
||
export default metabox; |
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.
Will make this private.