UNPKG

@wordpress/editor

Version:
29 lines (25 loc) 807 B
/** * WordPress dependencies */ import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; import { privateApis as preferencesPrivateApis } from '@wordpress/preferences'; /** * Internal dependencies */ import { unlock } from '../../lock-unlock'; import { store as editorStore } from '../../store'; const { PreferenceBaseOption } = unlock( preferencesPrivateApis ); export default compose( withSelect( ( select ) => ( { isChecked: select( editorStore ).isPublishSidebarEnabled(), } ) ), withDispatch( ( dispatch ) => { const { enablePublishSidebar, disablePublishSidebar } = dispatch( editorStore ); return { onChange: ( isEnabled ) => isEnabled ? enablePublishSidebar() : disablePublishSidebar(), }; } ) )( PreferenceBaseOption );