quitar media print css
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
{% liquid
|
||||
assign product_collection = section.settings.collection
|
||||
if product_collection == blank
|
||||
assign product_collection = collections.all
|
||||
endif
|
||||
|
||||
if section.settings.heading != blank
|
||||
assign heading = section.settings.heading
|
||||
else
|
||||
assign heading = 'new_products.heading' | t
|
||||
endif
|
||||
|
||||
assign more_url = routes.all_products_collection_url
|
||||
assign feed_url = blank
|
||||
assign already_sorted = false
|
||||
if product_collection != blank
|
||||
assign more_url = product_collection.url | sort_by: 'created-descending'
|
||||
assign feed_url = more_url | append: '&view=new-products-data'
|
||||
if product_collection.default_sort_by == 'created-descending'
|
||||
assign already_sorted = true
|
||||
endif
|
||||
endif
|
||||
|
||||
assign video_src = blank
|
||||
if section.settings.video != blank
|
||||
for source in section.settings.video.sources
|
||||
if source.mime_type == 'video/mp4' or source.format == 'mp4'
|
||||
assign video_src = source.url
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
assign poster = section.settings.poster
|
||||
assign poster_url = blank
|
||||
if poster != blank
|
||||
assign poster_url = poster | image_url: width: 1000
|
||||
endif
|
||||
|
||||
if video_src == blank and section.settings.promo_link != blank
|
||||
assign promo_tag = 'a'
|
||||
else
|
||||
assign promo_tag = 'div'
|
||||
endif
|
||||
|
||||
assign products_to_show = section.settings.products_to_show | default: 8
|
||||
assign show_promo = false
|
||||
if poster != blank or video_src != blank
|
||||
assign show_promo = true
|
||||
endif
|
||||
%}
|
||||
|
||||
<section
|
||||
class="bestsellers new-products full-width"
|
||||
data-bestsellers
|
||||
data-new-products
|
||||
data-cart-add-url="{{ routes.cart_add_url }}.js"
|
||||
data-cart-url="{{ routes.cart_url }}.js"
|
||||
data-checkout-url="{{ routes.root_url }}checkout"
|
||||
data-limit="{{ products_to_show }}"
|
||||
{% if feed_url != blank %}
|
||||
data-feed="{{ feed_url }}"
|
||||
{% endif %}
|
||||
{% if already_sorted or request.design_mode %}
|
||||
data-sorted="true"
|
||||
{% endif %}
|
||||
>
|
||||
<div class="bestsellers__header">
|
||||
<h2 class="bestsellers__heading">{{ heading | escape }}</h2>
|
||||
<div class="bestsellers__tools">
|
||||
<a class="bestsellers__more" href="{{ more_url }}">{{ 'bestsellers.view_more' | t }}</a>
|
||||
<div class="bestsellers__arrows">
|
||||
<button class="bestsellers__arrow bestsellers__arrow--prev" type="button" data-slider-prev disabled aria-label="{{ 'bestsellers.previous' | t }}">
|
||||
<span class="bestsellers__arrow-icon" aria-hidden="true">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.375 9.53125L10 3.90625L15.625 9.53125M10 4.6875V16.0938" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
<button class="bestsellers__arrow bestsellers__arrow--next" type="button" data-slider-next aria-label="{{ 'bestsellers.next' | t }}">
|
||||
<span class="bestsellers__arrow-icon" aria-hidden="true">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.375 9.53125L10 3.90625L15.625 9.53125M10 4.6875V16.0938" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bestsellers__body">
|
||||
{% if show_promo %}
|
||||
<{{ promo_tag }}
|
||||
class="bestsellers__promo"
|
||||
{% if promo_tag == 'a' %}
|
||||
href="{{ section.settings.promo_link }}"
|
||||
{% endif %}
|
||||
>
|
||||
{% if poster != blank %}
|
||||
{{
|
||||
poster
|
||||
| image_url: width: 1400
|
||||
| image_tag:
|
||||
alt: heading,
|
||||
widths: '372, 486, 744, 972',
|
||||
sizes: '(max-width: 1024px) calc(100vw - 30px), 486px',
|
||||
class: 'bestsellers__promo-image new-products__poster',
|
||||
loading: 'lazy'
|
||||
}}
|
||||
{% endif %}
|
||||
|
||||
{% if video_src != blank %}
|
||||
<video
|
||||
class="new-products__video"
|
||||
data-new-products-video
|
||||
data-src="{{ video_src }}"
|
||||
{% if poster_url != blank %}
|
||||
poster="{{ poster_url }}"
|
||||
{% endif %}
|
||||
muted
|
||||
playsinline
|
||||
loop
|
||||
preload="none"
|
||||
aria-hidden="true"
|
||||
></video>
|
||||
{% endif %}
|
||||
</{{ promo_tag }}>
|
||||
{% endif %}
|
||||
|
||||
<div class="bestsellers__slider">
|
||||
<div class="bestsellers__viewport" data-viewport tabindex="0">
|
||||
<div class="bestsellers__track" data-track>
|
||||
{% if product_collection != blank and product_collection.products_count > 0 %}
|
||||
{% for product in product_collection.products limit: products_to_show %}
|
||||
{% render 'bestsellers-card', product: product, form_suffix: section.id %}
|
||||
{% endfor %}
|
||||
{% elsif request.design_mode %}
|
||||
<p class="bestsellers__empty">{{ 'bestsellers.empty' | t }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="bestsellers__progress" data-progress aria-hidden="true">
|
||||
<span class="bestsellers__progress-bar" data-progress-bar></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% stylesheet %}
|
||||
.bestsellers.new-products {
|
||||
padding-top: 100px;
|
||||
}
|
||||
|
||||
.new-products__video {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.new-products.is-playing .new-products__video {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.new-products.is-playing .new-products__poster {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.bestsellers.new-products {
|
||||
padding-top: 40px;
|
||||
}
|
||||
}
|
||||
{% endstylesheet %}
|
||||
|
||||
{% javascript %}
|
||||
(() => {
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
const markPlaying = (video) => {
|
||||
const root = video.closest('[data-new-products]');
|
||||
if (!root) return;
|
||||
root.classList.toggle('is-playing', !video.paused && !video.ended);
|
||||
};
|
||||
|
||||
const ensureSource = (video) => {
|
||||
if (video.dataset.loaded === 'true' || !video.dataset.src || reduceMotion) return;
|
||||
video.dataset.loaded = 'true';
|
||||
video.src = video.dataset.src;
|
||||
video.load();
|
||||
};
|
||||
|
||||
const playVideo = (video) => {
|
||||
ensureSource(video);
|
||||
if (video.dataset.loaded !== 'true') return;
|
||||
const attempt = video.play();
|
||||
if (attempt && typeof attempt.catch === 'function') attempt.catch(() => {});
|
||||
};
|
||||
|
||||
const watch = (video) => {
|
||||
video.addEventListener('playing', () => markPlaying(video));
|
||||
video.addEventListener('pause', () => markPlaying(video));
|
||||
video.addEventListener('ended', () => markPlaying(video));
|
||||
|
||||
if (!('IntersectionObserver' in window)) {
|
||||
playVideo(video);
|
||||
return;
|
||||
}
|
||||
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
playVideo(entry.target);
|
||||
return;
|
||||
}
|
||||
if (entry.target.dataset.loaded === 'true') entry.target.pause();
|
||||
});
|
||||
}, { rootMargin: '200px 0px' });
|
||||
|
||||
observer.observe(video);
|
||||
};
|
||||
|
||||
const boot = (root) => {
|
||||
if (!root || root.dataset.videoReady === 'true') return;
|
||||
root.dataset.videoReady = 'true';
|
||||
const video = root.querySelector('[data-new-products-video]');
|
||||
if (video) watch(video);
|
||||
};
|
||||
|
||||
document.querySelectorAll('[data-new-products]').forEach(boot);
|
||||
|
||||
document.addEventListener('shopify:section:load', (event) => {
|
||||
const root = event.target.querySelector('[data-new-products]');
|
||||
if (root) boot(root);
|
||||
});
|
||||
})();
|
||||
{% endjavascript %}
|
||||
|
||||
{% schema %}
|
||||
{
|
||||
"name": "t:new_products.name",
|
||||
"tag": "section",
|
||||
"class": "new-products-section",
|
||||
"disabled_on": {
|
||||
"groups": ["header", "footer"]
|
||||
},
|
||||
"settings": [
|
||||
{
|
||||
"type": "text",
|
||||
"id": "heading",
|
||||
"label": "t:new_products.heading",
|
||||
"default": "Nuevos productos"
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"id": "collection",
|
||||
"label": "t:new_products.collection",
|
||||
"info": "t:new_products.collection_info"
|
||||
},
|
||||
{
|
||||
"type": "range",
|
||||
"id": "products_to_show",
|
||||
"label": "t:new_products.products_to_show",
|
||||
"min": 4,
|
||||
"max": 12,
|
||||
"step": 1,
|
||||
"default": 8
|
||||
},
|
||||
{
|
||||
"type": "header",
|
||||
"content": "t:new_products.media"
|
||||
},
|
||||
{
|
||||
"type": "image_picker",
|
||||
"id": "poster",
|
||||
"label": "t:new_products.poster",
|
||||
"info": "t:new_products.poster_info"
|
||||
},
|
||||
{
|
||||
"type": "video",
|
||||
"id": "video",
|
||||
"label": "t:new_products.video",
|
||||
"info": "t:new_products.video_info"
|
||||
},
|
||||
{
|
||||
"type": "url",
|
||||
"id": "promo_link",
|
||||
"label": "t:new_products.promo_link",
|
||||
"info": "t:new_products.promo_link_info"
|
||||
}
|
||||
],
|
||||
"presets": [
|
||||
{
|
||||
"name": "t:new_products.name"
|
||||
}
|
||||
]
|
||||
}
|
||||
{% endschema %}
|
||||
Reference in New Issue
Block a user