PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.9.0
GenerateBlocks v1.9.0
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 2 years ago editor.scss 2 years ago index.js 2 years ago utils.js 2 years ago
index.js
55 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 closeModal={ () => setIsOpen( false ) } />
43 </LibraryProvider>
44 </Modal>
45 ) }
46 </>
47 );
48 }
49
50 addFilter(
51 'generateblocks.editor.sidebar',
52 'generateblocks/pattern-library',
53 PatternLibrary
54 );
55