Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some layout issues with FSE #11

Merged
merged 14 commits into from
Sep 20, 2022
39 changes: 0 additions & 39 deletions bin/colorPaletteGenerator.js

This file was deleted.

55 changes: 21 additions & 34 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
const colorPaletteGenerator = require('./bin/colorPaletteGenerator');

module.exports = {
plugins: [
[
'@luehrsenheinrich/postcss-wp-global-styles',
{
themeJson: './theme/theme.json',
colorPaletteGenerator,
}
],
[
'postcss-import',
],
[
'postcss-preset-env',
{
stage: 1,
features: {
'custom-media-queries': {
preserve: false,
importFrom: './theme/src/css/vars/_media-queries.css',
},
'custom-properties': {
preserve: true,
importFrom: './theme/src/css/vars.css',
},
},
}
],
[
'cssnano'
]
]
}
plugins: [
['postcss-import'],
[
'postcss-preset-env',
{
stage: 1,
features: {
'custom-media-queries': {
preserve: false,
importFrom: './theme/src/css/vars/_media-queries.css',
},
'custom-properties': {
preserve: true,
importFrom: './theme/src/css/vars.css',
},
},
},
],
['cssnano'],
],
};
3 changes: 2 additions & 1 deletion theme/admin/src/js/script.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import './modules/test';
// eslint-disable-next-line no-console
console.log('The admin scripts is still emtpy.');
19 changes: 1 addition & 18 deletions theme/inc/FSE/FSE.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class FSE extends Component {
* {@inheritdoc}
*/
protected function add_actions() {
/** Remove global styles */
if ( ! is_admin() ) {
add_action( 'init', array( $this, 'remove_global_styles' ) );
}

add_action( 'init', array( $this, 'remove_theme_support' ), 9 );
}

Expand All @@ -33,9 +28,7 @@ protected function add_filters() {
/** Filter the block type metadata */
add_filter( 'block_type_metadata', array( $this, 'filter_block_type_metadata' ) );
add_filter( 'block_type_metadata_settings', array( $this, 'filter_block_type_metadata_settings' ), 10, 2 );

/** Remove unwanted output from the editor. */
remove_filter( 'render_block', 'wp_render_layout_support_flag' );
add_filter( 'styles_inline_size_limit', '__return_zero' );
}

/**
Expand All @@ -58,16 +51,6 @@ public function remove_theme_support() {
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
}

/**
* Remove global styles as we handle them ourselves.
*
* @return void
*/
public function remove_global_styles() {
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_footer', 'wp_enqueue_global_styles' );
}

/**
* Filter block type metadata to remove unwanted output from the editor.
*
Expand Down
2 changes: 1 addition & 1 deletion theme/inc/Lazysizes/Lazysizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function rewrite_image_block( $block_content, $block, $instance ) {
/**
* Create a new image element.
*/
$new_image_html = wp_get_attachment_image( $block['attrs']['id'], $block['attrs']['sizeSlug'] ?? 'full' );
$new_image_html = wp_get_attachment_image( $block['attrs']['id'] ?? null, $block['attrs']['sizeSlug'] ?? 'full' );

/**
* If there is no image, we cannot do anything.
Expand Down
8 changes: 8 additions & 0 deletions theme/inc/Scripts/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Scripts extends Component {
*/
protected function add_actions() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
}

