diff --git a/README.md b/README.md index 8b13789..64be9af 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ +**TODO** - currently the block name is hardcoded to `svg` and theme is `room-vw`. +Need to use templating to create a `.php` file (based on `svg.php) +with the correct theme/block names. + +## Usage + +```sh +npm install + +# build and watch for development +npm run dev + +# build for production +npm run build +``` + +The links to the WordPress default config files are required so that code +editors pick up the correct linting configurations. diff --git a/src/index.js b/src/index.js index 0a204cd..a9f4c0d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,8 @@ import './style.scss'; import './editor.scss'; -const registerBlockType = { wp.blocks }; -const el = { wp.element }; -const __ = { wp.i18n}; +import { registerBlockType } from '@wordpress/blocks'; +import { __ } from '@wordpress/i18n'; registerBlockType( 'room-vw/svg', { title: __( 'SVG Wrapper', 'room-vw' ), @@ -16,14 +15,14 @@ registerBlockType( 'room-vw/svg', { }, edit( props ) { - return el( - 'p', - { className: props.className }, - __( 'Hello from the editor!', 'room-vw' ) + return ( +

+ { __( 'Hello from the editor!', 'room-vw' ) } +

); }, save() { - return el( 'p', {}, __( 'Hello from the saved content!', 'room-vw' ) ); + return

{ __( 'Hello from the saved content!', 'room-vw' ) }

; }, } ); diff --git a/src/style.scss b/src/style.scss index bb3fbd4..1de0373 100644 --- a/src/style.scss +++ b/src/style.scss @@ -5,7 +5,7 @@ */ .wp-block-room-vw-svg { - background-color: #000; + background-color: #666; color: #fff; padding: 2px; } diff --git a/svg.php b/svg.php index bde23a1..4ca3ccf 100644 --- a/svg.php +++ b/svg.php @@ -17,7 +17,7 @@ function svg_block_init() { $asset_file['version'] ); - $editor_css = 'build/style-index.css'; + $editor_css = 'build/index.css'; wp_register_style( 'svg-block-editor', "$uri/$editor_css", @@ -25,7 +25,7 @@ function svg_block_init() { filemtime( "$dir/$editor_css" ) ); - $style_css = 'build/index.css'; + $style_css = 'build/style-index.css'; wp_register_style( 'svg-block', "$uri/$style_css",