{% liquid if section.settings.heading != blank assign heading = section.settings.heading else assign heading = 'learn.heading' | t endif if section.settings.subheading != blank assign subheading = section.settings.subheading else assign subheading = 'learn.subheading' | t endif assign slide_count = section.blocks.size assign active_index = slide_count | minus: 1 | divided_by: 2 | floor if active_index < 0 assign active_index = 0 endif %}

{{ heading | escape }}

{{ subheading | escape }}

{% for block in section.blocks %} {% liquid assign video_src = blank if block.settings.video != blank for source in block.settings.video.sources if source.mime_type == 'video/mp4' or source.format == 'mp4' assign video_src = source.url endif endfor endif assign fallback_image = blank case forloop.index when 1 assign fallback_image = 'learn-cover-1.avif' when 2 assign fallback_image = 'learn-cover-2.avif' when 4 assign fallback_image = 'learn-cover-4.avif' when 5 assign fallback_image = 'learn-cover-5.avif' endcase assign poster_alt = heading %}
{% if block.settings.poster != blank %} {{ block.settings.poster | image_url: width: 900 | image_tag: alt: poster_alt, widths: '384, 768', sizes: '384px', class: 'learn__poster', loading: 'lazy' }} {% elsif fallback_image != blank %} {{ poster_alt | escape }} {% endif %} {% if video_src != blank %} {% endif %}
{% endfor %}
{% for block in section.blocks %}
{% for product_key in (1..2) %} {% liquid if product_key == 1 assign slide_product = block.settings.product_1 else assign slide_product = block.settings.product_2 endif %} {% if slide_product != blank %} {% liquid assign variant = slide_product.selected_or_first_available_variant assign card_image = slide_product.featured_image assign hover_image = blank for image in slide_product.images offset: 1 limit: 1 assign hover_image = image endfor %} {% endif %} {% endfor %}
{% endfor %}
{% stylesheet %} .learn { --slide: 384px; --slide-gap: 30px; position: relative; margin-top: 50px; padding: 97px 0 50px; overflow: hidden; background: linear-gradient(127deg, #f8e1ee 8%, #ffffff 60%); color: #000; font-family: Archivo, sans-serif; } .learn__blob { position: absolute; z-index: 0; pointer-events: none; user-select: none; } .learn__blob--right { top: 0; right: 219px; width: 539px; height: auto; } .learn__blob--left { top: 722px; left: 29px; width: 407px; height: auto; } .learn__header, .learn__products, .learn__progress, .learn__stage { position: relative; z-index: 1; } .learn__header { margin-bottom: 30px; padding-inline: 100px; } .learn__heading { margin: 0; font-family: "Roc Grotesk", Archivo, sans-serif; font-size: 30px; font-weight: 500; line-height: normal; text-transform: uppercase; } .learn__subheading { margin: 13px 0 0; font-size: 20px; font-weight: 300; line-height: 30px; } .learn__stage { height: 680px; } .learn__viewport { height: 100%; overflow: hidden; cursor: grab; touch-action: pan-y; } .learn__viewport.is-dragging { cursor: grabbing; } .learn__track { display: flex; align-items: center; gap: var(--slide-gap); width: max-content; height: 100%; padding-inline: calc(50% - var(--slide) / 2); } .learn__slide { flex: 0 0 var(--slide); width: var(--slide); } .learn__media { position: relative; height: 518px; overflow: hidden; border-radius: 10px; background: #f3e6ee; } .learn__slide.is-active .learn__media { height: 680px; } .learn__poster, .learn__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; } .learn__video { opacity: 0; } .learn__slide.is-playing .learn__video { opacity: 1; } .learn__slide.is-playing .learn__poster { opacity: 0; } .learn__arrow { position: absolute; top: 50%; z-index: 2; display: grid; width: 50px; height: 50px; place-items: center; padding: 0; border: 0; border-radius: 60px; background: #fff; transform: translateY(-50%); cursor: pointer; } .learn__arrow--prev { left: 50px; } .learn__arrow--next { right: 50px; } .learn__arrow:disabled { cursor: default; opacity: 0.45; } .learn__arrow-icon { display: block; } .learn__arrow--prev .learn__arrow-icon { transform: rotate(-90deg); } .learn__arrow--next .learn__arrow-icon { transform: rotate(90deg); } .learn__products { min-height: 120px; margin-top: 36px; } .learn__row { display: flex; justify-content: center; gap: 20px; } .learn__row[hidden] { display: none; } .learn__card { display: flex; align-items: center; gap: 10px; width: 384px; height: 120px; padding: 10px; border-radius: 10px; background: rgba(249, 249, 250, 0.7); } .learn__card-media { position: relative; flex: 0 0 100px; width: 100px; height: 100px; overflow: hidden; border-radius: 5px; } .learn__card-image { display: block; width: 100%; height: 100%; object-fit: cover; } .learn__card-image--hover { position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s ease; } .learn__card:hover .learn__card-image--hover, .learn__card:focus-within .learn__card-image--hover { opacity: 1; } @media (prefers-reduced-motion: reduce) { .learn__card-image--hover { transition: none; } } .learn__card-copy { min-width: 0; flex: 1 1 auto; } .learn__card-title { display: block; color: #000; font-size: 14px; font-weight: 400; line-height: normal; text-decoration: none; } .learn__card-price { margin: 5px 0 0; font-size: 16px; font-weight: 400; line-height: normal; } .learn__form { flex: 0 0 auto; margin: 0; } .learn__cart { display: grid; width: 50px; height: 50px; place-items: center; padding: 0; border: 0; border-radius: 60px; background: #9dd6c7; cursor: pointer; } .learn__cart:disabled { cursor: not-allowed; opacity: 0.45; } .learn__cart svg { display: block; } .learn__progress { position: relative; width: min(1200px, calc(100% - 200px)); height: 1px; margin: 54px auto 0; background: #e6e6e6; cursor: pointer; touch-action: none; } .learn__progress::before { content: ""; position: absolute; top: -12px; right: 0; left: 0; height: 25px; } .learn__progress-bar { position: absolute; top: 0; left: 0; height: 2px; background: #000; } .learn__arrow:focus-visible, .learn__cart:focus-visible, .learn__card-title:focus-visible, .learn__card-media:focus-visible { outline: 2px solid #000; outline-offset: 2px; } @media (max-width: 1439px) { .learn__header { padding-inline: 40px; } .learn__blob--right { right: -80px; width: 360px; } .learn__blob--left { top: auto; bottom: 40px; width: 240px; } } @media (max-width: 1024px) { .learn { --slide: 220px; --slide-gap: 16px; margin-top: 24px; padding: 40px 0 32px; } .learn__blob { display: none; } .learn__header { margin-bottom: 20px; padding-inline: 15px; } .learn__heading { font-size: 20px; } .learn__subheading { margin-top: 8px; font-size: 14px; line-height: 20px; } .learn__stage { height: 390px; } .learn__media { height: 300px; } .learn__slide.is-active .learn__media { height: 390px; } .learn__arrow { width: 40px; height: 40px; } .learn__arrow--prev { left: 12px; } .learn__arrow--next { right: 12px; } .learn__products { min-height: 0; margin-top: 20px; padding-inline: 15px; } .learn__row { flex-direction: column; align-items: center; gap: 10px; } .learn__card { width: min(384px, 100%); } .learn__progress { width: calc(100% - 30px); margin-top: 24px; } } {% endstylesheet %} {% javascript %} (() => { 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); }; const playSlide = (slide) => { const video = slide.querySelector('[data-learn-video]'); if (!video || reduceMotion) return; if (video.dataset.loaded !== 'true' && video.dataset.src) { video.dataset.loaded = 'true'; video.src = video.dataset.src; video.load(); } const mark = () => slide.classList.add('is-playing'); if (!video.paused && video.currentTime > 0) mark(); video.addEventListener('playing', mark, { once: true }); const attempt = video.play(); if (attempt && typeof attempt.catch === 'function') attempt.catch(() => {}); }; const stopSlide = (slide) => { const video = slide.querySelector('[data-learn-video]'); slide.classList.remove('is-playing'); if (video && video.dataset.loaded === 'true') video.pause(); }; const boot = (root) => { if (!root || root.dataset.ready === 'true') return; const viewport = root.querySelector('[data-viewport]'); const slides = [...root.querySelectorAll('[data-slide]')]; const rows = [...root.querySelectorAll('[data-product-row]')]; const progress = root.querySelector('[data-progress]'); const bar = root.querySelector('[data-progress-bar]'); const prev = root.querySelector('[data-learn-prev]'); const next = root.querySelector('[data-learn-next]'); if (!viewport || !slides.length) return; root.dataset.ready = 'true'; let index = Number(root.dataset.active) || 0; if (index < 0) index = 0; if (index > slides.length - 1) index = slides.length - 1; const paint = (animate) => { slides.forEach((slide, i) => { const active = i === index; slide.classList.toggle('is-active', active); if (active) playSlide(slide); else stopSlide(slide); }); rows.forEach((row, i) => { row.hidden = i !== index; }); if (bar) { const width = 100 / slides.length; const travel = 100 - width; bar.style.width = `${width}%`; bar.style.left = `${slides.length < 2 ? 0 : (index / (slides.length - 1)) * travel}%`; } if (prev) prev.disabled = index === 0; if (next) next.disabled = index === slides.length - 1; if (progress) { progress.setAttribute('aria-valuemax', String(slides.length)); progress.setAttribute('aria-valuenow', String(index + 1)); } const slide = slides[index]; const left = slide.offsetLeft - (viewport.clientWidth - slide.offsetWidth) / 2; viewport.scrollTo({ left: Math.max(left, 0), behavior: animate && !reduceMotion ? 'smooth' : 'auto' }); }; const go = (nextIndex) => { const target = Math.min(Math.max(nextIndex, 0), slides.length - 1); if (target === index) return; index = target; paint(true); }; prev?.addEventListener('click', () => go(index - 1)); next?.addEventListener('click', () => go(index + 1)); let pointerId = null; let startX = 0; let startScroll = 0; let moved = false; viewport.addEventListener('pointerdown', (event) => { if (event.button !== 0) return; if (event.target.closest('a, button')) return; pointerId = event.pointerId; startX = event.clientX; startScroll = viewport.scrollLeft; moved = false; viewport.classList.add('is-dragging'); viewport.setPointerCapture(pointerId); }); viewport.addEventListener('pointermove', (event) => { if (event.pointerId !== pointerId) return; const delta = event.clientX - startX; if (Math.abs(delta) > 4) moved = true; viewport.scrollLeft = startScroll - delta; }); const endDrag = (event) => { if (event.pointerId !== pointerId) return; pointerId = null; viewport.classList.remove('is-dragging'); if (!moved) return; const center = viewport.scrollLeft + viewport.clientWidth / 2; let nearest = index; let best = Infinity; slides.forEach((slide, i) => { const mid = slide.offsetLeft + slide.offsetWidth / 2; const distance = Math.abs(mid - center); if (distance < best) { best = distance; nearest = i; } }); index = nearest; paint(true); viewport.addEventListener('click', (clickEvent) => { clickEvent.preventDefault(); clickEvent.stopPropagation(); }, { capture: true, once: true }); }; viewport.addEventListener('pointerup', endDrag); viewport.addEventListener('pointercancel', endDrag); const indexFromClientX = (clientX) => { if (!progress || slides.length < 2) return 0; const rect = progress.getBoundingClientRect(); const ratio = Math.min(Math.max((clientX - rect.left) / rect.width, 0), 1); return Math.round(ratio * (slides.length - 1)); }; if (progress) { let progressPointer = null; progress.addEventListener('pointerdown', (event) => { if (event.button !== 0) return; progressPointer = event.pointerId; progress.setPointerCapture(progressPointer); go(indexFromClientX(event.clientX)); }); progress.addEventListener('pointermove', (event) => { if (event.pointerId !== progressPointer) return; go(indexFromClientX(event.clientX)); }); const endProgress = (event) => { if (event.pointerId !== progressPointer) return; progressPointer = null; }; progress.addEventListener('pointerup', endProgress); progress.addEventListener('pointercancel', endProgress); progress.addEventListener('keydown', (event) => { if (event.key === 'ArrowRight') go(index + 1); if (event.key === 'ArrowLeft') go(index - 1); }); } window.addEventListener('resize', () => paint(false)); paint(false); }; document.querySelectorAll('[data-learn]').forEach(boot); document.addEventListener('shopify:section:load', (event) => { const root = event.target.querySelector('[data-learn]'); if (root) { delete root.dataset.ready; boot(root); } }); if (!window.__seasonLearn) { window.__seasonLearn = true; document.addEventListener('submit', async (event) => { const form = event.target; if (!(form instanceof HTMLFormElement) || !form.classList.contains('learn__form')) return; const root = form.closest('[data-learn]'); if (!root) 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(root.dataset.cartAddUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json', }, body: JSON.stringify({ id: variantId, quantity: 1 }), }); if (!addResponse.ok) { form.submit(); return; } const cartResponse = await fetch(root.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')); } catch (error) { form.submit(); } finally { button.disabled = false; } }); } })(); {% endjavascript %} {% schema %} { "name": "t:learn.name", "tag": "section", "class": "learn-section", "disabled_on": { "groups": ["header", "footer"] }, "settings": [ { "type": "text", "id": "heading", "label": "t:learn.heading", "default": "Aprende, aplica y brilla con Seasons" }, { "type": "text", "id": "subheading", "label": "t:learn.subheading", "default": "Descubre tips, rutinas y formas reales de usar tus productos favoritos." } ], "blocks": [ { "type": "clip", "name": "t:learn.clip", "settings": [ { "type": "image_picker", "id": "poster", "label": "t:learn.poster", "info": "t:learn.poster_info" }, { "type": "video", "id": "video", "label": "t:learn.video", "info": "t:learn.video_info" }, { "type": "product", "id": "product_1", "label": "t:learn.product_1" }, { "type": "product", "id": "product_2", "label": "t:learn.product_2" } ] } ], "presets": [ { "name": "t:learn.name", "blocks": [ { "type": "clip" }, { "type": "clip" }, { "type": "clip" }, { "type": "clip" }, { "type": "clip" } ] } ] } {% endschema %}