Skip to content

Mini cart block: add margin and padding supports #59872

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

Merged
merged 9 commits into from
Aug 6, 2025

Conversation

MaggieCabrera
Copy link
Contributor

@MaggieCabrera MaggieCabrera commented Jul 22, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR adds support for margin and padding on the Mini cart block to allow for better user customization

Closes #59701

Screenshots or screen recordings:

Editor Frontend
Screenshot 2025-07-22 at 11 12 40 Screenshot 2025-07-22 at 11 12 56

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Insert the mini cart icon
  2. Before this PR, check the site editor and the frontend, applying this PR shouldn't change how the block looks
  3. Add margin and padding to the block and check that it applies correctly on site editor and frontend
  4. All other customizations should keep working, including adding an extra class to the block via the Advanced panel

Testing that has already taken place:

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 22, 2025
@MaggieCabrera MaggieCabrera marked this pull request as ready for review July 22, 2025 09:21
@MaggieCabrera MaggieCabrera requested a review from a team as a code owner July 22, 2025 09:21
@MaggieCabrera MaggieCabrera requested review from opr and removed request for a team July 22, 2025 09:21
Copy link
Contributor

github-actions bot commented Jul 22, 2025

Testing Guidelines

Hi @opr @straku ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@MaggieCabrera MaggieCabrera self-assigned this Jul 22, 2025
@MaggieCabrera MaggieCabrera added the Enhancement The issue is a request for an enhancement. label Jul 22, 2025
Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

📝 Walkthrough

Walkthrough

This change adds support for margin and padding (spacing controls) to the WooCommerce MiniCart block. It updates the block's configuration to enable spacing controls and refactors PHP methods to handle CSS classes and styles extraction by relying on default attribute handling, removing explicit style attribute lists.

Changes

File(s) Change Summary
Changelog update
plugins/woocommerce/changelog/add-spacing-support-minicart
Adds changelog entry documenting the addition of margin and padding support to the MiniCart block.
Block configuration
plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/block.json
Updates block configuration to enable margin and padding (spacing) controls in the MiniCart block.
PHP rendering logic
plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
Refactors methods to extract and compose CSS classes/styles by removing explicit style attribute lists in favor of default handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Editor
    participant MiniCart Block (JS)
    participant MiniCart Block (PHP)
    User->>Editor: Adds/Configures MiniCart block
    Editor->>MiniCart Block (JS): Loads block.json (now with spacing support)
    MiniCart Block (JS)->>Editor: Enables margin/padding controls
    Editor->>MiniCart Block (PHP): Renders block with attributes (including spacing)
    MiniCart Block (PHP)->>MiniCart Block (PHP): Extracts classes/styles using default attribute handling
    MiniCart Block (PHP)->>Editor: Returns rendered HTML with updated classes/styles
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbce353 and 79c890b.

📒 Files selected for processing (1)
  • plugins/woocommerce/changelog/add-spacing-support-minicart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/woocommerce/changelog/add-spacing-support-minicart
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-spacing-support-minicart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Jul 22, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@opr opr requested a review from straku July 22, 2025 15:22
@straku
Copy link
Contributor

straku commented Jul 24, 2025

Sorry for the delay with my review. It works great in my testing 😊

I've updated the branch with latest trunk changes with hope it will get the CI green.

@opr opr removed their request for review July 29, 2025 10:27
@MaggieCabrera MaggieCabrera force-pushed the add-spacing-support-minicart branch from 7686206 to 4ab0c62 Compare August 6, 2025 15:08
@MaggieCabrera MaggieCabrera enabled auto-merge (squash) August 6, 2025 15:26
@MaggieCabrera MaggieCabrera merged commit 1301d66 into trunk Aug 6, 2025
66 of 68 checks passed
@MaggieCabrera MaggieCabrera deleted the add-spacing-support-minicart branch August 6, 2025 15:58
@github-actions github-actions bot added this to the 10.2.0 milestone Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The issue is a request for an enhancement. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Mini cart block should have margin/padding controls
2 participants