/**
 * Internal dependencies.
 */
import Settings from './settings';
import Render from './render';
import RenderBlockPreview from '@spectra-components/render-block-preview';

/**
 * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
 * Those files can contain any CSS code that gets applied to the editor.
 */
import './editor.scss';

/**
 * The 'Edit' function.
 *
 * @param {Object} props The element props.
 * @since x.x.x
 * @return {Element} Element to render.
 */
const Edit = ( props ) => {
	// Destructure the required props.
	const {
		isSelected,
		attributes: { isPreview },
	} = props;

	// If this is an example, return the preview image.
	if ( isPreview ) {
		return <RenderBlockPreview childPath="loop-builder-children" blockName="sort" pluginName="spectra-pro" />;
	}

	return (
		<>
			{ isSelected && <Settings { ...{ ...props } } /> }
			<Render { ...props } />
		</>
	);
};

export default Edit;
