Files
season/sections/hero.liquid
T
2026-10-02 19:32:54 -06:00

862 lines
20 KiB
Plaintext

{% liquid
assign media_type = section.settings.media_type | default: 'video'
if section.settings.cover_desktop != blank
assign cover_desktop = section.settings.cover_desktop | image_url: width: 2400
else
assign cover_desktop = 'mascara-video.avif' | asset_url
endif
if section.settings.cover_mobile != blank
assign cover_mobile = section.settings.cover_mobile | image_url: width: 1200
else
assign cover_mobile = 'mascara-vido-mobile.avif' | asset_url
endif
assign video_src = blank
if media_type == 'video'
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
if video_src == blank
assign video_src = 'home-video-op.mp4' | asset_url
endif
endif
if section.settings.social_label != blank
assign social_label = section.settings.social_label
else
assign social_label = 'hero.follow' | t
endif
if section.settings.featured_label != blank
assign featured_label = section.settings.featured_label
else
assign featured_label = 'hero.featured_label' | t
endif
assign fallback_product = blank
for catalog_product in collections.all.products
if catalog_product.available
assign fallback_product = catalog_product
break
endif
endfor
assign show_products = false
if section.blocks.size > 0
if fallback_product != blank or request.design_mode
assign show_products = true
endif
endif
for block in section.blocks
if block.settings.product != blank
assign show_products = true
endif
endfor
assign line_1_weight = section.settings.heading_line_1_weight | default: 'light'
assign line_2_weight = section.settings.heading_line_2_weight | default: 'medium'
assign line_3_weight = section.settings.heading_line_3_weight | default: 'light'
%}
<section
class="hero full-width"
data-hero
data-cart-add-url="{{ routes.cart_add_url }}.js"
data-cart-url="{{ routes.cart_url }}.js"
>
<link rel="preload" as="image" href="{{ cover_desktop }}" media="(min-width: 1024px)" fetchpriority="high">
<link rel="preload" as="image" href="{{ cover_mobile }}" media="(max-width: 1023px)" fetchpriority="high">
<div class="hero__media" aria-hidden="true">
{% if media_type == 'image' %}
<picture class="hero__still">
<source media="(max-width: 1023px)" srcset="{{ cover_mobile }}">
<img
class="hero__poster-image"
src="{{ cover_desktop }}"
alt=""
width="1920"
height="650"
fetchpriority="high"
>
</picture>
{% else %}
<video
class="hero__video"
data-hero-video
muted
loop
playsinline
preload="none"
>
<source src="{{ video_src }}" type="video/mp4">
</video>
<picture class="hero__poster">
<source media="(max-width: 1023px)" srcset="{{ cover_mobile }}">
<img
class="hero__poster-image"
src="{{ cover_desktop }}"
alt=""
width="1920"
height="650"
fetchpriority="high"
>
</picture>
{% endif %}
</div>
<div class="hero__content">
<div class="hero__copy">
{% if section.settings.heading_line_1 != blank or section.settings.heading_line_2 != blank or section.settings.heading_line_3 != blank %}
<h1 class="hero__title">
{% if section.settings.heading_line_1 != blank %}
<span class="hero__title-line hero__title-line--{{ line_1_weight }}">{{ section.settings.heading_line_1 | escape }}</span>
{% endif %}
{% if section.settings.heading_line_2 != blank %}
<span class="hero__title-line hero__title-line--{{ line_2_weight }}">{{ section.settings.heading_line_2 | escape }}</span>
{% endif %}
{% if section.settings.heading_line_3 != blank %}
<span class="hero__title-line hero__title-line--{{ line_3_weight }}">{{ section.settings.heading_line_3 | escape }}</span>
{% endif %}
</h1>
<span class="hero__rule" aria-hidden="true"></span>
{% endif %}
{% if show_products %}
<p class="hero__label">{{ featured_label | escape }}</p>
<div class="hero__products">
{% for block in section.blocks %}
{% liquid
assign featured_product = block.settings.product
if featured_product == blank and forloop.first
assign featured_product = fallback_product
endif
%}
{% if featured_product != blank %}
<div class="hero__product" {{ block.shopify_attributes }}>
{% render 'hero-product', product: featured_product %}
</div>
{% elsif request.design_mode %}
<div class="hero__product" {{ block.shopify_attributes }}>
<div class="hero__card hero__card--empty">
<p>{{ 'hero.select_product' | t }}</p>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
</div>
</div>
<aside class="hero__social">
<p class="hero__social-label">{{ social_label | escape }}</p>
<span class="hero__social-line" aria-hidden="true"></span>
<ul class="hero__social-list">
<li>
{% if section.settings.instagram_url != blank %}
<a class="hero__social-item" href="{{ section.settings.instagram_url }}" target="_blank" rel="noopener" aria-label="{{ 'hero.instagram' | t }}">
{{ 'icon-instagram.svg' | inline_asset_content }}
</a>
{% else %}
<span class="hero__social-item" aria-hidden="true">
{{ 'icon-instagram.svg' | inline_asset_content }}
</span>
{% endif %}
</li>
<li>
{% if section.settings.facebook_url != blank %}
<a class="hero__social-item" href="{{ section.settings.facebook_url }}" target="_blank" rel="noopener" aria-label="{{ 'hero.facebook' | t }}">
{{ 'icon-facebook.svg' | inline_asset_content }}
</a>
{% else %}
<span class="hero__social-item" aria-hidden="true">
{{ 'icon-facebook.svg' | inline_asset_content }}
</span>
{% endif %}
</li>
<li>
{% if section.settings.linkedin_url != blank %}
<a class="hero__social-item" href="{{ section.settings.linkedin_url }}" target="_blank" rel="noopener" aria-label="{{ 'hero.linkedin' | t }}">
{{ 'icon-linkedin.svg' | inline_asset_content }}
</a>
{% else %}
<span class="hero__social-item" aria-hidden="true">
{{ 'icon-linkedin.svg' | inline_asset_content }}
</span>
{% endif %}
</li>
</ul>
</aside>
</section>
{% stylesheet %}
.hero {
position: relative;
width: 100%;
min-height: 650px;
overflow: hidden;
color: #fff;
background: #c8c2bc;
}
.hero__media {
position: absolute;
inset: 0;
}
.hero__video,
.hero__poster,
.hero__still,
.hero__poster-image {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
max-width: none;
object-fit: cover;
object-position: center center;
}
.hero__poster,
.hero__still {
z-index: 1;
transition: opacity 0.45s ease;
}
.hero.is-playing .hero__poster {
opacity: 0;
pointer-events: none;
}
.hero__content {
position: relative;
z-index: 2;
display: flex;
min-height: 650px;
padding: 104px 160px 80px 100px;
}
.hero__copy {
width: min(100%, 800px);
}
.hero__title {
margin: 0;
color: #fff;
font-family: "Roc Grotesk", Archivo, sans-serif;
font-size: 70px;
font-weight: 500;
line-height: 69px;
text-transform: uppercase;
}
.hero__title-line {
display: block;
white-space: nowrap;
}
.hero__title-line--light {
font-weight: 300;
}
.hero__title-line--medium {
font-weight: 500;
}
.hero__rule {
display: block;
width: 578px;
max-width: 100%;
height: 1px;
margin-top: 40px;
background: #fff;
}
.hero__label {
margin: 40px 0 20px;
color: #fff;
font-family: Archivo, sans-serif;
font-size: 14px;
font-weight: 300;
line-height: normal;
}
.hero__products {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.hero__card {
display: grid;
grid-template-columns: 100px minmax(0, 1fr) 50px;
column-gap: 10px;
align-items: center;
width: 384px;
height: 120px;
padding: 10px;
border-radius: 10px;
background: rgba(249, 249, 250, 0.5);
backdrop-filter: blur(3px);
}
.hero__card--empty {
display: flex;
color: #000;
font-family: Archivo, sans-serif;
font-size: 14px;
font-weight: 400;
}
.hero__card-media {
position: relative;
display: block;
width: 100px;
height: 100px;
overflow: hidden;
border-radius: 5px;
}
.hero__card-image {
width: 100%;
height: 100%;
max-width: none;
object-fit: cover;
transition: transform 0.35s ease;
}
.hero__card:hover .hero__card-image,
.hero__card:focus-within .hero__card-image {
transform: scale(1.06);
}
.hero__card-image--hover {
position: absolute;
inset: 0;
opacity: 0;
transition: opacity 0.35s ease, transform 0.35s ease;
}
.hero__card:hover .hero__card-image--hover,
.hero__card:focus-within .hero__card-image--hover {
opacity: 1;
}
.hero__card-title {
background-image: linear-gradient(currentColor, currentColor);
background-position: 0 100%;
background-repeat: no-repeat;
background-size: 0 1px;
transition: background-size 0.25s ease;
}
.hero__card:hover .hero__card-title,
.hero__card-title:focus-visible {
background-size: 100% 1px;
}
@media (prefers-reduced-motion: reduce) {
.hero__card-image,
.hero__card-image--hover,
.hero__card-title {
transition: none;
}
.hero__card:hover .hero__card-image,
.hero__card:focus-within .hero__card-image {
transform: none;
}
}
.hero__card-copy {
display: flex;
min-width: 0;
flex-direction: column;
gap: 5px;
}
.hero__card-title {
display: -webkit-box;
overflow: hidden;
color: #000;
font-family: Archivo, sans-serif;
font-size: 14px;
font-weight: 400;
line-height: normal;
text-decoration: none;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.hero__card-price {
margin: 0;
color: #000;
font-family: Archivo, sans-serif;
font-size: 16px;
font-weight: 400;
line-height: normal;
}
.hero__form {
display: flex;
justify-content: flex-end;
}
.hero__cart {
display: grid;
width: 50px;
height: 50px;
place-items: center;
padding: 0;
border: 0;
border-radius: 60px;
background: #9dd6c7;
cursor: pointer;
}
.hero__cart:disabled {
cursor: not-allowed;
opacity: 0.55;
}
.hero__cart.is-added {
outline: 2px solid #000;
outline-offset: 2px;
}
.hero__cart-icon {
display: block;
width: 25px;
height: 25px;
}
.hero__cart-icon svg {
width: 25px;
height: 25px;
}
.hero__social {
position: absolute;
top: 151px;
right: 100px;
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}
.hero__social-label {
margin: 0;
color: #fff;
font-family: "Roc Grotesk", Archivo, sans-serif;
font-size: 16px;
font-weight: 500;
line-height: normal;
text-transform: uppercase;
writing-mode: vertical-rl;
}
.hero__social-line {
display: block;
width: 1px;
height: 80px;
background: #fff;
}
.hero__social-list {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
margin: 0;
padding: 0;
list-style: none;
}
.hero__social-item {
display: flex;
width: 37px;
height: 37px;
align-items: center;
justify-content: center;
color: #fff;
}
.hero__social-item svg {
max-width: none;
}
@media (max-width: 1439px) {
.hero__content {
padding-right: 120px;
padding-left: 40px;
}
.hero__social {
right: 40px;
}
}
@media (max-width: 1023px) {
.hero,
.hero__content {
min-height: 550px;
}
.hero__video,
.hero__poster-image {
object-position: center 22%;
}
.hero__content {
align-items: flex-end;
padding: 24px 20px 15px;
}
.hero__title {
font-size: 35px;
line-height: 40px;
}
.hero__rule {
width: 253px;
margin-top: 20px;
}
.hero__label {
margin: 10px 0;
font-size: 10px;
}
.hero__products {
flex-direction: column;
gap: 10px;
}
.hero__card {
grid-template-columns: 70px minmax(0, 1fr) 40px;
width: 100%;
max-width: 297px;
height: 80px;
padding: 5px;
}
.hero__card-media {
width: 70px;
height: 70px;
}
.hero__card-title {
font-size: 12px;
}
.hero__card-price {
font-size: 14px;
}
.hero__cart {
width: 40px;
height: 40px;
}
.hero__cart-icon,
.hero__cart-icon svg {
width: 18px;
height: 18px;
}
.hero__social {
display: none;
}
}
@media (max-width: 380px) {
.hero__title-line {
white-space: normal;
}
}
@media (prefers-reduced-motion: reduce) {
.hero__video {
display: none;
}
.hero__poster {
transition: none;
}
}
{% endstylesheet %}
<script nolazy>
(() => {
if (window.__seasonHeroVideo) return;
window.__seasonHeroVideo = true;
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const events = ['keydown', 'mousedown', 'mousemove', 'touchstart', 'wheel'];
const start = () => {
events.forEach((eventName) => window.removeEventListener(eventName, start));
document.querySelectorAll('[data-hero-video]').forEach((video) => {
const hero = video.closest('[data-hero]');
const play = () => {
const attempt = video.play();
if (attempt && typeof attempt.catch === 'function') attempt.catch(() => {});
};
video.addEventListener('playing', () => hero?.classList.add('is-playing'));
video.preload = 'auto';
if (video.readyState >= 2) play();
else video.addEventListener('canplay', play, { once: true });
video.load();
});
};
events.forEach((eventName) => window.addEventListener(eventName, start, { passive: true }));
})();
</script>
{% javascript %}
(() => {
if (window.__seasonHero) return;
window.__seasonHero = true;
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const setCartCount = (count) => {
const link = document.querySelector('.header__cart');
if (!link || count < 1) return;
let badge = link.querySelector('[data-cart-count]');
if (!badge) {
badge = document.createElement('span');
badge.className = 'absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand-mint px-[3px] text-[10px] font-medium leading-none text-black';
badge.setAttribute('data-cart-count', '');
link.appendChild(badge);
}
badge.textContent = String(count);
};
document.querySelectorAll('[data-hero]').forEach((hero) => {
const video = hero.querySelector('[data-hero-video]');
if (!video || reduceMotion) return;
const markPlaying = () => hero.classList.add('is-playing');
video.addEventListener('playing', markPlaying);
const tryPlay = () => {
const playAttempt = video.play();
if (playAttempt && typeof playAttempt.catch === 'function') {
playAttempt.catch(() => {});
}
};
if (video.readyState >= 2) {
tryPlay();
} else {
video.addEventListener('canplay', tryPlay, { once: true });
}
});
document.addEventListener('submit', async (event) => {
const form = event.target;
if (!(form instanceof HTMLFormElement) || !form.classList.contains('hero__form')) return;
const hero = form.closest('[data-hero]');
if (!hero) return;
event.preventDefault();
const button = form.querySelector('[type="submit"]');
const variantId = form.querySelector('[name="id"]')?.value;
if (!button || button.disabled || !variantId) return;
button.disabled = true;
try {
const addResponse = await fetch(hero.dataset.cartAddUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({ id: variantId, quantity: 1 }),
});
if (!addResponse.ok) return;
const cartResponse = await fetch(hero.dataset.cartUrl, {
headers: { Accept: 'application/json' },
});
const cart = await cartResponse.json();
if (typeof cart.item_count === 'number') setCartCount(cart.item_count);
document.dispatchEvent(new CustomEvent('season:cart:open'));
button.classList.add('is-added');
window.setTimeout(() => button.classList.remove('is-added'), 1200);
} catch (error) {
form.submit();
} finally {
button.disabled = false;
}
});
})();
{% endjavascript %}
{% schema %}
{
"name": "t:hero.name",
"tag": "section",
"class": "hero-section",
"max_blocks": 2,
"disabled_on": {
"groups": ["header", "footer"]
},
"settings": [
{
"type": "header",
"content": "t:hero.heading"
},
{
"type": "text",
"id": "heading_line_1",
"label": "t:hero.line_1",
"default": "descubre"
},
{
"type": "select",
"id": "heading_line_1_weight",
"label": "t:hero.line_1_weight",
"default": "light",
"options": [
{ "value": "light", "label": "t:hero.weight_light" },
{ "value": "medium", "label": "t:hero.weight_medium" }
]
},
{
"type": "text",
"id": "heading_line_2",
"label": "t:hero.line_2",
"default": "lo que tu piel"
},
{
"type": "select",
"id": "heading_line_2_weight",
"label": "t:hero.line_2_weight",
"default": "medium",
"options": [
{ "value": "light", "label": "t:hero.weight_light" },
{ "value": "medium", "label": "t:hero.weight_medium" }
]
},
{
"type": "text",
"id": "heading_line_3",
"label": "t:hero.line_3",
"default": "disfrutará"
},
{
"type": "select",
"id": "heading_line_3_weight",
"label": "t:hero.line_3_weight",
"default": "light",
"options": [
{ "value": "light", "label": "t:hero.weight_light" },
{ "value": "medium", "label": "t:hero.weight_medium" }
]
},
{
"type": "text",
"id": "featured_label",
"label": "t:hero.featured_label",
"default": "Producto destacado"
},
{
"type": "header",
"content": "t:hero.media"
},
{
"type": "select",
"id": "media_type",
"label": "t:hero.media_type",
"default": "video",
"options": [
{ "value": "video", "label": "t:hero.media_video" },
{ "value": "image", "label": "t:hero.media_image" }
]
},
{
"type": "video",
"id": "video",
"label": "t:hero.video",
"info": "t:hero.video_info",
"visible_if": "{{ section.settings.media_type == 'video' }}"
},
{
"type": "image_picker",
"id": "cover_desktop",
"label": "t:hero.cover_desktop",
"info": "t:hero.cover_info"
},
{
"type": "image_picker",
"id": "cover_mobile",
"label": "t:hero.cover_mobile"
},
{
"type": "header",
"content": "t:hero.social"
},
{
"type": "text",
"id": "social_label",
"label": "t:hero.social_label",
"default": "Síguenos"
},
{
"type": "url",
"id": "instagram_url",
"label": "t:hero.instagram"
},
{
"type": "url",
"id": "facebook_url",
"label": "t:hero.facebook"
},
{
"type": "url",
"id": "linkedin_url",
"label": "t:hero.linkedin"
}
],
"blocks": [
{
"type": "featured_product",
"name": "t:hero.featured_product",
"limit": 2,
"settings": [
{
"type": "product",
"id": "product",
"label": "t:hero.product"
}
]
}
],
"presets": [
{
"name": "t:hero.name",
"blocks": [
{ "type": "featured_product" }
]
}
]
}
{% endschema %}