Skip to content

Commit

Permalink
Add multi-assets support to auto-gen pr. page
Browse files Browse the repository at this point in the history
  • Loading branch information
PeeterPaal committed Nov 28, 2023
1 parent ae75832 commit 6a3f7ad
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 60 deletions.
11 changes: 0 additions & 11 deletions javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1159,16 +1159,6 @@ MMCQ = (function() {
}
};

// Opens product admin view on product image click

var handleProductImageClick = function(product_id) {
if (editmode()) {
$('.product-content .product-image').click(function() {
window.open('/admin/ecommerce/products/' + product_id, '_blank').focus();
});
}
};

var init = function() {
// ADD SITE WIDE FUNCTIONS HERE
handleLanguageSwitch();
Expand Down Expand Up @@ -1196,7 +1186,6 @@ MMCQ = (function() {
initItemsPage: initItemsPage,
handleColorScheme: handleColorScheme,
handleProductPageContent: handleProductPageContent,
handleProductImageClick: handleProductImageClick,
getCombinedLightness: getCombinedLightness,
handleHeaderColorScheme: handleHeaderColorScheme,
getPhotoByWidth: getPhotoByWidth,
Expand Down
2 changes: 1 addition & 1 deletion javascripts/application.min.js

Large diffs are not rendered by default.

24 changes: 9 additions & 15 deletions layouts/auto_generated_product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,18 @@
<div class="flex-col">
<div class="content-illustrations">

{%- if product.image != blank %}
{% assign item_image_state = "with-image" %}
{%- if product.photos != blank %}
{% assign item_image_state = "with-images" %}
{% else %}
{% assign item_image_state = "without-image" %}
{% assign item_image_state = "without-images" %}
{% endif -%}

<div class="content-item-box {{ item_image_state }} js-content-item-box" href="{{ page.url }}">
<div class="item-top product-image">
{%- if product.image != blank -%}
<div class="top-inner aspect-ratio-inner product-page-image">
{%- assign image_class = "item-image not-cropped" -%}
{% image product.image target_width: "600" class: image_class loading: "lazy" %}
</div>
{%- endif -%}
</div>
<div class="content-item-box {{ item_image_state }} js-content-item-box">
{%- if product.photos == blank -%}
<div class="item-top without-pointer"></div>
{%- else -%}
{% gallery product layout="product_slider" %}
{%- endif -%}
</div>

{%- if gallery_content_size > 0 or editmode -%}
Expand Down Expand Up @@ -168,9 +165,6 @@
<script>
if (site) {
site.handleProductPageContent();
{%- if product and editmode %}
site.handleProductImageClick({{ product.id }});
{% endif -%}
}
</script>
</body>
Expand Down
11 changes: 0 additions & 11 deletions sources/javascripts/concat/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,16 +618,6 @@
}
};

// Opens product admin view on product image click

var handleProductImageClick = function(product_id) {
if (editmode()) {
$('.product-content .product-image').click(function() {
window.open('/admin/ecommerce/products/' + product_id, '_blank').focus();
});
}
};

var init = function() {
// ADD SITE WIDE FUNCTIONS HERE
handleLanguageSwitch();
Expand Down Expand Up @@ -655,7 +645,6 @@
initItemsPage: initItemsPage,
handleColorScheme: handleColorScheme,
handleProductPageContent: handleProductPageContent,
handleProductImageClick: handleProductImageClick,
getCombinedLightness: getCombinedLightness,
handleHeaderColorScheme: handleHeaderColorScheme,
getPhotoByWidth: getPhotoByWidth,
Expand Down
18 changes: 7 additions & 11 deletions sources/stylesheets/_product.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@
position: relative;
@include aspect-ratio(1, 1);

.editmode & {
cursor: pointer;
&:not(.without-pointer) {
.editmode & {
cursor: pointer;
}
}

&:hover {
Expand Down Expand Up @@ -200,7 +202,7 @@
// scss-lint:enable SelectorDepth
}

.with-image &:not(.product-page-image) {
.with-image {
background-color: rgba($color-black, .05);
border: 0;

Expand All @@ -219,12 +221,6 @@
}
}

&.product-page-image > .item-image {
width: 100%;
height: 100%;
object-fit: contain;
}

.item-placeholder {
padding: .5em;
text-transform: none;
Expand Down Expand Up @@ -334,7 +330,7 @@
margin: 24px 0;
}

.without-image .item-top {
.without-images {
background-image: url('../assets/ico-placeholder.svg');
background-color: #F2F2F2;
background-size: 40px;
Expand All @@ -355,7 +351,7 @@
opacity: .4;
display: inline-block;
}

&-final {
display: inline-block;
}
Expand Down
14 changes: 4 additions & 10 deletions stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3380,7 +3380,7 @@ ul.menu .menu-item:before {
bottom: 0;
left: 0;
}
.editmode .item-top {
.editmode .item-top:not(.without-pointer) {
cursor: pointer;
}
.item-top:hover .btn,
Expand Down Expand Up @@ -3487,11 +3487,11 @@ ul.menu .menu-item:before {
width: 100%;
height: auto;
}
.with-image .item-top .top-inner:not(.product-page-image) {
.item-top .top-inner .with-image {
background-color: rgba(0, 0, 0, 0.05);
border: 0;
}
.dark-background .with-image .item-top .top-inner:not(.product-page-image) {
.dark-background .item-top .top-inner .with-image {
background-color: rgba(255, 255, 255, 0.05);
}
.without-image .item-top .top-inner {
Expand All @@ -3502,12 +3502,6 @@ ul.menu .menu-item:before {
.dark-background .without-image .item-top .top-inner {
border-color: rgba(255, 255, 255, 0.1);
}
.item-top .top-inner.product-page-image > .item-image {
width: 100%;
height: 100%;
-o-object-fit: contain;
object-fit: contain;
}
.item-top .top-inner .item-placeholder {
padding: 0.5em;
text-transform: none;
Expand Down Expand Up @@ -3600,7 +3594,7 @@ ul.menu .menu-item:before {
.product-content .edy-buy-button-container {
margin: 24px 0;
}
.product-content .without-image .item-top {
.product-content .without-images {
background-image: url("../assets/ico-placeholder.svg");
background-color: #F2F2F2;
background-size: 40px;
Expand Down
2 changes: 1 addition & 1 deletion stylesheets/main.min.css

Large diffs are not rendered by default.

0 comments on commit 6a3f7ad

Please sign in to comment.