-
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.
First pass at Navigation screen (#21036)
* First pass at Navigation screen Adds a new Navigation screen, a new edit-navigation package, and a very rough UI for editing menus using the Navigation block. * Add explanatory comment * Remove console logs * Move inline styles to scss Co-authored-by: Daniel Richards <[email protected]>
- Loading branch information
1 parent
55fed74
commit b84e38f
Showing
21 changed files
with
535 additions
and
0 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,101 @@ | ||
<?php | ||
/** | ||
* Bootstraping the Gutenberg Navigation page. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* The main entry point for the Gutenberg Navigation page. | ||
* | ||
* @since 7.8.0 | ||
*/ | ||
function gutenberg_navigation_page() { | ||
?> | ||
<div | ||
id="navigation-editor" | ||
class="edit-navigation" | ||
> | ||
</div> | ||
<?php | ||
} | ||
|
||
/** | ||
* Initialize the Gutenberg Navigation page. | ||
* | ||
* @since 7.8.0 | ||
* | ||
* @param string $hook Page. | ||
*/ | ||
function gutenberg_navigation_init( $hook ) { | ||
if ( 'gutenberg_page_gutenberg-navigation' !== $hook ) { | ||
return; | ||
} | ||
|
||
// Media settings. | ||
$max_upload_size = wp_max_upload_size(); | ||
if ( ! $max_upload_size ) { | ||
$max_upload_size = 0; | ||
} | ||
|
||
/** This filter is documented in wp-admin/includes/media.php */ | ||
$image_size_names = apply_filters( | ||
'image_size_names_choose', | ||
array( | ||
'thumbnail' => __( 'Thumbnail', 'gutenberg' ), | ||
'medium' => __( 'Medium', 'gutenberg' ), | ||
'large' => __( 'Large', 'gutenberg' ), | ||
'full' => __( 'Full Size', 'gutenberg' ), | ||
) | ||
); | ||
|
||
$available_image_sizes = array(); | ||
foreach ( $image_size_names as $image_size_slug => $image_size_name ) { | ||
$available_image_sizes[] = array( | ||
'slug' => $image_size_slug, | ||
'name' => $image_size_name, | ||
); | ||
} | ||
|
||
$settings = array( | ||
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ), | ||
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ), | ||
'imageSizes' => $available_image_sizes, | ||
'isRTL' => is_rtl(), | ||
'maxUploadFileSize' => $max_upload_size, | ||
); | ||
|
||
list( $color_palette, ) = (array) get_theme_support( 'editor-color-palette' ); | ||
list( $font_sizes, ) = (array) get_theme_support( 'editor-font-sizes' ); | ||
|
||
if ( false !== $color_palette ) { | ||
$settings['colors'] = $color_palette; | ||
} | ||
|
||
if ( false !== $font_sizes ) { | ||
$settings['fontSizes'] = $font_sizes; | ||
} | ||
|
||
wp_add_inline_script( | ||
'wp-edit-navigation', | ||
sprintf( | ||
'wp.domReady( function() { | ||
wp.editNavigation.initialize( "navigation-editor", %s ); | ||
} );', | ||
wp_json_encode( gutenberg_experiments_editor_settings( $settings ) ) | ||
) | ||
); | ||
|
||
// Preload server-registered block schemas. | ||
wp_add_inline_script( | ||
'wp-blocks', | ||
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' | ||
); | ||
|
||
wp_enqueue_script( 'wp-edit-navigation' ); | ||
wp_enqueue_style( 'wp-edit-navigation' ); | ||
wp_enqueue_style( 'wp-block-library' ); | ||
wp_enqueue_script( 'wp-format-library' ); | ||
wp_enqueue_style( 'wp-format-library' ); | ||
} | ||
add_action( 'admin_enqueue_scripts', 'gutenberg_navigation_init' ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
package-lock=false |
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,5 @@ | ||
- Package name | ||
- Package description | ||
- Installation details | ||
- Usage example | ||
- `Code is Poetry` logo (`<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>`) |
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,44 @@ | ||
{ | ||
"name": "@wordpress/edit-navigation", | ||
"version": "1.0.0-beta.0", | ||
"private": true, | ||
"description": "Module for the Navigation page in WordPress.", | ||
"author": "The WordPress Contributors", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
"wordpress" | ||
], | ||
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/edit-navigation/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/WordPress/gutenberg.git", | ||
"directory": "packages/edit-navigation" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/WordPress/gutenberg/issues" | ||
}, | ||
"main": "build/index.js", | ||
"module": "build-module/index.js", | ||
"react-native": "src/index", | ||
"dependencies": { | ||
"@babel/runtime": "^7.8.3", | ||
"@wordpress/block-editor": "file:../block-editor", | ||
"@wordpress/block-library": "file:../block-library", | ||
"@wordpress/blocks": "file:../blocks", | ||
"@wordpress/components": "file:../components", | ||
"@wordpress/compose": "file:../compose", | ||
"@wordpress/data": "file:../data", | ||
"@wordpress/data-controls": "file:../data-controls", | ||
"@wordpress/dom-ready": "file:../dom-ready", | ||
"@wordpress/element": "file:../element", | ||
"@wordpress/hooks": "file:../hooks", | ||
"@wordpress/i18n": "file:../i18n", | ||
"@wordpress/media-utils": "file:../media-utils", | ||
"@wordpress/notices": "file:../notices", | ||
"lodash": "^4.17.15", | ||
"rememo": "^3.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,60 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
DropZoneProvider, | ||
FocusReturnProvider, | ||
Popover, | ||
SlotFillProvider, | ||
TabPanel, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import MenusEditor from '../menus-editor'; | ||
import MenuLocationsEditor from '../menu-locations-editor'; | ||
|
||
export default function Layout( { blockEditorSettings } ) { | ||
return ( | ||
<> | ||
<SlotFillProvider> | ||
<DropZoneProvider> | ||
<FocusReturnProvider> | ||
{ /* <Notices /> */ } | ||
<Popover.Slot name="block-toolbar" /> | ||
<TabPanel | ||
tabs={ [ | ||
{ | ||
name: 'menus', | ||
title: __( 'Edit Navigation' ), | ||
}, | ||
{ | ||
name: 'menu-locations', | ||
title: __( 'Manage Locations' ), | ||
}, | ||
] } | ||
> | ||
{ ( tab ) => ( | ||
<> | ||
{ tab.name === 'menus' && ( | ||
<MenusEditor | ||
blockEditorSettings={ | ||
blockEditorSettings | ||
} | ||
/> | ||
) } | ||
{ tab.name === 'menu-locations' && ( | ||
<MenuLocationsEditor /> | ||
) } | ||
</> | ||
) } | ||
</TabPanel> | ||
<Popover.Slot /> | ||
</FocusReturnProvider> | ||
</DropZoneProvider> | ||
</SlotFillProvider> | ||
</> | ||
); | ||
} |
Oops, something went wrong.