Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add TotalsWrapper component #4415

Merged
merged 16 commits into from Jul 2, 2021
Merged

Add TotalsWrapper component #4415

merged 16 commits into from Jul 2, 2021

Conversation

opr
Copy link
Contributor

@opr opr commented Jun 30, 2021

This PR adds a component called TotalsWrapper whose purpose is to wrap components in the Cart and Checkout sidebar so that components that have borders (the grey lines between items in the screenshot section) don't have to be concerned with what follows them.

For example, if the store has coupons disabled, then you could end up with a component with a bottom border, and one with a top border together resulting in a "double border".

By wrapping these components in a TotalsWrapper then the borders can be consistently managed from one place.

The PR will also slightly change the way Slot/Fills are rendered. The Slot will be rendered inside a TotalsWrapper but each Fill will also have a border and padding applied to it (by CSS), to visually separate them.

Here is an overview of the changes made in this PR:

  • Add a TotalsWrapper component. This has the optional prop slotWrapper to allow CSS to render borders on Fills.
  • Add hasValidFills function in slot/index.js - This is to check that at least one of the Fills about to be rendered is truthy (i.e. not null/undefined) or it won't render the Slot.
  • Change styles on OrderSummary, ShippingRatesControlPackage, TotalsCoupon, Cart, and CheckoutSidebar to remove borders and padding because TotalsWrapper is now handling it.
  • Wrap Slots in <TotalsWrapper>
  • Change the button responsible for expanding the Panel component to only have margins/padding when the panel is open.

Fixes #4267

Screenshots

Before After
image image

How to test the changes in this Pull Request:

  1. Ensure you're running WC Subscriptions 3.1.3 or later and you've got some different subscriptions products available to add to your cart.
  2. Check out feature/add-inputs-for-points-redemption on WC Points and Rewards
  3. run npm run build in your WC Points and Rewards directory.
  4. Ensure your user has points available to use (WooCommerce > Points and Rewards)
  5. Add some products to your cart, some of which should be subscription products.
  6. Go to the Cart block. Ensure the sidebar doesn't have double borders, empty gaps, or inconsistent spacing.
  7. Change settings relating to tax, try several different combinations and check the Cart/Checkout sidebar each time to make sure the spacing/borders are all consistent.
  8. Disable coupons and do the same.
  9. Try any other settings you can think of to introduce/hide different sections on these sidebars.

Changelog

Wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.

@opr opr added status: needs review type: bug The issue/PR concerns a confirmed bug. focus: blocks Specific work involving or impacting how blocks behave. block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: global styles Issues that involve styles/css/layout structure. labels Jun 30, 2021
@opr opr requested a review from a team as a code owner June 30, 2021 14:29
@opr opr self-assigned this Jun 30, 2021
@opr opr requested review from senadir and removed request for a team June 30, 2021 14:29
@github-actions
Copy link
Contributor

github-actions bot commented Jun 30, 2021

Size Change: +412 B (0%)

Total Size: 1 MB

