-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Create default Core Navigation Overlay patterns #74047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a5a2ac
eec36ea
043c91b
05bb25d
a5f60f6
8ad40f9
2199632
5003484
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
| /** | ||
| * Block patterns registration for navigation overlays. | ||
| * | ||
| * @package gutenberg | ||
| */ | ||
|
|
||
| /** | ||
| * Registers block patterns for navigation overlays. | ||
| * | ||
| * This function adds patterns that are specific to the navigation overlays | ||
| * experiment. It runs after core patterns are registered to ensure all patterns | ||
| * are available. | ||
| * | ||
| * @since 6.0.0 | ||
| */ | ||
| function gutenberg_register_overlay_block_patterns() { | ||
| register_block_pattern_category( | ||
| 'navigation', | ||
| array( | ||
| 'label' => _x( 'Navigation', 'Block pattern category', 'gutenberg' ), | ||
| 'description' => _x( 'Display your website navigation.', 'Block pattern category', 'gutenberg' ), | ||
| ) | ||
| ); | ||
|
|
||
| register_block_pattern( | ||
| 'gutenberg/navigation-overlay', | ||
| array( | ||
| 'title' => __( 'Navigation Overlay', 'gutenberg' ), | ||
| 'description' => _x( 'A simple pattern with a navigation block and a navigation overlay close button.', 'Block pattern description', 'gutenberg' ), | ||
| 'content' => '<!-- wp:group {"style":{"spacing":{"padding":{"right":"var:preset|spacing|40","left":"var:preset|spacing|40","top":"var:preset|spacing|40","bottom":"var:preset|spacing|40"}}},"layout":{"type":"default"}} --> | ||
| <div class="wp-block-group" style="padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)"><!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"right"}} --> | ||
| <div class="wp-block-group alignwide"><!-- wp:navigation-overlay-close --> | ||
| <button class="wp-block-navigation-overlay-close" type="button" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1.1-1-6.1 6.2-6.1-6.2-1.1 1 6.1 6.3-6.5 6.7 1.1 1 6.5-6.6 6.5 6.6 1.1-1z"></path></svg></button> | ||
| <!-- /wp:navigation-overlay-close --></div> | ||
| <!-- /wp:group --> | ||
|
|
||
| <!-- wp:navigation {"layout":{"type":"flex","orientation":"vertical"}} /--></div> | ||
| <!-- /wp:group -->', | ||
| 'categories' => array( 'navigation' ), | ||
| 'blockTypes' => array( 'core/template-part/overlay' ), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know not introduced here, but I personally think the block type should be Non-navigation content perhaps shouldn't ever be assigned to this area. I think the template part areas are also a public api (extenders can add their own), so it might be better to have a more specific name, less chance of a clash with plugins.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @getdave for awareness
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Dan (and Maggie for ping)
My understanding of this suggestion is that the Template Part Area for I don't believe we need a custom block instead of just using a Group with a custom name - I don't think you are suggesting that but mentioning just in case.
I didn't follow this. The overlay must be allowed to contain any content. Could you elaborate? |
||
| ) | ||
| ); | ||
| } | ||
|
|
||
| add_action( 'init', 'gutenberg_register_overlay_block_patterns', 20 ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should disable the overlay on this navigation...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we should do this to all navigation blocks within navigation overlays, so it should be a different PR.