-
Notifications
You must be signed in to change notification settings - Fork 4k
/
screen-block-list.js
51 lines (45 loc) · 1.31 KB
/
screen-block-list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* WordPress dependencies
*/
import { getBlockTypes } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { useHasBorderPanel } from './border-panel';
import { useHasColorPanel } from './color-utils';
import { useHasDimensionsPanel } from './dimensions-panel';
import { useHasTypographyPanel } from './typography-panel';
import ScreenHeader from './header';
import NavigationButton from './navigation-button';
function BlockMenuItem( { block } ) {
const hasTypographyPanel = useHasTypographyPanel( block.name );
const hasColorPanel = useHasColorPanel( block.name );
const hasBorderPanel = useHasBorderPanel( block.name );
const hasDimensionsPanel = useHasDimensionsPanel( block.name );
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
const hasBlockMenuItem =
hasTypographyPanel || hasColorPanel || hasLayoutPanel;
if ( ! hasBlockMenuItem ) {
return null;
}
return (
<NavigationButton path={ '/blocks/' + block.name }>
{ block.title }
</NavigationButton>
);
}
function ScreenBlockList() {
return (
<>
<ScreenHeader back="/" title={ __( 'Blocks' ) } />
{ getBlockTypes().map( ( block ) => (
<BlockMenuItem
block={ block }
key={ 'menu-itemblock-' + block.name }
/>
) ) }
</>
);
}
export default ScreenBlockList;