PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.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 / components / library-selector.js
generateblocks / src / pattern-library / components Last commit date
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
library-selector.js
51 lines
1 import { Button, ButtonGroup } from '@wordpress/components';
2 import { applyFilters } from '@wordpress/hooks';
3 import { useLibrary } from './library-provider';
4 import AddLibrary from './add-library';
5
6 export default function LibrarySelector( { readOnly } ) {
7 const {
8 libraries,
9 activeLibrary,
10 setActiveLibrary,
11 setIsLocal,
12 setPublicKey,
13 setActiveCategory,
14 loading,
15 } = useLibrary();
16
17 const visibleLibraries = applyFilters(
18 'generateblocks.patternLibrary.libraries',
19 libraries
20 );
21
22 return (
23 <div className="pattern-library-selector">
24 <ButtonGroup>
25 { visibleLibraries.map( ( library ) => (
26 <Button
27 key={ library.id }
28 isPressed={ library.id === activeLibrary.id }
29 variant="secondary"
30 onClick={ () => {
31 setActiveLibrary( library );
32 setIsLocal( !! library.isLocal );
33 setPublicKey( library.publicKey );
34 setActiveCategory( '' );
35 } }
36 style={ {
37 pointerEvents: !! loading ? 'none' : '',
38 } }
39 >
40 { library.name }
41 </Button>
42 ) ) }
43
44 { ! readOnly && (
45 <AddLibrary />
46 ) }
47 </ButtonGroup>
48 </div>
49 );
50 }
51