Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockVariationPicker: remove unused withSelect #53100

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import {
/**
* WordPress dependencies
*/
import { withSelect, useDispatch } from '@wordpress/data';
import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
import {
createBlocksFromInnerBlocksTemplate,
store as blocksStore,
} from '@wordpress/blocks';
import { useDispatch } from '@wordpress/data';
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
import { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import {
PanelBody,
Expand All @@ -26,7 +23,6 @@ import {
InserterButton,
} from '@wordpress/components';
import { Icon, close } from '@wordpress/icons';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -45,28 +41,25 @@ function BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {
styles.cancelButtonDark
);

const leftButton = useMemo(
() => (
<TouchableWithoutFeedback onPress={ onClose } hitSlop={ hitSlop }>
<View>
{ isIOS ? (
<Text
style={ cancelButtonStyle }
maxFontSizeMultiplier={ 2 }
>
{ __( 'Cancel' ) }
</Text>
) : (
<Icon
icon={ close }
size={ 24 }
style={ styles.closeIcon }
/>
) }
</View>
</TouchableWithoutFeedback>
),
[ onClose, cancelButtonStyle ]
const leftButton = (
<TouchableWithoutFeedback onPress={ onClose } hitSlop={ hitSlop }>
<View>
{ isIOS ? (
<Text
style={ cancelButtonStyle }
maxFontSizeMultiplier={ 2 }
>
{ __( 'Cancel' ) }
</Text>
) : (
<Icon
icon={ close }
size={ 24 }
style={ styles.closeIcon }
/>
) }
</View>
</TouchableWithoutFeedback>
);

const onVariationSelect = ( variation ) => {
Expand All @@ -77,51 +70,38 @@ function BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {
onClose();
};

return useMemo(
() => (
<BottomSheet
isVisible={ isVisible }
onClose={ onClose }
title={ __( 'Select a layout' ) }
contentStyle={ styles.contentStyle }
leftButton={ leftButton }
testID="block-variation-modal"
return (
<BottomSheet
isVisible={ isVisible }
onClose={ onClose }
title={ __( 'Select a layout' ) }
contentStyle={ styles.contentStyle }
leftButton={ leftButton }
testID="block-variation-modal"
>
<ScrollView
horizontal
showsHorizontalScrollIndicator={ false }
contentContainerStyle={ styles.contentContainerStyle }
style={ styles.containerStyle }
>
<ScrollView
horizontal
showsHorizontalScrollIndicator={ false }
contentContainerStyle={ styles.contentContainerStyle }
style={ styles.containerStyle }
>
{ variations.map( ( v ) => {
return (
<InserterButton
item={ v }
key={ v.name }
onSelect={ () => onVariationSelect( v ) }
/>
);
} ) }
</ScrollView>
<PanelBody>
<FooterMessageControl
label={ __(
'Note: Column layout may vary between themes and screen sizes'
) }
{ variations.map( ( v ) => (
<InserterButton
item={ v }
key={ v.name }
onSelect={ () => onVariationSelect( v ) }
/>
</PanelBody>
</BottomSheet>
),
[ variations, isVisible, onClose ]
) ) }
</ScrollView>
<PanelBody>
<FooterMessageControl
label={ __(
'Note: Column layout may vary between themes and screen sizes'
) }
/>
</PanelBody>
</BottomSheet>
);
}

export default compose(
withSelect( ( select, {} ) => {
const { getBlockVariations } = select( blocksStore );

return {
date: getBlockVariations( 'core/columns', 'block' ),
};
} )
)( BlockVariationPicker );
export default BlockVariationPicker;
Loading