tomusborne / generateblocks

GenerateBlocks is a small collection of lightweight WordPress blocks that can accomplish nearly anything.
https://generateblocks.com
194 stars 19 forks source link

var() values not reflected in the editor for new components #1082

Closed SchneiderSam closed 1 year ago

SchneiderSam commented 1 year ago

Description

I've encountered an issue with GenerateBlocks where CSS variable values, specifically var(--space-xl), don't seem to reflect accurately in the WordPress block editor for new components.

Steps to reproduce

  1. Create a new variable in Customizer.
  2. Input var(--space-xl) as the value for spacing.
  3. Observe the frontend to see the applied spacing.
  4. Compare with the view in the WordPress block editor.

Expected behavior

When I enter a var() value, it should be displayed consistently in both the frontend and the editor, indicating that the spacing has been defined.

Actual behavior

While the frontend displays the spacing correctly, in the block editor, it appears as if no spacing has been defined.

References:

https://github.com/tomusborne/generateblocks/assets/9355398/db6f7dc4-9c57-47cd-a317-add3974b2b01


diggeddy commented 1 year ago

Thats not related to GB. You need to load your customiser styles in the editor. As WP doesn't do it for you.

this snippet:

add_filter( 'block_editor_settings_all', function( $editor_settings ) {
    $css = wp_get_custom_css_post()->post_content;
    $editor_settings['styles'][] = array( 'css' => $css );

    return $editor_settings;
} );