Filename Size Change
build/active-filters-frontend.js 8.28 kB -1 B (0%)
build/active-filters.js 7.84 kB -2 B (0%)
build/all-products-frontend.js 35.2 kB -2 B (0%)
build/all-products.js 37.7 kB -10 B (0%)
build/all-reviews.js 9.56 kB +1 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button--atomic-block-components/image---a7e2bb9b.js 2.56 kB -1 B (0%)
build/atomic-block-components/add-to-cart--atomic-block-components/button.js 2 kB -1 B (0%)
build/atomic-block-components/add-to-cart-frontend.js 8.66 kB +1 B (0%)
build/atomic-block-components/add-to-cart.js 7.73 kB +1 B (0%)
build/atomic-block-components/button-frontend.js 1.76 kB -1 B (0%)
build/attribute-filter-frontend.js 18 kB -2 B (0%)
build/attribute-filter.js 11.8 kB -4 B (0%)
build/blocks-checkout-editor.js 10.8 kB +125 B (+1%)
build/blocks-checkout.js 20.2 kB +118 B (+1%)
build/cart-frontend.js 78.6 kB +39 B (0%)
build/cart.js 45.8 kB +21 B (0%)
build/checkout-frontend.js 82.7 kB +41 B (0%)
build/checkout.js 48.1 kB +22 B (0%)
build/featured-product.js 9.55 kB -1 B (0%)
build/price-filter-frontend.js 14.4 kB -1 B (0%)
build/price-filter.js 9.57 kB -5 B (0%)
build/reviews-by-product.js 13.1 kB -2 B (0%)
build/reviews-frontend.js 9.18 kB +1 B (0%)
build/single-product-frontend.js 37.5 kB -1 B (0%)
build/vendors--atomic-block-components/price-frontend.js 6.51 kB -3 B (0%)
build/wc-blocks-middleware.js 1.48 kB -1 B (0%)
build/wc-blocks-registry.js 2.75 kB +1 B (0%)
build/wc-blocks-shared-context.js 1.54 kB -1 B (0%)
build/wc-blocks-shared-hocs.js 1.75 kB +1 B (0%)
build/wc-blocks-style-rtl.css 19.2 kB +39 B (0%)
build/wc-blocks-style.css 19.2 kB +41 B (0%)
build/wc-blocks-vendors.js 240 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size
build/atomic-block-components/add-to-cart--atomic-block-components/image--atomic-block-components/title.js 333 B
build/atomic-block-components/button.js 875 B
build/atomic-block-components/category-list-frontend.js 469 B
build/atomic-block-components/category-list.js 478 B
build/atomic-block-components/image-frontend.js 1.88 kB
build/atomic-block-components/image.js 1.35 kB
build/atomic-block-components/price-frontend.js 2.08 kB
build/atomic-block-components/price.js 2.1 kB
build/atomic-block-components/rating-frontend.js 560 B
build/atomic-block-components/rating.js 565 B
build/atomic-block-components/sale-badge-frontend.js 860 B
build/atomic-block-components/sale-badge.js 868 B
build/atomic-block-components/sku-frontend.js 389 B
build/atomic-block-components/sku.js 394 B
build/atomic-block-components/stock-indicator-frontend.js 610 B
build/atomic-block-components/stock-indicator.js 611 B
build/atomic-block-components/summary-frontend.js 907 B
build/atomic-block-components/summary.js 913 B
build/atomic-block-components/tag-list-frontend.js 466 B
build/atomic-block-components/tag-list.js 471 B
build/atomic-block-components/title-frontend.js 1.43 kB
build/atomic-block-components/title.js 1.28 kB
build/featured-category.js 7.39 kB
build/handpicked-products.js 6.55 kB
build/price-format.js 1.38 kB
build/product-best-sellers.js 6.73 kB
build/product-categories.js 3.38 kB
build/product-category.js 7.59 kB
build/product-new.js 6.88 kB
build/product-on-sale.js 7.22 kB
build/product-search.js 2.68 kB
build/product-tag.js 6.7 kB
build/product-top-rated.js 6.85 kB
build/products-by-attribute.js 7.82 kB
build/reviews-by-category.js 11.5 kB
build/single-product.js 9.88 kB
build/wc-blocks-data.js 10.9 kB
build/wc-blocks-editor-style-rtl.css 14.9 kB
build/wc-blocks-editor-style.css 14.9 kB
build/wc-blocks-google-analytics.js 1.99 kB
build/wc-blocks-vendors-style-rtl.css 1.05 kB
build/wc-blocks-vendors-style.css 1.05 kB
build/wc-blocks.js 3.5 kB
build/wc-payment-method-bacs.js 812 B
build/wc-payment-method-cheque.js 807 B
build/wc-payment-method-cod.js 903 B
build/wc-payment-method-paypal.js 844 B
build/wc-payment-method-stripe.js 12.3 kB
build/wc-settings.js 2.93 kB

compressed-size-action

Copy link
Member

@senadir senadir left a comment

Choose a reason for hiding this comment

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

I tested with and without Subscriptions. everything looks fine!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. block: checkout Issues related to the checkout block. focus: blocks Specific work involving or impacting how blocks behave. focus: global styles Issues that involve styles/css/layout structure. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Border on Coupon code Panel in Cart/Checkout is too thick when there is no shipping required
2 participants