UNPKG

@wordpress/editor

Version:
8 lines (7 loc) 1.69 kB
{ "version": 3, "sources": ["../../../src/components/post-sticky/index.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog.' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"], "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,aAAa,iBAAiB;AAKvC,OAAO,qBAAqB;AAC5B,SAAS,SAAS,mBAAmB;AAiBlC;AAVY,SAAR,aAA8B;AACpC,QAAM,aAAa,UAAW,CAAE,WAAY;AAC3C,WACC,OAAQ,WAAY,EAAE,uBAAwB,QAAS,KAAK;AAAA,EAE9D,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,SAAS,IAAI,YAAa,WAAY;AAE9C,SACC,oBAAC,mBACA;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,QAAS;AAAA,MACrB,MAAO,GAAI,uCAAwC;AAAA,MACnD,SAAU;AAAA,MACV,UAAW,MAAM,SAAU,EAAE,QAAQ,CAAE,WAAW,CAAE;AAAA;AAAA,EACrD,GACD;AAEF;", "names": [] }