Skip to content

Commit 580801f

Browse files
authored
Merge pull request #293 from 10up/fix/scaffold-issues
Fix asset related issues in scaffold
2 parents 5ff36b4 + 0119dec commit 580801f

File tree

7 files changed

+100
-97
lines changed

7 files changed

+100
-97
lines changed

mu-plugins/10up-plugin/src/Assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function admin_scripts() {
6868
public function admin_styles() {
6969
wp_enqueue_style(
7070
'tenup_plugin_admin',
71-
TENUP_PLUGIN_URL . 'dist/css/admin-style.css',
71+
TENUP_PLUGIN_URL . 'dist/css/admin.css',
7272
[],
7373
$this->get_asset_info( 'admin', 'version' ),
7474
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.wp-block-image {
2+
3+
& img[src$=".svg"] {
4+
height: auto;
5+
}
6+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is used to override the styling of the block editor canvas.
3+
* It is enqueued in the editor iframe only.
4+
*/
5+
6+
/*
7+
* Override the styling of the post title in the post editor
8+
* to make it look as though it's part of the editor frame instead
9+
* of the post content.
10+
*/
11+
.edit-post-visual-editor__post-title-wrapper {
12+
align-items: center;
13+
background-color: #fff; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
14+
border-bottom: 1px solid #e0e0e0;
15+
display: flex;
16+
justify-content: flex-start;
17+
margin-bottom: 0;
18+
margin-top: 0 !important;
19+
max-width: none;
20+
min-height: 48px;
21+
overflow: hidden;
22+
width: 100%;
23+
24+
& .editor-post-title__input {
25+
color: #000; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
26+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
27+
font-size: 16px;
28+
height: auto;
29+
line-height: 1.2;
30+
padding: 2px 0;
31+
width: 100%;
32+
}
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This file is used to override the styling of the block editor frame.
3+
* It is enqueued in the editor outside of the editor canvas iframe.
4+
*/
5+
6+
7+
/*
8+
* Small editor blocks like the footer social nav are hard to click
9+
* Setting a min-height so that elements can be selected to edit
10+
* Prior to this scrollbars overlapped small elements
11+
*/
12+
13+
.is-root-container {
14+
min-height: 90dvh;
15+
}
16+
17+
.block-editor-iframe__container {
18+
min-height: 70px;
19+
}

themes/10up-block-theme/assets/css/editor-style-overrides.css

Lines changed: 0 additions & 72 deletions
This file was deleted.

themes/10up-block-theme/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"useScriptModules": true,
2929
"loadBlockSpecificStyles": true,
3030
"entry": {
31-
"editor-style-overrides": "./assets/css/editor-style-overrides.css",
31+
"editor-frame-style-overrides": "./assets/css/editor-frame-style-overrides.css",
32+
"editor-canvas-style-overrides": "./assets/css/editor-canvas-style-overrides.css",
3233
"frontend": "./assets/js/frontend.js",
3334
"block-extensions": "./assets/js/block-extensions.js"
3435
},

themes/10up-block-theme/src/Assets.php

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,27 @@ public function register() {
4040
dist_path: TENUP_BLOCK_THEME_DIST_PATH,
4141
fallback_version: TENUP_BLOCK_THEME_VERSION
4242
);
43-
add_action( 'init', [ $this, 'scripts' ] );
4443
add_action( 'init', [ $this, 'register_all_icons' ], 10 );
45-
add_action( 'wp_enqueue_scripts', [ $this, 'styles' ] );
46-
add_action( 'enqueue_block_editor_assets', [ $this, 'editor_style_overrides' ] );
44+
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_frontend_assets' ] );
45+
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] );
46+
add_action( 'enqueue_block_assets', [ $this, 'enqueue_block_editor_iframe_assets' ] );
4747
}
4848

4949
/**
50-
* Enqueue scripts for front-end.
50+
* Enqueue assets for the front-end.
5151
*
5252
* @return void
5353
*/
54-
public function scripts() {
54+
public function enqueue_frontend_assets() {
55+
wp_enqueue_style(
56+
'tenup-theme-styles',
57+
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/frontend.css',
58+
[],
59+
$this->get_asset_info( 'frontend', 'version' )
60+
);
61+
5562
wp_enqueue_script(
56-
'frontend',
63+
'tenup-theme-frontend',
5764
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/js/frontend.js',
5865
$this->get_asset_info( 'frontend', 'dependencies' ),
5966
$this->get_asset_info( 'frontend', 'version' ),
@@ -64,28 +71,16 @@ public function scripts() {
6471
}
6572

6673
/**
67-
* Enqueue styles for front-end.
74+
* Enqueue assets for the block editor.
6875
*
69-
* @return void
70-
*/
71-
public function styles() {
72-
wp_enqueue_style(
73-
'tenup-theme-styles',
74-
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/frontend.css',
75-
[],
76-
$this->get_asset_info( 'frontend', 'version' )
77-
);
78-
}
79-
80-
/**
81-
* Enqueue styles for editor only.
76+
* These assets are enqueued in the editor outside of the editor canvas iframe.
8277
*
8378
* @return void
8479
*/
85-
public function editor_style_overrides() {
80+
public function enqueue_block_editor_assets() {
8681
wp_enqueue_style(
87-
'tenup-theme-editor-style-overrides',
88-
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/editor-style-overrides.css',
82+
'tenup-theme-editor-frame-style-overrides',
83+
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/editor-frame-style-overrides.css',
8984
[],
9085
TENUP_BLOCK_THEME_VERSION
9186
);
@@ -99,6 +94,27 @@ public function editor_style_overrides() {
9994
);
10095
}
10196

97+
/**
98+
* Enqueue styles inside the editor canvas iFrame only.
99+
*
100+
* @return void
101+
*/
102+
public function enqueue_block_editor_iframe_assets() {
103+
104+
// The `enqueue_block_assets` action is triggered both on the front-end and in the editor iframe.
105+
// We only want to enqueue these styles inside the editor iframe.
106+
if ( ! is_admin() ) {
107+
return;
108+
}
109+
110+
wp_enqueue_style(
111+
'tenup-theme-editor-canvas-style-overrides',
112+
TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/editor-canvas-style-overrides.css',
113+
[],
114+
TENUP_BLOCK_THEME_VERSION
115+
);
116+
}
117+
102118
/**
103119
* register all icons located in the dist/svg folder
104120
*

0 commit comments

Comments
 (0)