Skip to content

Commit

Permalink
Issue #24 - enable Additional CSS class svg64 for block info icons an…
Browse files Browse the repository at this point in the history
…d transform between block icon and block info
  • Loading branch information
bobbingwide committed Feb 8, 2019
1 parent 0c6fe83 commit 0a8f3e5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion blocks/oik-blockicon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default registerBlockType(
}

var blockicon = BlockiconStyled( props.attributes.blockicon, props );

return [
<InspectorControls >
<PanelBody>
Expand Down
12 changes: 4 additions & 8 deletions blocks/oik-blockinfo/blockinfo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/*
* Block info - displays the fields for the block info block
* Block info renderer - displays the fields for the block info block
*
* @copyright (C) Copyright Bobbing Wide 2019
* @author Herb Miller @bobbingwide
*
*/

const { Component, Fragment } = wp.element;
const { getBlockTypes, getBlockType } = wp.blocks;
const { BlockIcon } = wp.editor;
const { SelectControl } = wp.components;
const { getBlockType } = wp.blocks;

import { BlockiconStyled } from '../oik-blockicon/blockicons.js';

Expand All @@ -21,15 +18,14 @@ function BlockinfoStyled( blockname, showBlockTypeName, showTitle, showDescripti
var blockDescription = showDescription ? <div> { block.description } </div> : null;

return(
<Fragment>
<div className={ props.className }>
{ blockicon }
{ blockTypeName }
{ blockTitle }
{ blockDescription }
</Fragment>
</div>

);
}


export { BlockinfoStyled };
36 changes: 30 additions & 6 deletions blocks/oik-blockinfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const { __ } = wp.i18n;
// Get registerBlockType from wp.blocks
const {
registerBlockType,
createBlock,
} = wp.blocks;
const {
BlockIcon,
Expand All @@ -41,6 +42,7 @@ const {
Dashicon,

} = wp.components;
const { Fragment } = wp.element;


//import { DashiconsSelect } from './dashicons.js';
Expand Down Expand Up @@ -97,10 +99,31 @@ export default registerBlockType(
default: true
}

},




transforms: {
from: [
{
type: 'block',
blocks: ['oik-block/blockicon'],
transform: function( attributes ) {
return createBlock( 'oik-block/blockinfo', {
blockicon: attributes.blockicon,
});
},
},
],
to: [
{
type: 'block',
blocks: ['oik-block/blockicon'],
transform: function( attributes ) {
return createBlock( 'oik-block/blockicon', {
blockicon: attributes.blockicon,
});
},
}
]
},

/**
Expand Down Expand Up @@ -133,7 +156,7 @@ export default registerBlockType(
props.setAttributes( { showDescription: ! props.attributes.showDescription } );
}

var blockicon = BlockinfoStyled( props.attributes.blockicon,
var blockinfo = BlockinfoStyled( props.attributes.blockicon,
props.attributes.showBlockTypeName,
props.attributes.showTitle,
props.attributes.showDescription,
Expand Down Expand Up @@ -183,9 +206,10 @@ export default registerBlockType(
</InspectorControls>
,
<div className={ props.className }>
{ blockicon }
{ blockinfo }
</div>


];
},
/*
Expand All @@ -194,7 +218,7 @@ export default registerBlockType(
/>
*/
save: props => {
return BlockinfoStyled( props.attributes.blockicon, props.attributes.showBlockTypeName, props.attributes.showTitle );
return BlockinfoStyled( props.attributes.blockicon, props.attributes.showBlockTypeName, props.attributes.showTitle, props.attributes.showDescription, props );
},
},
);
1 change: 1 addition & 0 deletions blocks/oik-blockinfo/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/* oik-blockicon/style.scss */
.wp-block-oik-block-blockicon.svg64 svg {
width: 64px;
Expand Down

0 comments on commit 0a8f3e5

Please sign in to comment.