diff --git a/src/index.js b/src/index.js index bb3e4ea..aede38f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,9 +3,15 @@ import './editor.scss'; import { registerBlockType } from '@wordpress/blocks'; -import { Fragment } from '@wordpress/element'; +import { RawHTML, Fragment } from '@wordpress/element'; import { InspectorControls } from '@wordpress/editor'; -import { TextControl, Panel, PanelRow } from '@wordpress/components'; +import { + Button, + TextControl, + ToggleControl, + Panel, + PanelRow, +} from '@wordpress/components'; import { __ } from '@wordpress/i18n'; registerBlockType('room-vw/iconify', { @@ -21,15 +27,25 @@ registerBlockType('room-vw/iconify', { attributes: { prefix: { type: 'string', + source: 'attribute', + selector: 'data-prefix', default: 'noto-v1', }, name: { type: 'string', + source: 'attribute', + selector: 'data-name', default: 'unicorn', }, inline: { type: 'boolean', - default: true, + default: false, + }, + svg: { + type: 'string', + source: 'html', + selector: '.icon', + default: 'Select an icon', }, }, @@ -54,27 +70,53 @@ registerBlockType('room-vw/iconify', { }} /> + + { + setAttributes({ inline: state }); + }} + /> + + -
- - {attributes.prefix + ':' + attributes.name} -
+ + {attributes.svg} + ); }, - save({ className, attributes }) { + save({ attributes }) { return ( - + + {attributes.svg} + ); }, });