/**
Expand All @@ -45,4 +46,11 @@ public function enqueue_scripts() {
wp_enqueue_script( 'comment-reply' );
}
}

/**
* Enqueue admin scripts.
*/
public function enqueue_admin_scripts() {
wp_enqueue_script( 'lhpbpt-admin-script', get_template_directory_uri() . '/admin/dist/js/script.min.js', array(), lh_theme()->get_theme_version(), true );
}
}
13 changes: 0 additions & 13 deletions theme/inc/Styles/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ protected function add_actions() {
add_action( 'after_setup_theme', array( $this, 'action_add_editor_styles' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );

/** Remove global styles */
add_action( 'init', array( $this, 'remove_global_styles' ) );

/** Remove WP Emoji */
add_action( 'init', array( $this, 'remove_wp_emoji' ) );
}
Expand Down Expand Up @@ -293,16 +290,6 @@ public function enqueue_block_editor_assets() {
wp_enqueue_style( 'lhpbpt-editor-vars', get_theme_file_uri( '/dist/css/vars.min.css' ), array(), lh_theme()->get_theme_version() );
}

/**
* Remove global styles as we handle them ourselves.
*
* @return void
*/
public function remove_global_styles() {
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
remove_action( 'wp_footer', 'wp_enqueue_global_styles' );
}

/**
* Remove WP Emojis.
*
Expand Down
2 changes: 1 addition & 1 deletion theme/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="entry-header inner-container">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="entry-content wide-content">
<div class="entry-content wp-site-blocks">
<?php the_content(); ?>
</div>
</article>
Expand Down
1 change: 0 additions & 1 deletion theme/src/css/base.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import "normalize.css";
@import "./src-base/_global-styles.css";
@import "./src-base/_reset.css";
@import "./src-base/_a11y.css";
@import "./src-base/_inner-container.css";
Expand Down
3 changes: 0 additions & 3 deletions theme/src/css/blocks.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@import "./src-blocks/core/columns.css";
@import "./src-blocks/core/cover.css";
@import "./src-blocks/core/gallery.css";
@import "./src-blocks/core/group.css";
@import "./src-blocks/core/spacer.css";
@import "./src-blocks/core/embed.css";

/* Test 1 */
6 changes: 0 additions & 6 deletions theme/src/css/editor-styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
@import "./base.css";
@import "./blocks.css";
@import "./src-editor-styles/_widths.css";
@import "./src-editor-styles/_z-index.css";

/* Editor Styles for blocks */
@import "./src-blocks/core/columns-editor.css";

/* Test 2 */
1 change: 0 additions & 1 deletion theme/src/css/src-base/_alignment.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
max-width: none;
margin-left: calc(var(--grid-gutter-width) * -1);
margin-right: calc(var(--grid-gutter-width) * -1);
padding: 0;
}

@media (--sm-query) {
Expand Down
1 change: 0 additions & 1 deletion theme/src/css/src-base/_global-styles.css

This file was deleted.

13 changes: 2 additions & 11 deletions theme/src/css/src-base/_inner-container.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

.entry-content,
.inner-container,
.wp-block-column,
[class*="wp-block"] > [class*="__inner-container"],
[class*="wp-block"] > [class*="__content"] {
margin: 0 auto;
Expand All @@ -13,21 +12,13 @@
& > * {

/* The default margin */
margin: 0 auto;

/* The default padding */
padding-left: 0;
margin-left: auto;
margin-right: auto;

/**
* By default, content within the container is constraint
* to the content width.
*/
max-width: var(--content-width);

& + * {

/* The stack */
margin-top: var(--grid-gutter-height);
}
}
}
12 changes: 0 additions & 12 deletions theme/src/css/src-blocks/core/columns-editor.css

This file was deleted.

8 changes: 0 additions & 8 deletions theme/src/css/src-blocks/core/group.css

This file was deleted.

18 changes: 18 additions & 0 deletions theme/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"spacing": {
"blockGap": true,
"margin": true,
"padding": true,
"units": [
"em",
"rem",
"vh",
"vw",
"%"
]
},
"typography": {
"dropCap": false,
"customFontSize": false,
Expand Down Expand Up @@ -44,6 +56,7 @@
"defaultGradients": false,
"custom": false,
"customGradient": false,
"defaultDuotone": false,
"palette": [
{
"name": "Primary 300",
Expand Down Expand Up @@ -147,5 +160,10 @@
}
]
}
},
"styles": {
"spacing": {
"blockGap": "var(--grid-gutter-height)"
}
}
}