article block: more core block styles

This commit is contained in:
2026-02-05 11:59:32 +00:00
parent 4c38753830
commit c136756962
17 changed files with 85 additions and 27 deletions

View File

@@ -31,6 +31,11 @@ add_filter( 'block_categories_all' , __NAMESPACE__ . '\\add_categories' );
add_filter( 'badegg_block_types_allow', __NAMESPACE__ . '\\allowed_list' ); add_filter( 'badegg_block_types_allow', __NAMESPACE__ . '\\allowed_list' );
add_action( 'init', __NAMESPACE__ . '\\auto_register' ); add_action( 'init', __NAMESPACE__ . '\\auto_register' );
/**
* Core Blocks
*/
add_filter( 'render_block_core/details', __NAMESPACE__ . '\\core_details_modified', 10, 2 );
function remove_action_block_inline() function remove_action_block_inline()
{ {
@@ -251,3 +256,11 @@ function render_acf($block, $content = '', $is_preview = false, $post_id = 0, $w
<?php echo ob_get_clean(); <?php echo ob_get_clean();
} }
} }
function core_details_modified($content, $block)
{
$content = str_replace('</summary>', '</summary><div class="wp-block-details__inner inner inner-zero-x wysiwyg">', $content);
$content = str_replace('</details>', '</div></details>', $content);
return $content;
}

View File

@@ -1,4 +1,4 @@
@use "../global/fonts"; @use "../global/variables/fonts";
@use "../global/variables/colours"; @use "../global/variables/colours";
button { button {

View File

@@ -1,4 +1,4 @@
@use "../global/fonts"; @use "../global/variables/fonts";
@use "../global/variables/breakpoints"; @use "../global/variables/breakpoints";
@use "../global/variables/colours"; @use "../global/variables/colours";

View File

@@ -1,6 +1,3 @@
$font: "Ubuntu", Helvetica, Arial, sans-serif;
$blockquote: serif;
/* /*
* Roots Fonts Setup * Roots Fonts Setup
* https://roots.io/sage/docs/fonts-setup/ * https://roots.io/sage/docs/fonts-setup/

View File

@@ -1,4 +1,4 @@
@use "fonts"; @use "variables/fonts";
@use "variables/breakpoints"; @use "variables/breakpoints";
@use "variables/colours"; @use "variables/colours";
@use "variables/spacing"; @use "variables/spacing";

View File

@@ -1,3 +1,4 @@
@use "variables/fonts";
@use "variables/colours"; @use "variables/colours";
@use "variables/breakpoints"; @use "variables/breakpoints";
@use "variables/spacing"; @use "variables/spacing";

View File

@@ -32,6 +32,11 @@ img {
transition: all 300ms ease; transition: all 300ms ease;
} }
video {
max-width: 100%;
height: auto;
}
img.lazy, img.lazy,
.lazy-bg, .lazy-bg,
.lazy-loaded { .lazy-loaded {

View File

@@ -0,0 +1,2 @@
$font: "Ubuntu", Helvetica, Arial, sans-serif;
$blockquote: serif;

View File

@@ -12,16 +12,20 @@ domReady(() => {
return settings return settings
} }
wp.hooks.addFilter( const coreInnerBlocks = (settings, name) => {
'blocks.registerBlockType', if (['core/media-text', 'core/details', 'core/quote'].includes(name)) {
'badegg/restrict-parent-blocks',
restrictEditorParentBlocks
);
// find blocks styles settings.allowedBlocks = [
wp.blocks.getBlockTypes().forEach((block) => { 'core/paragraph',
if (_.isArray(block['styles'])) { 'core/heading',
console.log('editor.js ' + block.name, _.pluck(block['styles'], 'name')); 'core/list',
];
} }
});
return settings;
}
wp.hooks.addFilter( 'blocks.registerBlockType', 'badegg/restrict-parent-blocks', restrictEditorParentBlocks );
wp.hooks.addFilter( 'blocks.registerBlockType', 'badegg/core-inner-blocks', coreInnerBlocks );
}); });

View File

@@ -7,17 +7,16 @@
"core/media-text", "core/media-text",
"core/audio", "core/audio",
"core/video", "core/video",
"core/embed",
"core/footnotes", "core/footnotes",
"core/heading", "core/heading",
"core/list", "core/list",
"core/code",
"core/details", "core/details",
"core/list-item", "core/list-item",
"core/missing", "core/missing",
"core/paragraph", "core/paragraph",
"core/quote", "core/quote",
"core/pullquote", "core/pullquote",
"core/table",
"core/verse" "core/verse"
] ]

View File

@@ -1,7 +1,4 @@
[ [
"core/media-text",
"core/details",
"core/quote",
"acf/badegg-editor", "acf/badegg-editor",
"badegg/article" "badegg/article"
] ]

View File

@@ -3,7 +3,6 @@
@use "../../../../css/global/variables/breakpoints"; @use "../../../../css/global/variables/breakpoints";
@use "../../../../css/global/variables/spacing"; @use "../../../../css/global/variables/spacing";
@use "../../../../css/global/variables/colours"; @use "../../../../css/global/variables/colours";
@use "../../../../css/global/fonts";
.wp-block-badegg-article { .wp-block-badegg-article {
container-name: BadEggArticle; container-name: BadEggArticle;

View File

@@ -0,0 +1,17 @@
@use "../../../../css/global/variables/colours";
@use "../../../../css/global/variables/fonts";
.wp-block-details {
summary {
font-family: fonts.$font;
font-weight: bold;
}
@media screen {
.knockout & {
summary {
color: colours.$white;
}
}
}
}

View File

@@ -0,0 +1,10 @@
.wp-block-badegg-article {
.is-type-video {
iframe {
display: block;
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
}
}
}

View File

@@ -1,7 +1,7 @@
@use "../../../../css/global/variables/breakpoints"; @use "../../../../css/global/variables/breakpoints";
@use "../../../../css/global/variables/spacing"; @use "../../../../css/global/variables/spacing";
@use "../../../../css/global/variables/colours"; @use "../../../../css/global/variables/colours";
@use "../../../../css/global/fonts"; @use "../../../../css/global/variables/fonts";
.wp-block-badegg-article { .wp-block-badegg-article {
.wp-block-pullquote blockquote, .wp-block-pullquote blockquote,

View File

@@ -0,0 +1,14 @@
@use "../../../../css/global/variables/colours";
@use "../../../../css/global/variables/fonts";
.wp-block-verse {
font-family: fonts.$font;
line-height: 2;
word-wrap: normal;
@media screen {
.knockout & {
color: colours.$white;
}
}
}

View File

@@ -1,8 +1,8 @@
@use 'css/base'; @use 'css/base';
@use 'css/image'; @use 'css/image';
@use 'css/gallery'; @use 'css/gallery';
@use 'css/media-text'; @use 'css/media-text';
@use 'css/quote'; @use 'css/quote';
@use 'css/embed';
@use 'css/verse';
@use 'css/details';