Demas ajustes

This commit is contained in:
2026-10-09 23:02:05 -06:00
parent 220178d421
commit f9666c4088
83 changed files with 10271 additions and 6509 deletions
+382 -444
View File
@@ -17,7 +17,7 @@
data-header
data-menu-close="{{ 'header.menu_close' | t | escape }}"
>
<div class="header__shell relative grid grid-cols-[auto_minmax(0,699px)_1fr_auto_auto] items-center px-[100px] pt-[15px] xxl:px-10">
<div class="header__shell relative grid grid-cols-[auto_minmax(0,699px)_1fr_auto_auto] items-center px-[100px] pt-[15px]">
<button
type="button"
class="header__toggle col-start-1 row-start-1 hidden size-[30px] cursor-pointer appearance-none items-center justify-center border-0 bg-transparent p-0"
@@ -33,7 +33,7 @@
</button>
<a
class="header__logo col-start-1 row-start-1 mr-[50px] block w-[223px] shrink-0 no-underline xxl:mr-8"
class="header__logo col-start-1 row-start-1 mr-[50px] block w-[223px] shrink-0 no-underline"
href="{{ routes.root_url }}"
>
{% if section.settings.logo != blank %}
@@ -51,11 +51,12 @@
</a>
<form
class="header__search col-start-2 row-start-1 mr-[50px] flex h-[55px] w-full min-w-0 max-w-[699px] items-center rounded-full bg-brand-cloud p-[5px] xxl:mr-8"
class="header__search col-start-2 row-start-1 mr-[50px] flex h-[55px] w-full min-w-0 max-w-[699px] items-center rounded-full bg-brand-cloud p-[5px]"
action="{{ routes.search_url }}"
method="get"
role="search"
data-search
data-predictive-url="{{ routes.predictive_search_url }}"
>
<button
type="submit"
@@ -76,13 +77,44 @@
{% if template.name == 'search' %}
value="{{ search.terms | escape }}"
{% endif %}
role="combobox"
aria-expanded="false"
aria-controls="header-predictive-{{ section.id }}"
aria-autocomplete="list"
autocomplete="off"
data-search-input
>
<div
id="header-predictive-{{ section.id }}"
class="header__predictive"
data-predictive
role="listbox"
hidden
></div>
<p class="sr-only" data-predictive-status aria-live="polite"></p>
</form>
<div class="header__actions col-start-5 row-start-1 flex items-center">
<button
type="button"
class="header__cart relative col-start-5 row-start-1 flex size-[45px] cursor-pointer appearance-none items-center justify-center border-0 bg-transparent p-0"
class="header__wish relative flex size-[45px] cursor-pointer appearance-none items-center justify-center border-0 bg-transparent p-0"
data-wish-open
data-count-label="{{ 'header.wishlist_count' | t: count: '__COUNT__' | escape }}"
aria-controls="wish-drawer"
aria-expanded="false"
aria-haspopup="dialog"
aria-label="{{ 'header.wishlist' | t }}"
>
<span class="header__icon header__icon--wish" aria-hidden="true">
<svg width="22" height="22" viewBox="0 0 25 25" fill="none">
<path d="M17.2324 3.90625C14.0625 3.90625 12.5 7.03125 12.5 7.03125C12.5 7.03125 10.9375 3.90625 7.76758 3.90625C5.19141 3.90625 3.15137 6.06152 3.125 8.6333C3.07129 13.9717 7.35986 17.7681 12.0605 20.9585C12.1901 21.0467 12.3433 21.0938 12.5 21.0938C12.6567 21.0938 12.8099 21.0467 12.9395 20.9585C17.6396 17.7681 21.9282 13.9717 21.875 8.6333C21.8486 6.06152 19.8086 3.90625 17.2324 3.90625Z" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</span>
<span class="header__wish-count absolute right-0 top-0 hidden h-4 min-w-4 items-center justify-center rounded-full bg-brand-mint px-[3px] text-[10px] font-medium leading-none text-black" data-wish-count></span>
</button>
<button
type="button"
class="header__cart relative flex size-[45px] cursor-pointer appearance-none items-center justify-center border-0 bg-transparent p-0"
data-cart-open
data-cart-count-label="{{ 'header.cart_count' | t: count: '__COUNT__' | escape }}"
aria-controls="cart-drawer"
@@ -99,6 +131,7 @@
</span>
{% endif %}
</button>
</div>
<nav
id="header-menu"
@@ -188,23 +221,48 @@
assign skin_menu = label_combination | append: '::/collections/piel-mixta-grasa|' | append: label_oily | append: '::/collections/piel-grasa|' | append: label_dry | append: '::/collections/piel-seca-1'
assign concern_menu = label_sun | append: '::/collections/proteccion-solar-1|' | append: label_oil | append: '::/collections/control-grasa|' | append: label_acne | append: '::/collections/acne-1|' | append: label_hydration | append: '::/collections/hidratacion|' | append: label_aging | append: '::/collections/antiedad-1|' | append: label_spots | append: '::/collections/aclarar'
%}
{% render 'header-menu-item', title: nav_categories, url: '/collections/all-products', child_menu: categories_menu %}
{% render 'header-menu-item', title: nav_routine, url: routes.collections_url, child_menu: routine_menu %}
{% render 'header-menu-item', title: nav_skin_type, url: routes.collections_url, child_menu: skin_menu %}
{% render 'header-menu-item', title: nav_concern, url: routes.collections_url, child_menu: concern_menu %}
{% render 'header-menu-item', title: nav_categories, url: '/collections/all-products', child_menu: categories_menu, image_set: 'categories' %}
{% render 'header-menu-item', title: nav_routine, url: routes.collections_url, child_menu: routine_menu, image_set: 'routine' %}
{% render 'header-menu-item', title: nav_skin_type, url: routes.collections_url, child_menu: skin_menu, image_set: 'skin' %}
{% render 'header-menu-item', title: nav_concern, url: routes.collections_url, child_menu: concern_menu, image_set: 'concern' %}
{% endif %}
</ul>
<ul class="header__pills m-0 flex list-none items-center gap-[15px] p-0">
{% assign favorites_label = 'header.links.favorites' | t | downcase %}
{% if section.settings.pills_menu != blank and section.settings.pills_menu.links.size > 0 %}
{% for link in section.settings.pills_menu.links %}
{% liquid
assign pill_title = link.title | strip | downcase
assign pill_handle = link.title | handleize
assign open_wishlist = false
if pill_title == favorites_label
assign open_wishlist = true
endif
if pill_handle == 'los-favoritos'
assign open_wishlist = true
endif
%}
<li>
<a
class="inline-flex items-center justify-center rounded-full border border-solid border-black px-5 py-1 text-[14px] font-normal leading-none text-black no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-black"
href="{{ link.url }}"
>
{{ link.title }}
</a>
{% if open_wishlist %}
<button
type="button"
class="inline-flex cursor-pointer appearance-none items-center justify-center rounded-full border border-solid border-black bg-transparent px-5 py-1 font-sans text-[14px] font-normal leading-none text-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-black"
data-wish-open
aria-controls="wish-drawer"
aria-expanded="false"
aria-haspopup="dialog"
>
{{ link.title }}
</button>
{% else %}
<a
class="inline-flex items-center justify-center rounded-full border border-solid border-black px-5 py-1 text-[14px] font-normal leading-none text-black no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-black"
href="{{ link.url }}"
>
{{ link.title }}
</a>
{% endif %}
</li>
{% endfor %}
{% else %}
@@ -213,6 +271,18 @@
{{ 'header.links.sunscreen' | t }}
</a>
</li>
<li>
<button
type="button"
class="inline-flex cursor-pointer appearance-none items-center justify-center rounded-full border border-solid border-black bg-transparent px-5 py-1 font-sans text-[14px] font-normal leading-none text-black"
data-wish-open
aria-controls="wish-drawer"
aria-expanded="false"
aria-haspopup="dialog"
>
{{ 'header.links.favorites' | t }}
</button>
</li>
<li>
<a class="inline-flex items-center justify-center rounded-full border border-solid border-black px-5 py-1 text-[14px] font-normal leading-none text-black no-underline" href="/collections/kits-skincare-facial">
{{ 'header.links.kits' | t }}
@@ -252,438 +322,22 @@
></button>
</header>
{% stylesheet %}
.header__logo-mark svg,
.header__logo-image {
display: block;
width: 223px;
height: auto;
}
<div id="wish-drawer" class="wish-drawer" data-wish-drawer data-empty="{{ 'header.wishlist_empty' | t | escape }}" data-remove="{{ 'header.wishlist_remove' | t | escape }}" aria-hidden="true">
<button class="wish-drawer__backdrop" type="button" data-wish-close tabindex="-1" aria-label="{{ 'header.wishlist_close' | t }}"></button>
<div class="wish-drawer__panel" role="dialog" aria-modal="true" aria-labelledby="wish-drawer-title">
<div class="wish-drawer__head">
<h2 id="wish-drawer-title" class="wish-drawer__title">{{ 'header.wishlist' | t }}</h2>
<button class="wish-drawer__close" type="button" data-wish-close aria-label="{{ 'header.wishlist_close' | t }}">
<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true" focusable="false">
<path d="M2 2l10 10M12 2L2 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
</svg>
</button>
</div>
<div class="wish-drawer__list" data-wish-list></div>
</div>
</div>
.header__icon {
display: flex;
align-items: center;
justify-content: center;
}
.header__icon svg {
display: block;
}
.header__icon--menu svg {
width: 30px;
height: 30px;
}
.header__icon--search svg {
width: 22px;
height: 22px;
}
.header__icon--user svg {
width: 22px;
height: 22px;
}
.header__icon--bag svg {
width: 30px;
height: 30px;
}
.header__shell {
z-index: 2;
}
.header__promo {
position: relative;
z-index: 1;
}
.header__caret-button {
width: 10px;
height: 10px;
}
.header__submenu {
min-width: 280px;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}
.header__icon--caret {
display: flex;
transform: rotate(180deg);
transition: transform 0.2s ease;
}
.header__icon--caret svg {
width: 10px;
height: 10px;
}
.header__item.is-open .header__icon--caret {
transform: rotate(0deg);
}
.header__icon--close {
display: none;
position: relative;
width: 18px;
height: 18px;
}
.header__icon--close::before,
.header__icon--close::after {
content: '';
position: absolute;
left: 0;
top: 8px;
width: 18px;
height: 1.4px;
background: #000;
}
.header__icon--close::before {
transform: rotate(45deg);
}
.header__icon--close::after {
transform: rotate(-45deg);
}
.header__account-label {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.header button,
.header input {
font: inherit;
color: inherit;
}
.header input[type='search']::-webkit-search-decoration,
.header input[type='search']::-webkit-search-cancel-button {
appearance: none;
}
@media (min-width: 1120px) {
.header__submenu::before {
content: '';
position: absolute;
top: -16px;
left: 0;
width: 100%;
height: 16px;
}
.header__submenu {
margin-top: 8px;
}
.header__item:hover > .header__submenu,
.header__item:focus-within > .header__submenu,
.header__item.is-open > .header__submenu {
display: block;
}
}
@media (max-width: 1119px) {
.header__shell {
position: relative;
display: flex;
align-items: center;
height: 55px;
padding: 0 10px;
}
.header__toggle {
display: grid;
position: relative;
z-index: 50;
order: 1;
flex: 0 0 30px;
}
.header.is-menu-open .header__icon--menu {
display: none;
}
.header.is-menu-open .header__icon--close {
display: block;
}
.header__logo {
position: absolute;
top: 0;
left: 50%;
z-index: 1;
display: flex;
align-items: center;
width: 150px;
height: 55px;
margin: 0;
transform: translateX(-50%);
}
.header__logo-mark svg,
.header__logo-image {
width: 150px;
}
.header__search {
position: absolute;
top: 12px;
right: 50px;
z-index: 2;
width: 30px;
height: 30px;
max-width: none;
margin: 0;
padding: 0;
overflow: hidden;
background: transparent;
}
.header__search-button {
width: 30px;
height: 30px;
background-color: #9dd6c7;
border-radius: 999px;
}
.header__icon--search svg {
width: 14px;
height: 14px;
}
.header__search-input {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.header__search.is-open {
top: 6px;
right: 50px;
left: 10px;
z-index: 3;
width: auto;
height: 44px;
overflow: visible;
padding: 5px;
background: #f8f8f8;
}
.header__search.is-open .header__search-input {
position: static;
width: auto;
height: auto;
margin: 0;
padding: 0 12px;
overflow: visible;
clip: auto;
white-space: normal;
}
.header__cart {
position: absolute;
top: 12px;
right: 10px;
z-index: 2;
flex: 0 0 30px;
width: 30px;
height: 30px;
}
.header__icon--bag svg {
width: 18px;
height: 18px;
}
.header__nav {
position: absolute;
top: 100%;
right: 0;
left: 0;
z-index: 40;
display: none;
pointer-events: auto;
max-height: calc(100dvh - 90px);
overflow: auto;
background: #fff;
padding: 8px 16px 28px;
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
}
.header__nav.is-open {
display: flex;
flex-direction: column;
gap: 20px;
}
.header__menu {
order: 1;
flex-direction: column;
align-items: stretch;
gap: 20px;
margin-top: 0;
padding-top: 4px;
}
.header__links {
flex-direction: column;
align-items: stretch;
gap: 0;
}
.header__links .header__item {
flex-wrap: wrap;
justify-content: space-between;
width: 100%;
padding: 14px 0;
border-bottom: 1px solid #ececec;
}
.header__caret-button {
width: 32px;
height: 32px;
}
.header__nav .header__submenu {
position: static;
top: auto;
left: auto;
z-index: auto;
flex: 0 0 100%;
min-width: 0;
width: 100%;
margin: 8px 0 0;
padding: 4px 0 8px;
background: transparent;
border-radius: 0;
box-shadow: none;
}
.header__nav .header__item.is-open > .header__submenu {
display: flex;
flex-direction: column;
gap: 12px;
}
.header__pills {
flex-wrap: wrap;
gap: 10px;
}
.header__utility {
order: 2;
flex-direction: column;
align-items: flex-start;
gap: 8px;
margin-right: 0;
}
.header__utility > ul {
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.header__account {
width: auto;
height: auto;
justify-content: flex-start;
gap: 10px;
padding: 10px 20px 10px 0;
}
.header__account-label {
position: static;
width: auto;
height: auto;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal;
}
.header__promo {
height: 30px;
}
.header__promo a,
.header__promo p {
font-size: 14px;
}
.header.is-menu-open .header__shell {
z-index: 3;
}
.header.is-menu-open .header__backdrop {
z-index: 1;
display: block;
}
}
@media (max-width: 380px) {
.header__logo,
.header__logo-mark svg,
.header__logo-image {
width: 128px;
}
}
.header__item > a,
.header__submenu a,
.header__utility a {
background-image: linear-gradient(currentColor, currentColor);
background-position: 0 100%;
background-repeat: no-repeat;
background-size: 0 1px;
transition: background-size 0.25s ease;
}
.header__item > a:hover,
.header__item > a:focus-visible,
.header__submenu a:hover,
.header__submenu a:focus-visible,
.header__utility a:hover,
.header__utility a:focus-visible {
background-size: 100% 1px;
}
.header__pills a {
transition: background-color 0.2s ease, color 0.2s ease;
}
.header__pills a:hover,
.header__pills a:focus-visible {
background: #9dd6c7;
}
@media (prefers-reduced-motion: reduce) {
.header__item > a,
.header__submenu a,
.header__utility a,
.header__pills a {
transition: none;
}
}
{% endstylesheet %}
{% javascript %}
(() => {
@@ -692,6 +346,15 @@
const mobileQuery = window.matchMedia('(max-width: 1119px)');
const setHeaderOffset = () => {
const group = document.querySelector('.shopify-section-group-header-group');
if (!group) return;
document.documentElement.style.setProperty('--header-offset', group.offsetHeight + 'px');
};
setHeaderOffset();
window.addEventListener('resize', setHeaderOffset);
const closeMenu = (header) => {
const menu = header.querySelector('[data-menu]');
const toggle = header.querySelector('[data-menu-toggle]');
@@ -702,8 +365,20 @@
document.documentElement.classList.remove('overflow-hidden');
};
const closePredictive = (header) => {
const panel = header.querySelector('[data-predictive]');
const input = header.querySelector('[data-search-input]');
const status = header.querySelector('[data-predictive-status]');
panel?.classList.remove('is-open');
panel?.setAttribute('hidden', '');
input?.setAttribute('aria-expanded', 'false');
input?.removeAttribute('aria-activedescendant');
if (status) status.textContent = '';
};
const closeSearch = (header) => {
header.querySelector('[data-search]')?.classList.remove('is-open');
closePredictive(header);
};
const bind = (header) => {
@@ -741,6 +416,98 @@
searchInput?.focus();
});
if (searchForm && searchInput) {
const panel = searchForm.querySelector('[data-predictive]');
const status = searchForm.querySelector('[data-predictive-status]');
let requestId = 0;
let controller = null;
let timer = 0;
const resultOptions = () => [...panel.querySelectorAll('[role="option"]')];
const setActive = (index) => {
const items = resultOptions();
items.forEach((item, itemIndex) => {
const active = itemIndex === index;
item.classList.toggle('is-active', active);
if (active) searchInput.setAttribute('aria-activedescendant', item.id);
});
if (index < 0) searchInput.removeAttribute('aria-activedescendant');
if (index >= 0 && items[index]) items[index].scrollIntoView({ block: 'nearest' });
};
const openPredictive = () => {
panel.hidden = false;
panel.classList.add('is-open');
searchInput.setAttribute('aria-expanded', 'true');
};
const fetchResults = (term) => {
const id = ++requestId;
controller?.abort();
controller = new AbortController();
const url = new URL(searchForm.dataset.predictiveUrl, window.location.origin);
url.searchParams.set('q', term);
url.searchParams.set('resources[type]', 'product');
url.searchParams.set('resources[limit]', '6');
url.searchParams.set('resources[options][unavailable_products]', 'last');
url.searchParams.set('section_id', 'predictive-search');
fetch(url, { signal: controller.signal })
.then((response) => {
if (!response.ok) throw new Error('predictive search failed');
return response.text();
})
.then((html) => {
if (id !== requestId || searchInput.value.trim() !== term) return;
const parsed = new DOMParser().parseFromString(html, 'text/html');
const body = parsed.querySelector('.header__predictive-body');
if (!body) {
closePredictive(header);
return;
}
panel.replaceChildren(body);
const count = panel.querySelector('[data-predictive-count]');
if (status && count) status.textContent = count.textContent;
setActive(-1);
openPredictive();
})
.catch((error) => {
if (error.name === 'AbortError') return;
if (id === requestId) closePredictive(header);
});
};
searchInput.addEventListener('input', () => {
const term = searchInput.value.trim();
window.clearTimeout(timer);
if (term.length < 3) {
requestId += 1;
controller?.abort();
closePredictive(header);
return;
}
timer = window.setTimeout(() => fetchResults(term), 180);
});
searchInput.addEventListener('keydown', (event) => {
if (!panel.classList.contains('is-open')) return;
const items = resultOptions();
if (items.length === 0) return;
const current = items.findIndex((item) => item.classList.contains('is-active'));
if (event.key === 'ArrowDown') {
event.preventDefault();
setActive(current < items.length - 1 ? current + 1 : 0);
} else if (event.key === 'ArrowUp') {
event.preventDefault();
setActive(current > 0 ? current - 1 : items.length - 1);
} else if (event.key === 'Enter' && current >= 0) {
event.preventDefault();
window.location.assign(items[current].href);
}
});
}
menu?.addEventListener('click', (event) => {
const submenuToggle = event.target.closest('[data-submenu-toggle]');
const toggleSubmenu = (submenuToggle) => {
@@ -782,6 +549,8 @@
document.addEventListener('click', (event) => {
document.querySelectorAll('[data-header]').forEach((header) => {
const searchForm = header.querySelector('[data-search]');
if (searchForm && !searchForm.contains(event.target)) closePredictive(header);
if (header.contains(event.target)) return;
closeMenu(header);
closeSearch(header);
@@ -790,7 +559,13 @@
document.addEventListener('keydown', (event) => {
if (event.key !== 'Escape') return;
if (document.querySelector('[data-wish-drawer].is-open')) return;
document.querySelectorAll('[data-header]').forEach((header) => {
const panel = header.querySelector('[data-predictive]');
if (panel && !panel.hidden) {
closePredictive(header);
return;
}
closeMenu(header);
closeSearch(header);
});
@@ -808,6 +583,169 @@
const header = event.target.querySelector('[data-header]');
if (header) bind(header);
});
const wishKey = 'seasons-wishlist';
const wishDrawer = document.querySelector('[data-wish-drawer]');
const wishList = document.querySelector('[data-wish-list]');
const wishButton = document.querySelector('[data-wish-open]');
const wishCount = document.querySelector('[data-wish-count]');
const readWishItems = () => {
try {
const stored = JSON.parse(window.localStorage.getItem(wishKey));
if (!Array.isArray(stored)) return [];
return stored.map((item) => {
if (item && typeof item === 'object') return { id: String(item.id || ''), handle: String(item.handle || '') };
return { id: String(item), handle: '' };
}).filter((item) => item.id);
} catch (error) {
return [];
}
};
const writeWishItems = (items) => {
window.localStorage.setItem(wishKey, JSON.stringify(items));
document.dispatchEvent(new CustomEvent('seasons:wishlist'));
};
const formatPrice = (cents) => {
const currency = (window.Shopify && Shopify.currency && Shopify.currency.active) || 'MXN';
return new Intl.NumberFormat('es-MX', {
style: 'currency',
currency,
minimumFractionDigits: 0,
maximumFractionDigits: 2,
}).format(cents / 100);
};
let wishRequest = 0;
const updateWishCount = () => {
const count = readWishItems().filter((item) => item.handle).length;
if (!wishButton || !wishCount) return;
wishButton.classList.toggle('is-active', count > 0);
wishCount.textContent = count > 0 ? String(count) : '';
wishCount.classList.toggle('is-visible', count > 0);
const label = wishButton.dataset.countLabel || '';
if (label) wishButton.setAttribute('aria-label', label.replace('__COUNT__', String(count)));
};
const renderWishList = async () => {
if (!wishList) return;
const request = ++wishRequest;
const items = readWishItems().filter((item) => item.handle);
if (!items.length) {
wishList.replaceChildren();
const empty = document.createElement('p');
empty.className = 'wish-drawer__empty';
empty.textContent = wishDrawer?.dataset.empty || '';
wishList.append(empty);
return;
}
const products = await Promise.all(items.map(async (item) => {
try {
const response = await fetch(window.location.origin + '/products/' + item.handle + '.js');
if (!response.ok) return null;
const product = await response.json();
product._wishId = item.id;
return product;
} catch (error) {
return null;
}
}));
if (request !== wishRequest) return;
const found = products.filter(Boolean);
wishList.replaceChildren();
if (!found.length) {
const empty = document.createElement('p');
empty.className = 'wish-drawer__empty';
empty.textContent = wishDrawer?.dataset.empty || '';
wishList.append(empty);
return;
}
found.forEach((product) => {
const row = document.createElement('article');
row.className = 'wish-drawer__item';
const link = document.createElement('a');
link.className = 'wish-drawer__thumb';
link.href = product.url;
let imageSource = typeof product.featured_image === 'string' ? product.featured_image : product.featured_image && product.featured_image.src;
if (imageSource && imageSource.indexOf('//') === 0) imageSource = 'https:' + imageSource;
if (imageSource) {
const image = document.createElement('img');
image.src = imageSource;
image.alt = '';
image.width = 72;
image.height = 72;
link.append(image);
}
const copy = document.createElement('div');
const name = document.createElement('a');
name.className = 'wish-drawer__name';
name.href = product.url;
name.textContent = product.title;
const price = document.createElement('p');
price.className = 'wish-drawer__price';
price.textContent = formatPrice(product.price);
copy.append(name, price);
const remove = document.createElement('button');
remove.className = 'wish-drawer__remove';
remove.type = 'button';
remove.dataset.wishRemove = product._wishId;
remove.textContent = wishDrawer?.dataset.remove || '';
row.append(link, copy, remove);
wishList.append(row);
});
};
const setWishOpen = (open) => {
if (!wishDrawer || !wishButton) return;
wishDrawer.classList.toggle('is-open', open);
wishDrawer.setAttribute('aria-hidden', open ? 'false' : 'true');
document.querySelectorAll('[data-wish-open]').forEach((control) => {
control.setAttribute('aria-expanded', open ? 'true' : 'false');
});
document.documentElement.classList.toggle('overflow-hidden', open);
if (open) {
document.querySelectorAll('[data-header]').forEach((header) => {
closeMenu(header);
closeSearch(header);
closePredictive(header);
});
document.querySelector('[data-cart-drawer].is-open [data-cart-drawer-close]')?.click();
renderWishList();
wishDrawer.querySelector('.wish-drawer__close')?.focus();
}
};
updateWishCount();
document.addEventListener('seasons:wishlist', () => {
updateWishCount();
if (wishDrawer?.classList.contains('is-open')) renderWishList();
});
document.addEventListener('click', (event) => {
if (event.target.closest('[data-wish-open]')) {
event.preventDefault();
setWishOpen(!wishDrawer?.classList.contains('is-open'));
return;
}
if (event.target.closest('[data-wish-close]')) {
setWishOpen(false);
wishButton?.focus();
return;
}
const remove = event.target.closest('[data-wish-remove]');
if (!remove) return;
const id = remove.dataset.wishRemove;
writeWishItems(readWishItems().filter((item) => item.id !== id));
});
document.addEventListener('keydown', (event) => {
if (event.key !== 'Escape' || !wishDrawer?.classList.contains('is-open')) return;
setWishOpen(false);
wishButton?.focus();
});
})();
{% endjavascript %}