-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.native.js
45 lines (39 loc) · 1.04 KB
/
index.native.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
/**
* External dependencies
*/
import React from 'react';
import { View } from 'react-native';
/**
* WordPress dependencies
*/
import { createSlotFill, BottomSheetConsumer } from '@wordpress/components';
/**
* Internal dependencies
*/
import { useBlockEditContext } from '../block-edit/context';
import { BlockSettingsButton } from '../block-settings';
const { Fill, Slot } = createSlotFill( 'InspectorControls' );
const FillWithSettingsButton = ( { children, ...props } ) => {
const { isSelected } = useBlockEditContext();
if ( ! isSelected ) {
return null;
}
return (
<>
<Fill { ...props }>
{
<BottomSheetConsumer>
{ () => <View>{ children }</View> }
</BottomSheetConsumer>
}
</Fill>
{ React.Children.count( children ) > 0 && <BlockSettingsButton /> }
</>
);
};
const InspectorControls = FillWithSettingsButton;
InspectorControls.Slot = Slot;
/**
* @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inspector-controls/README.md
*/
export default InspectorControls;