PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.2
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / pattern-library / index.js
generateblocks / src / pattern-library Last commit date
components 1 year ago editor.scss 1 year ago index.js 1 year ago utils.js 2 years ago
index.js
58 lines
1 import { Button, Modal, PanelBody } from '@wordpress/components';
2 import { useState } from '@wordpress/element';
3 import { LibraryProvider } from './components/library-provider';
4 import LibraryLayout from './components/library-layout';
5 import { addFilter } from '@wordpress/hooks';
6 import { __ } from '@wordpress/i18n';
7 import './editor.scss';
8
9 function PatternLibrary( content, { activePanel } ) {
10 const [ isOpen, setIsOpen ] = useState( false );
11
12 if ( activePanel ) {
13 return content;
14 }
15
16 return (
17 <>
18 <PanelBody>
19 <h2 className="gblocks-editor-sidebar__panel-title">
20 { __( 'Pattern Library', 'generateblocks' ) }
21 </h2>
22
23 <Button
24 className="gblocks-pattern-library-button"
25 variant="secondary"
26 onClick={ () => setIsOpen( true ) }
27 isPressed={ isOpen }
28 >
29 { __( 'Open Pattern Library', 'generateblocks' ) }
30 </Button>
31 </PanelBody>
32
33 { content }
34
35 { !! isOpen && (
36 <Modal
37 className="gblocks-pattern-library-modal"
38 isFullScreen
39 onRequestClose={ () => setIsOpen( false ) }
40 >
41 <LibraryProvider>
42 <LibraryLayout
43 closeModal={ () => setIsOpen( false ) }
44 readOnly={ false }
45 />
46 </LibraryProvider>
47 </Modal>
48 ) }
49 </>
50 );
51 }
52
53 addFilter(
54 'generateblocks.editor.sidebar',
55 'generateblocks/pattern-library',
56 PatternLibrary
57 );
58