Skip to content
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

fix(storefront): BCTHEME-325 Apple pay button displaying needs to be fixed #2043

Merged
merged 5 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
- Incorrect focus order for product carousels. [#2034](https://github.com/bigcommerce/cornerstone/pull/2034)
- Removed duplicates of main tag.[#2032](https://github.com/bigcommerce/cornerstone/pull/2032)
- Hamburger Menu Icon missing on Google AMP Pages. [#2022](https://github.com/bigcommerce/cornerstone/pull/2022)
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