Skip to content

Commit

Permalink
Issue #27 - sort the blocks by Title and display in description list
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Feb 14, 2019
1 parent 71c0120 commit a7cb10e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions blocks/oik-blocklist/blocklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

import { BlockiconStyled } from '../oik-blockicon/blockicons.js';
import { getNameSpace} from './blockprefix.js';
Expand All @@ -24,12 +25,14 @@ function BlockListStyled( prefix, showBlockTypeName, showTitle, showDescription,

var block_types = getBlockTypes();
block_types = block_types.filter( namespaceFilter, namespace );
//block_types = block_types.sortByField( "name");
block_types = block_types.sort( (a, b) => a.title.localeCompare(b.title));
//console.log( block_types );
return(
<ul>
<li>Blocks for {namespace}</li>
<dl>

{ block_types.map ( ( block ) => BlockListItem( block ) )}
</ul>
</dl>

);

Expand All @@ -47,10 +50,17 @@ function namespaceFilter( element, index, array ) {
function BlockListItem( block ) {
/* { block.icon */
/* console.log( block ); */
return( <li>
<BlockIcon icon={block.icon.src} />
{block.name } {block.title }
</li> );
return( <Fragment>
<dt>
<BlockIcon icon={block.icon.src} />

</dt>
<dd>
{block.title } - {block.name }<br />
{block.description}
</dd>
</Fragment>
);
}

export { BlockListStyled };

0 comments on commit a7cb10e

Please sign in to comment.