Skip to content

Commit

Permalink
fix(storefront): BCTHEME-325 Apple pay button displaying needs to be …
Browse files Browse the repository at this point in the history
…fixed (#2043)
  • Loading branch information
BC-tymurbiedukhin committed Apr 29, 2021
1 parent 530ec94 commit b729eed
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Apple pay button displaying needs to be fixed. [#2043](https://github.com/bigcommerce/cornerstone/pull/2043)

## 5.4.0 (04-26-2021)
- Incorrect focus order for product carousels. [#2034](https://github.com/bigcommerce/cornerstone/pull/2034)
Expand Down
8 changes: 8 additions & 0 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CartItemDetails from './common/cart-item-details';
export default class Cart extends PageManager {
onReady() {
this.$modal = null;
this.$cartPageContent = $('[data-cart]');
this.$cartContent = $('[data-cart-content]');
this.$cartMessages = $('[data-cart-status]');
this.$cartTotals = $('[data-cart-totals]');
Expand All @@ -18,9 +19,16 @@ export default class Cart extends PageManager {
this.$activeCartItemId = null;
this.$activeCartItemBtnAction = null;

this.setApplePaySupport();
this.bindEvents();
}

setApplePaySupport() {
if (window.ApplePaySession) {
this.$cartPageContent.addClass('apple-pay-supported');
}
}

cartUpdate($target) {
const itemId = $target.data('cartItemid');
this.$activeCartItemId = itemId;
Expand Down
4 changes: 4 additions & 0 deletions assets/js/theme/common/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ export default class ProductDetails extends ProductDetailsBase {
if (this.previewModal) {
this.previewModal.open();

if (window.ApplePaySession) {
this.previewModal.$modal.addClass('apple-pay-supported');
}

if ($addToCartBtn.parents('.quickView').length === 0) this.previewModal.$preModalFocusedEl = $addToCartBtn;
this.updateCartContent(this.previewModal, response.data.cart_item.id, () => this.previewModal.setupFocusTrap());
} else {
Expand Down
4 changes: 4 additions & 0 deletions assets/js/theme/global/cart-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default function (secureBaseUrl, cartId) {

const $body = $('body');

if (window.ApplePaySession) {
$cartDropdown.addClass('apple-pay-supported');
}

$body.on('cart-quantity-update', (event, quantity) => {
$cart.attr('aria-label', (_, prevValue) => prevValue.replace(/\d+/, quantity));

Expand Down
11 changes: 1 addition & 10 deletions assets/scss/components/stencil/applePay/_applePay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,14 @@
}
}

.cart-additionalCheckoutButtons {
.apple-pay-checkout-button {
margin-top: spacing("half");
}
}

.apple-pay-supported {
.apple-pay-checkout-button {
display: block;
float: right;
}
}

.previewCartCheckout {
.apple-pay-checkout-button {
& .previewCartCheckout .apple-pay-checkout-button {
display: inline-block;
float: none;
margin-top: spacing("half");
}
}
17 changes: 3 additions & 14 deletions assets/scss/components/stencil/cart/_cart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ $card-preview-zoom-bottom-offset: 6rem;
float: right;
}
}

.CheckoutButton {
margin-bottom: spacing("base");

&:first-child {
margin-top: spacing("single");
}

&:last-child {
margin-bottom: spacing("single");
}
}
}

// Cart layout
Expand Down Expand Up @@ -557,7 +545,8 @@ $card-preview-zoom-bottom-offset: 6rem;

.previewCart-additionalCheckoutButtons {
@extend %additionalCheckoutButtons;
padding-right: 1.5rem;
padding-right: spacing('single');
padding-bottom: spacing('single');
}

// Cart Preview
Expand Down Expand Up @@ -608,7 +597,7 @@ $card-preview-zoom-bottom-offset: 6rem;
}

@include lazy-loaded-padding('productthumb_size');

&:after {
@include breakpoint("xxsmall") {
padding-bottom: 75%;
Expand Down
5 changes: 4 additions & 1 deletion assets/scss/components/stencil/previewCart/_previewCart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@
width: 100%;

// scss-lint:disable NestingDepth
+ .button,
+ p {
margin-top: spacing("half");
}

&:not(:last-child) {
margin-bottom: spacing("half");
}
}
}

Expand Down

0 comments on commit b729eed

Please sign in to comment.