add-library.js
2 years ago
category-list.js
1 year ago
insert-pattern.js
2 years ago
library-cache.js
2 years ago
library-layout.js
1 year ago
library-provider.js
2 years ago
library-selector.js
1 year ago
manage-libraries.js
2 years ago
pattern-details-header.js
1 year ago
pattern-details.js
1 year ago
pattern-list.js
1 year ago
pattern-search.js
2 years ago
pattern.js
1 year ago
selected-patterns.js
1 year ago
add-library.js
46 lines
| 1 | import { Button, Modal } from '@wordpress/components'; |
| 2 | import { useState } from '@wordpress/element'; |
| 3 | import { __ } from '@wordpress/i18n'; |
| 4 | import { plus } from '@wordpress/icons'; |
| 5 | import { applyFilters } from '@wordpress/hooks'; |
| 6 | import { useLibrary } from './library-provider'; |
| 7 | |
| 8 | function DefaultMessage( { setShowAddLibrary, setLibraries } ) { |
| 9 | const content = ( |
| 10 | <> |
| 11 | <p>{ __( 'This feature requires GenerateBlocks Pro.', 'generateblocks' ) }</p> |
| 12 | </> |
| 13 | ); |
| 14 | |
| 15 | return applyFilters( 'generateblocks.patternLibrary.addLibraryContent', content, { setShowAddLibrary, setLibraries } ); |
| 16 | } |
| 17 | |
| 18 | export default function AddLibrary() { |
| 19 | const [ showAddLibrary, setShowAddLibrary ] = useState( false ); |
| 20 | const { setLibraries } = useLibrary(); |
| 21 | |
| 22 | return ( |
| 23 | <> |
| 24 | <Button |
| 25 | variant="secondary" |
| 26 | icon={ plus } |
| 27 | onClick={ () => setShowAddLibrary( true ) } |
| 28 | label={ __( 'Add Library', 'generateblocks' ) } |
| 29 | /> |
| 30 | |
| 31 | { !! showAddLibrary && |
| 32 | <Modal |
| 33 | title={ __( 'Add Library', 'generateblocks' ) } |
| 34 | onRequestClose={ () => setShowAddLibrary( false ) } |
| 35 | className="gblocks-patterns-add-library" |
| 36 | > |
| 37 | <DefaultMessage |
| 38 | setShowAddLibrary={ setShowAddLibrary } |
| 39 | setLibraries={ setLibraries } |
| 40 | /> |
| 41 | </Modal> |
| 42 | } |
| 43 | </> |
| 44 | ); |
| 45 | } |
| 46 |