Skip to content

Commit

Permalink
BCTHEME-188 Product cards should link to products
Browse files Browse the repository at this point in the history
  • Loading branch information
yurytut1993 committed Sep 21, 2020
1 parent 797b3da commit 03d1f34
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

- Product cards should link to products. [#1842](https://github.com/bigcommerce/cornerstone/pull/1842)

## Draft
- Create unified focus styling in Cornerstone. [#1812](https://github.com/bigcommerce/cornerstone/pull/1812)
- Review link in quick modal focused twice. [#1797](https://github.com/bigcommerce/cornerstone/pull/1797)
Expand Down
9 changes: 8 additions & 1 deletion assets/js/theme/common/carousel.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import 'slick-carousel';

const integerRegExp = /[0-9]+/;
const allFocusableElementsSelector = '[href], button, input, textarea, select, details, [contenteditable="true"], [tabindex]';

const setSlideTabindexes = ($slides) => {
$slides.each((index, element) => {
const $element = $(element);
const tabIndex = $element.hasClass('slick-active') ? 0 : -1;
$element.attr('tabindex', tabIndex);
if (!$element.hasClass('js-product-slide')) {
$element.attr('tabindex', tabIndex);
}

$element.find(allFocusableElementsSelector).each((idx, child) => {
$(child).attr('tabindex', tabIndex);
});
});
};

Expand Down
8 changes: 8 additions & 0 deletions assets/scss/components/citadel/cards/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@
.card-figure {
margin-top: $card-figure-marginTop;
position: relative;
padding: 3px;
overflow: hidden;

&:hover {

// scss-lint:disable NestingDepth
.card-figcaption {
opacity: 1;
}
}

&__link {
display: block;
position: relative;
}
}

.card-img-container {
Expand Down
4 changes: 4 additions & 0 deletions assets/scss/components/stencil/compare/_compare.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
min-height: spacing("single") * 4;
padding-top: spacing("base");
}

.card-figure {
overflow: visible;
}
}


Expand Down
12 changes: 7 additions & 5 deletions assets/scss/layouts/products/_productSaleBadges.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
.starwrap {
height: rem-calc(50px);
position: absolute;
top: 10px;
top: 12px;
left: 12px;
width: rem-calc(50px);
}

Expand Down Expand Up @@ -108,7 +109,7 @@
font-size: 15px;
font-weight: 700;
height: rem-calc(20px);
left: -35px;
left: -25px;
line-height: rem-calc(16px);
padding-top: spacing("eighth") / 2;
position: absolute;
Expand All @@ -123,15 +124,16 @@
.listItem-figure {

.sale-flag-sash {
left: -25px;
top: 24px;

@include breakpoint("small") {
top: 15px;
top: 19px;
left: -20px;
}

@include breakpoint("large") {
left: -15px;
top: 25px;
top: 24px;
}

}
Expand Down
2 changes: 1 addition & 1 deletion templates/components/products/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
{{/if}}
{{/or}}
<a href="{{url}}" {{#if settings.data_tag_enabled}} data-event-type="product-click" {{/if}}>
<a class="card-figure__link" aria-label="{{name}}" href="{{url}}" {{#if settings.data_tag_enabled}} data-event-type="product-click" {{/if}}>
<div class="card-img-container">
{{> components/common/responsive-img
image=image
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/brands.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="page-heading">{{lang 'brand.label'}}</h1>
<li class="brand">
<article class="card {{#if alternate}}card--alternate{{/if}}">
<figure class="card-figure">
<a href="{{url}}">
<a class="card-figure__link" aria-label="{{name}}" href="{{url}}">
<div class="card-img-container">
{{> components/common/responsive-img
image=image
Expand Down
20 changes: 11 additions & 9 deletions templates/pages/compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ <h1 class="page-heading">{{lang 'compare.header' products=comparisons.length}}</
<th class="compareTable-product">
<article class="card">
<figure class="card-figure">
<div class="card-img-container">
{{> components/common/responsive-img
image=image
class="card-image"
fallback_size=../theme_settings.product_size
lazyload=../theme_settings.lazyload_mode
default_image=../theme_settings.default_image_product
}}
</div>
<a class="card-figure__link" aria-label="{{name}}" href="{{url}}" {{#if settings.data_tag_enabled}} data-event-type="product-click" {{/if}}>
<div class="card-img-container">
{{> components/common/responsive-img
image=image
class="card-image"
fallback_size=../theme_settings.product_size
lazyload=../theme_settings.lazyload_mode
default_image=../theme_settings.default_image_product
}}
</div>
</a>
<a class="compareTable-removeProduct" data-comparison-remove href="{{#if remove_url}}{{remove_url}}{{else}}#{{/if}}">
<svg class="icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-close"></use>
Expand Down

0 comments on commit 03d1f34

Please sign in to comment.