Skip to content

Commit 2c71cfa

Browse files
committed
Reapply "iAPI Router: Handle styles assets on region-based navigation (WordPress#67826)"
This reverts commit 0a5be06.
1 parent 116aad9 commit 2c71cfa

30 files changed

+680
-153
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 2,
4+
"name": "test/router-styles-blue",
5+
"title": "E2E Interactivity tests - router styles - Blue",
6+
"category": "text",
7+
"icon": "heart",
8+
"description": "",
9+
"supports": {
10+
"interactivity": true
11+
},
12+
"textdomain": "e2e-interactivity",
13+
"viewStyle": "file:./style.css",
14+
"render": "file:./render.php"
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* HTML for testing the iAPI's style assets management.
4+
*
5+
* @package gutenberg-test-interactive-blocks
6+
*
7+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8+
*/
9+
10+
add_action(
11+
'wp_enqueue_scripts',
12+
function () {
13+
wp_enqueue_style(
14+
'blue-from-link',
15+
plugin_dir_url( __FILE__ ) . 'style-from-link.css',
16+
array()
17+
);
18+
19+
$custom_css = '
20+
.blue-from-inline {
21+
color: rgb(0, 0, 255);
22+
}
23+
';
24+
25+
wp_register_style( 'test-router-styles', false );
26+
wp_enqueue_style( 'test-router-styles' );
27+
wp_add_inline_style( 'test-router-styles', $custom_css );
28+
}
29+
);
30+
31+
$wrapper_attributes = get_block_wrapper_attributes(
32+
array( 'data-testid' => 'blue-block' )
33+
);
34+
?>
35+
<p <?php echo $wrapper_attributes; ?>>Blue</p>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.blue-from-link {
2+
color: rgb(0, 0, 255);
3+
}
4+
5+
.background-from-link {
6+
background-image: url('./assets/10x10_e2e_test_image_blue.png');
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.wp-block-test-router-styles-blue,
2+
.blue {
3+
color: rgb(0, 0, 255);
4+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 2,
4+
"name": "test/router-styles-green",
5+
"title": "E2E Interactivity tests - router styles - Green",
6+
"category": "text",
7+
"icon": "heart",
8+
"description": "",
9+
"supports": {
10+
"interactivity": true
11+
},
12+
"textdomain": "e2e-interactivity",
13+
"viewStyle": "file:./style.css",
14+
"render": "file:./render.php"
15+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* HTML for testing the iAPI's style assets management.
4+
*
5+
* @package gutenberg-test-interactive-blocks
6+
*
7+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8+
*/
9+
10+
add_action(
11+
'wp_enqueue_scripts',
12+
function () {
13+
wp_enqueue_style(
14+
'green-from-link',
15+
plugin_dir_url( __FILE__ ) . 'style-from-link.css',
16+
array()
17+
);
18+
19+
$custom_css = '
20+
.green-from-inline {
21+
color: rgb(0, 255, 0);
22+
}
23+
';
24+
25+
wp_register_style( 'test-router-styles', false );
26+
wp_enqueue_style( 'test-router-styles' );
27+
wp_add_inline_style( 'test-router-styles', $custom_css );
28+
}
29+
);
30+
31+
$wrapper_attributes = get_block_wrapper_attributes(
32+
array( 'data-testid' => 'green-block' )
33+
);
34+
?>
35+
<p <?php echo $wrapper_attributes; ?>>Green</p>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.green-from-link {
2+
color: rgb(0, 255, 0);
3+
}
4+
5+
.background-from-link {
6+
background-image: url('./assets/10x10_e2e_test_image_green.png');
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.wp-block-test-router-styles-green,
2+
.green {
3+
color: rgb(0, 255, 0);
4+
}

0 commit comments

Comments
 (0)