@gechiui/block-editor
Version:
96 lines (88 loc) • 2.65 kB
JavaScript
import { createElement } from "@gechiui/element";
/**
* GeChiUI dependencies
*/
import { Icon } from '@gechiui/components';
import { withSelect } from '@gechiui/data';
import { compose } from '@gechiui/compose';
import { getBlockType } from '@gechiui/blocks';
import { BlockIcon } from '@gechiui/block-editor';
/**
* External dependencies
*/
import { View, Text, TouchableOpacity } from 'react-native';
/**
* Internal dependencies
*/
import BlockTitle from '../block-title';
import useBlockDisplayInformation from '../use-block-display-information';
import SubdirectorSVG from './subdirectory-icon';
import { store as blockEditorStore } from '../../store';
import styles from './block-selection-button.scss';
const BlockSelectionButton = _ref => {
let {
clientId,
rootClientId,
rootBlockIcon,
isRTL
} = _ref;
const blockInformation = useBlockDisplayInformation(clientId);
return createElement(View, {
style: [styles.selectionButtonContainer, rootClientId && styles.densedPaddingLeft]
}, createElement(TouchableOpacity, {
style: styles.button,
onPress: () => {
/* Open BottomSheet with markup */
},
disabled: true
/* Disable temporarily since onPress function is empty */
}, rootClientId && rootBlockIcon && [createElement(Icon, {
key: "parent-icon",
size: 24,
icon: rootBlockIcon.src,
fill: styles.icon.color
}), createElement(View, {
key: "subdirectory-icon",
style: styles.arrow
}, createElement(SubdirectorSVG, {
fill: styles.arrow.color,
isRTL: isRTL
}))], (blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon) && createElement(BlockIcon, {
size: 24,
icon: blockInformation.icon,
fill: styles.icon.color
}), createElement(Text, {
maxFontSizeMultiplier: 1.25,
ellipsizeMode: "tail",
numberOfLines: 1,
style: styles.selectionButtonTitle
}, createElement(BlockTitle, {
clientId: clientId
}))));
};
export default compose([withSelect((select, _ref2) => {
let {
clientId
} = _ref2;
const {
getBlockRootClientId,
getBlockName,
getSettings
} = select(blockEditorStore);
const rootClientId = getBlockRootClientId(clientId);
if (!rootClientId) {
return {
clientId
};
}
const rootBlockName = getBlockName(rootClientId);
const rootBlockType = getBlockType(rootBlockName);
const rootBlockIcon = rootBlockType ? rootBlockType.icon : {};
return {
clientId,
rootClientId,
rootBlockIcon,
isRTL: getSettings().isRTL
};
})])(BlockSelectionButton);
//# sourceMappingURL=block-selection-button.native.js.map