Skip to content

Commit

Permalink
Update React Native implementation to match web
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Aug 19, 2021
1 parent b62031c commit 83bc87e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export * from './gradients';
export * from './font-sizes';
export { AlignmentControl, AlignmentToolbar } from './alignment-control';
export { default as InnerBlocks } from './inner-blocks';
export { default as InspectorControls } from './inspector-controls';
export {
default as InspectorControls,
InspectorAdvancedControls,
} from './inspector-controls';
export {
JustifyToolbar,
JustifyContentControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ import { View } from 'react-native';
* WordPress dependencies
*/
import { Children } from '@wordpress/element';
import { createSlotFill, BottomSheetConsumer } from '@wordpress/components';
import { BottomSheetConsumer } from '@wordpress/components';
import warning from '@wordpress/warning';

/**
* Internal dependencies
*/
import groups from './groups';
import { useBlockEditContext } from '../block-edit/context';
import { BlockSettingsButton } from '../block-settings';

const { Fill, Slot } = createSlotFill( 'InspectorControls' );

const FillWithSettingsButton = ( { children, ...props } ) => {
export default function InspectorControlsFill( {
children,
__experimentalGroup: group = 'default',
...props
} ) {
const { isSelected } = useBlockEditContext();
const Fill = groups[ group ]?.Fill;
if ( ! Fill ) {
warning( `Unknown InspectorControl group "${ group }" provided.` );
return null;
}
if ( ! isSelected ) {
return null;
}
Expand All @@ -35,13 +44,4 @@ const FillWithSettingsButton = ( { children, ...props } ) => {
{ Children.count( children ) > 0 && <BlockSettingsButton /> }
</>
);
};

const InspectorControls = FillWithSettingsButton;

InspectorControls.Slot = Slot;

/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
*/
export default InspectorControls;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* WordPress dependencies
*/
import warning from '@wordpress/warning';

/**
* Internal dependencies
*/
import groups from './groups';

export default function InspectorControlsSlot( {
__experimentalGroup: group = 'default',
...props
} ) {
const Slot = groups[ group ]?.Slot;
if ( ! Slot ) {
warning( `Unknown InspectorControl group "${ group }" provided.` );
return null;
}

return <Slot { ...props } />;
}

0 comments on commit 83bc87e

Please sign in to comment.