@wordpress/create-block-interactive-template 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -11,26 +11,26 @@
|
|
|
11
11
|
* @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
$unique_id =
|
|
14
|
+
$unique_id = wp_unique_id( 'p-' );
|
|
15
15
|
?>
|
|
16
16
|
|
|
17
17
|
<div
|
|
18
18
|
<?php echo get_block_wrapper_attributes(); ?>
|
|
19
|
-
data-wp-interactive
|
|
20
|
-
data-wp-context='{ "
|
|
21
|
-
data-wp-
|
|
19
|
+
data-wp-interactive='{ "namespace": "{{namespace}}" }'
|
|
20
|
+
data-wp-context='{ "isOpen": false }'
|
|
21
|
+
data-wp-watch="callbacks.logIsOpen"
|
|
22
22
|
>
|
|
23
23
|
<button
|
|
24
|
-
data-wp-on--click="actions.
|
|
25
|
-
data-wp-bind--aria-expanded="context.
|
|
26
|
-
aria-controls="
|
|
24
|
+
data-wp-on--click="actions.toggle"
|
|
25
|
+
data-wp-bind--aria-expanded="context.isOpen"
|
|
26
|
+
aria-controls="<?php echo esc_attr( $unique_id ); ?>"
|
|
27
27
|
>
|
|
28
28
|
<?php esc_html_e( 'Toggle', '{{textdomain}}' ); ?>
|
|
29
29
|
</button>
|
|
30
30
|
|
|
31
31
|
<p
|
|
32
|
-
id="
|
|
33
|
-
data-wp-bind--hidden="!context.
|
|
32
|
+
id="<?php echo esc_attr( $unique_id ); ?>"
|
|
33
|
+
data-wp-bind--hidden="!context.isOpen"
|
|
34
34
|
>
|
|
35
35
|
<?php
|
|
36
36
|
esc_html_e( '{{title}} - hello from an interactive block!', '{{textdomain}}' );
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
{{#isBasicVariant}}
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies
|
|
5
4
|
*/
|
|
6
|
-
import { store } from "@wordpress/interactivity";
|
|
5
|
+
import { store, getContext } from "@wordpress/interactivity";
|
|
7
6
|
|
|
8
|
-
store( {
|
|
7
|
+
store( '{{namespace}}', {
|
|
9
8
|
actions: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
9
|
+
toggle: () => {
|
|
10
|
+
const context = getContext();
|
|
11
|
+
context.isOpen = ! context.isOpen;
|
|
14
12
|
},
|
|
15
13
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
14
|
+
callbacks: {
|
|
15
|
+
logIsOpen: () => {
|
|
16
|
+
const { isOpen } = getContext();
|
|
17
|
+
// Log the value of `isOpen` each time it changes.
|
|
18
|
+
console.log( `Is open: ${ isOpen }` );
|
|
22
19
|
},
|
|
23
20
|
},
|
|
24
21
|
} );
|
|
25
22
|
|
|
26
|
-
{{/isBasicVariant}}
|
|
23
|
+
{{/isBasicVariant}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/create-block-interactive-template",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Template for @wordpress/create-block to create interactive blocks with the Interactivity API.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
|
|
26
26
|
}
|