Skip to content

Commit

Permalink
fix(storefront): BCTHEME-67 Cart icon quantity should have appropriat…
Browse files Browse the repository at this point in the history
…e link text (#1765)
  • Loading branch information
BC-tymurbiedukhin authored Aug 26, 2020
1 parent ad952be commit 4e2946b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions assets/js/theme/global/cart-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ export default function (secureBaseUrl, cartId) {
const $body = $('body');

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

if (!quantity) {
$cart.addClass('navUser-item--cart__hidden-s');
} else {
$cart.removeClass('navUser-item--cart__hidden-s');
}

$('.cart-quantity')
.text(quantity)
.toggleClass('countPill--positive', quantity > 0);
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"title": "Checkout"
},
"cart": {
"nav_aria_label": "Cart with 0 items",
"continue_shopping": "Click here to continue shopping",
"items": "{NUM, plural, =0{(0 items)} one {(# item)} other {(# items)}}",
"checkout": {
Expand Down
2 changes: 1 addition & 1 deletion templates/components/common/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
data-dropdown="cart-preview-dropdown"
data-options="align:right"
href="{{urls.cart}}"
aria-label="{{lang 'common.cart'}}"
aria-label="{{lang 'cart.nav_aria_label'}}"
>
<span class="navUser-item-cartLabel">{{lang 'common.cart'}}</span>
<span class="countPill cart-quantity"></span>
Expand Down

0 comments on commit 4e2946b

Please sign in to comment.