-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Components: Extract Reusable DocumentOutlineCheck component
- Loading branch information
1 parent
e51fbe3
commit b65f8a0
Showing
3 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
import { filter } from 'lodash'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getBlocks } from '../../selectors'; | ||
|
||
function DocumentOutlineCheck( { blocks, children } ) { | ||
const headings = filter( blocks, ( block ) => block.name === 'core/heading' ); | ||
|
||
if ( headings.length <= 1 ) { | ||
return null; | ||
} | ||
|
||
return children; | ||
} | ||
|
||
export default connect( | ||
( state ) => ( { | ||
blocks: getBlocks( state ), | ||
} ) | ||
)( DocumentOutlineCheck ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters