/**
 * Registers a new block provided a unique name and an object defining its behavior.
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
 */
import { registerBlockType } from '@wordpress/blocks';

/**
 * Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
 * All files containing `style` keyword are bundled together. The code used
 * gets applied both to the front of your site and to the editor.
 *
 * @see https://www.npmjs.com/package/@wordpress/scripts#using-css
 */
import './style.scss';

/**
 * Import internal dependencies - the Main Block
 */
import Edit from './edit';
import save from './save';
import metadata from './block.json';

/**
 * Import internal dependencies - the Icon Button Block
 */
import EditIconButton from './icon-block/edit';
import SaveIconButton from './icon-block/save';
import metadataIconButton from './icon-block/block.json';

/**
 * Import the SVG icons for the blocks.
 */
import ssmbIcon from './assets/ssmb-icon.svg';
import ssmbIconButton from './assets/ssmb-icon-button.svg';

/**
 * Every block starts by registering a new block type definition.
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/
 */

// Register the Main Block (Smart Social Media Buttons)
registerBlockType( metadata.name, {
	...metadata,
	icon: () => (
		<img src={ ssmbIcon } alt="Smart Social Media Buttons Icon" style={ { width: '24px', height: '24px' }} />
	),
	edit: Edit,
	save,
} );

// Register the Icon Button Block
registerBlockType( metadataIconButton.name, {
	...metadataIconButton,
	icon: () => (
		<img src={ ssmbIconButton } alt="Icon Button Block Icon" style={ { width: '24px', height: '24px' } } />
	),
	edit: EditIconButton,
	save: SaveIconButton,
} );
