Skip to content

feat: add tailwind support for blocks#696

Open
Swanand01 wants to merge 4 commits into
theme-elementary-v2from
feat/tailwind-block-support
Open

feat: add tailwind support for blocks#696
Swanand01 wants to merge 4 commits into
theme-elementary-v2from
feat/tailwind-block-support

Conversation

@Swanand01
Copy link
Copy Markdown

Description

This PR adds tailwind styling supports to the gutenberg editor.

Technical Details

add_editor_style() call is added with the css/frontend/tailwind.css path if tailwind_enabled is true.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Tailwind CSS support to the WordPress block editor by registering an editor stylesheet via add_editor_style() when Tailwind is enabled. Mirrors the existing frontend Tailwind handling already present in register_assets/enqueue_assets.

Changes:

  • New add_editor_styles() method on Assets that calls add_editor_style() with assets/build/css/frontend/tailwind.css when $tailwind_enabled is true.
  • Hooks the new method on after_setup_theme from register_hooks().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread inc/Core/Assets.php
Copy link
Copy Markdown
Member

@aryanjasala aryanjasala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the failing PHP Lint job

Comment thread inc/Core/Assets.php
*/
public function add_editor_styles(): void {
if ( $this->tailwind_enabled ) {
add_editor_style( $this->assets_dir . '/css/frontend/tailwind.css' );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for using add_editor_style on after_theme_setup instead of using wp_enqueue_style on enqueue_block_editor_assets?

https://developer.wordpress.org/block-editor/how-to-guides/enqueueing-assets-in-the-editor/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs say: Editor-specific stylesheets should almost always be added with add_editor_style() or wp_enqueue_block_style().
Both do similar things. What do you recommend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants