-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add basic pages block * Add dropdowns and indicators * Inherit settings from parent Nav block * Add pages button adds the block and styling improvements * Change name to page list * Add pages icon * Add page list fixture * Update nav screen snapshot * Fix placeholder and dropdown background * Use context and add keywords * Fix clickability and remove extra classname. * Test presence of pages block items * Replace walker with manual iteration * Fix tests * Address review feedback * Order menu items and de-indent comment.
- Loading branch information
1 parent
68237f6
commit 218bff3
Showing
20 changed files
with
467 additions
and
69 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
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
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
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,20 @@ | ||
{ | ||
"apiVersion": 2, | ||
"name": "core/page-list", | ||
"category": "widgets", | ||
"usesContext": [ | ||
"textColor", | ||
"customTextColor", | ||
"backgroundColor", | ||
"customBackgroundColor", | ||
"fontSize", | ||
"customFontSize", | ||
"showSubmenuIcon" | ||
], | ||
"supports": { | ||
"reusable": false, | ||
"html": false | ||
}, | ||
"editorStyle": "wp-block-page-list-editor", | ||
"style": "wp-block-page-list" | ||
} |
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,31 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
||
import { useBlockProps } from '@wordpress/block-editor'; | ||
import ServerSideRender from '@wordpress/server-side-render'; | ||
|
||
export default function PageListEdit( { context } ) { | ||
const { textColor, backgroundColor, showSubmenuIcon } = context || {}; | ||
|
||
const blockProps = useBlockProps( { | ||
className: classnames( { | ||
'has-text-color': !! textColor, | ||
[ `has-${ textColor }-color` ]: !! textColor, | ||
'has-background': !! backgroundColor, | ||
[ `has-${ backgroundColor }-background-color` ]: !! backgroundColor, | ||
'show-submenu-icons': !! showSubmenuIcon, | ||
} ), | ||
} ); | ||
|
||
return ( | ||
<div { ...blockProps }> | ||
<ServerSideRender block="core/page-list" /> | ||
</div> | ||
); | ||
} |
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,29 @@ | ||
.wp-block-navigation { | ||
// Block wrapper gets the classes in the editor, and there's an extra div wrapper for now, so background styles need to be inherited. | ||
.wp-block-page-list > div, | ||
.wp-block-page-list { | ||
background-color: inherit; | ||
} | ||
// Make the dropdown background white if there's no background color set. | ||
&:not(.has-background) { | ||
.submenu-container { | ||
color: $gray-900; | ||
background-color: $white; | ||
} | ||
} | ||
} | ||
|
||
// Make links unclickable in the editor | ||
.wp-block-pages-list__item__link { | ||
pointer-events: none; | ||
} | ||
|
||
.wp-block-page-list .components-placeholder { | ||
min-height: 0; | ||
padding: 0; | ||
background-color: inherit; | ||
|
||
.components-spinner { | ||
margin-top: 0; | ||
} | ||
} |
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,24 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { pages as icon } from '@wordpress/icons'; | ||
import { __, _x } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
import edit from './edit.js'; | ||
|
||
const { name } = metadata; | ||
|
||
export { metadata, name }; | ||
|
||
export const settings = { | ||
title: _x( 'Page List', 'block title' ), | ||
description: __( 'Display a list of all pages.' ), | ||
keywords: [ __( 'menu' ), __( 'navigation' ) ], | ||
icon, | ||
example: {}, | ||
edit, | ||
}; |
Oops, something went wrong.