From cc19f6ae2ed419a0169d2153f793168d908df961 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Tue, 20 Sep 2022 10:28:50 +0200 Subject: [PATCH 1/9] Replace micromodal for Alpinejs directives --- .../block-library/src/navigation/block.json | 2 +- .../block-library/src/navigation/index.php | 39 ++++++++--- .../src/navigation/view-modal.js | 68 ------------------- 3 files changed, 31 insertions(+), 78 deletions(-) delete mode 100644 packages/block-library/src/navigation/view-modal.js diff --git a/packages/block-library/src/navigation/block.json b/packages/block-library/src/navigation/block.json index a8c65b5a88b75b..06dff2610aa3af 100644 --- a/packages/block-library/src/navigation/block.json +++ b/packages/block-library/src/navigation/block.json @@ -130,7 +130,7 @@ } } }, - "viewScript": [ "file:./view.min.js", "file:./view-modal.min.js" ], + "viewScript": "file:./view.min.js", "editorStyle": "wp-block-navigation-editor", "style": "wp-block-navigation" } diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 5173f96040b4d0..f8358791557fbc 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -426,10 +426,25 @@ function render_block_core_navigation( $attributes, $content, $block ) { wp_enqueue_script( 'wp-block-navigation-view' ); } - $should_load_modal_view_script = isset( $attributes['overlayMenu'] ) && 'never' !== $attributes['overlayMenu']; - if ( $should_load_modal_view_script ) { - wp_enqueue_script( 'wp-block-navigation-view-modal' ); - } + // Register @alpine/focus plugin + wp_register_script( + 'AlpineJS_focus', + 'https://unpkg.com/@alpinejs/focus@3.10.3/dist/cdn.min.js', + array(), + "3.10.3", + true // Load it in the footer + ); + wp_enqueue_script( 'AlpineJS_focus' ); + + // Register Alpine + wp_register_script( + 'AlpineJS', + 'https://unpkg.com/alpinejs@3.10.3/dist/cdn.min.js', + array('AlpineJS_focus'), + "3.10.3", + true // Load it in the footer + ); + wp_enqueue_script( 'AlpineJS' ); $inner_blocks = $block->inner_blocks; @@ -632,11 +647,17 @@ function render_block_core_navigation( $attributes, $content, $block ) { $toggle_aria_label_close = $should_display_icon_label ? 'aria-label="' . __( 'Close menu' ) . '"' : ''; // Close button label. $responsive_container_markup = sprintf( - ' -
+ ' +
-
- +