@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
39 lines (36 loc) • 992 B
JavaScript
import { createElement } from "@wordpress/element";
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { CheckboxControl } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
/**
* Internal dependencies
*/
import PostStickyCheck from './check';
export function PostSticky({
onUpdateSticky,
postSticky = false
}) {
return createElement(PostStickyCheck, null, createElement(CheckboxControl, {
label: __('Stick to the top of the blog'),
checked: postSticky,
onChange: () => onUpdateSticky(!postSticky)
}));
}
export default compose([withSelect(select => {
return {
postSticky: select('core/editor').getEditedPostAttribute('sticky')
};
}), withDispatch(dispatch => {
return {
onUpdateSticky(postSticky) {
dispatch('core/editor').editPost({
sticky: postSticky
});
}
};
})])(PostSticky);
//# sourceMappingURL=index.js.map