add-library.js
2 years ago
category-list.js
2 years ago
insert-pattern.js
2 years ago
library-cache.js
2 years ago
library-layout.js
2 years ago
library-provider.js
2 years ago
library-selector.js
2 years ago
manage-libraries.js
2 years ago
pattern-details-header.js
2 years ago
pattern-details.js
2 years ago
pattern-list.js
2 years ago
pattern-search.js
2 years ago
pattern.js
2 years ago
selected-patterns.js
2 years ago
library-selector.js
43 lines
| 1 | import { Button, ButtonGroup } from '@wordpress/components'; |
| 2 | import { useLibrary } from './library-provider'; |
| 3 | import AddLibrary from './add-library'; |
| 4 | |
| 5 | export default function LibrarySelector() { |
| 6 | const { |
| 7 | libraries, |
| 8 | activeLibrary, |
| 9 | setActiveLibrary, |
| 10 | setIsLocal, |
| 11 | setPublicKey, |
| 12 | setActiveCategory, |
| 13 | loading, |
| 14 | } = useLibrary(); |
| 15 | |
| 16 | return ( |
| 17 | <div className="pattern-library-selector"> |
| 18 | <ButtonGroup> |
| 19 | { libraries.map( ( library ) => ( |
| 20 | <Button |
| 21 | key={ library.id } |
| 22 | isPressed={ library.id === activeLibrary.id } |
| 23 | variant="secondary" |
| 24 | onClick={ () => { |
| 25 | setActiveLibrary( library ); |
| 26 | setIsLocal( !! library.isLocal ); |
| 27 | setPublicKey( library.publicKey ); |
| 28 | setActiveCategory( '' ); |
| 29 | } } |
| 30 | style={ { |
| 31 | pointerEvents: !! loading ? 'none' : '', |
| 32 | } } |
| 33 | > |
| 34 | { library.name } |
| 35 | </Button> |
| 36 | ) ) } |
| 37 | |
| 38 | <AddLibrary /> |
| 39 | </ButtonGroup> |
| 40 | </div> |
| 41 | ); |
| 42 | } |
| 43 |