Vue Router's scrollBehavior doesn't fire when RouterLink resolves to the current URL (logo while on /, /#bundles while already at #bundles), so the smooth scroll never happened. Added onNavClick + onLogoClick handlers that intercept the click when the destination is the same route and call scrollIntoView / window.scrollTo with behavior:'smooth' directly. Cross-route nav still goes through Vue Router's scrollBehavior unchanged (savedPosition restore + same-route smooth + cross-route instant). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 line
5.4 KiB
JavaScript
1 line
5.4 KiB
JavaScript
import{B as e,C as t,G as n,S as r,T as i,c as a,ft as o,l as s,m as c,o as l,p as u,r as d,s as f,u as p,ut as ee,x as te}from"./runtime-core.esm-bundler-DTXUv7Wx.js";import{o as ne}from"./vue-router-Cyqru1db.js";import{t as re}from"./i18n-DhVF3Pwg.js";import{i as ie,r as m,t as h}from"./products-BqW5PUnm.js";import{c as g,d as ae,f as oe,p as _,u as v}from"./api-DlB23x7f.js";import{t as y}from"./Navbar-BZK-fooS.js";import{t as b}from"./ProductCard-aSVEFTCo.js";import{t as x}from"./WaveDivider-xrSvFNvN.js";import{t as S}from"./Footer-DX-ml2dd.js";import{t as C}from"./CartDrawer-f57jysS_.js";var w={class:`flex flex-col bg-brand text-cream md:min-h-[calc(100svh-var(--nav-h))] md:justify-center`},T={class:`mx-auto w-full max-w-6xl px-6 py-12 sm:px-8 sm:py-16 md:px-12 md:py-12 lg:px-16 lg:py-16`},E={class:`flex flex-col items-center text-center gap-4 max-w-3xl mx-auto`},D={class:`font-display font-normal leading-[1.05] tracking-tight text-cream text-headline-lg`},O={class:`italic font-light text-accent-soft`},k={class:`text-base md:text-lg leading-relaxed text-cream/80 max-w-2xl`},A={class:`mt-8 md:mt-10 grid gap-4 sm:gap-5 md:gap-6 grid-cols-1 sm:grid-cols-3`},j=[`href`],M={class:`w-full aspect-[4/3] max-h-[30svh] md:max-h-[26svh] lg:max-h-[28svh] rounded-md bg-paper overflow-hidden flex items-center justify-center`},N=[`src`,`alt`],P={class:`flex flex-col items-center text-center gap-1`},F={class:`eyebrow text-accent`},I={class:`font-display text-lg md:text-xl font-normal leading-tight text-cream`},se={class:`mt-auto inline-flex items-center gap-1.5 text-sm font-semibold tracking-label text-cream/80 group-hover:text-accent transition-colors duration-base`},L=[`id`],R={class:`mx-auto w-full max-w-6xl px-6 py-16 sm:px-8 sm:py-20 md:px-12 md:py-24 lg:px-16 lg:py-28`},z={class:`flex flex-col gap-4 max-w-3xl`},B={class:`font-display font-normal leading-[1.05] tracking-tight text-ink text-headline-lg`},V={class:`italic font-light text-brand`},H={class:`text-lg leading-relaxed text-muted max-w-2xl`},U={key:0,class:`mt-12 md:mt-14 grid gap-5 md:gap-7 grid-cols-1 sm:grid-cols-2 md:grid-cols-3`},W={__name:`ShopPage`,setup(W){let{t:G}=re(),K=_(),ce=ne(),q=e(!1);function le(){q.value=!1,ce.push(`/checkout`)}let ue=[{key:`nav.shop`,href:`/shop`},{key:`nav.bundles`,href:`/#bundles`},{key:`nav.revitalization`,href:`/#revitalize`},{key:`nav.about`,href:`/#about`}],de=[],J=l(()=>ie(m)),Y=l(()=>h.map(e=>({id:e,label:G(`shop.feature.${e}`),cta:G(`shop.feature.cta.${e}`),product:J.value[e][0]}))),X=l(()=>h.map((e,t)=>({id:e,headline:G(`shop.section.${e}.headline`),headlineEm:G(`shop.section.${e}.headline.em`),sub:G(`shop.section.${e}.sub`),products:J.value[e],tone:t%2==0?`cream`:`surface`})));async function fe(e){await g(e.id,1),q.value=!0}async function pe(e){await g(e.id,1),q.value=!0}async function me({productId:e,quantity:t}){await oe(e,t)}async function he(e){await ae(e)}let Z=e(null),Q=null;function $(){let e=Z.value,t=e&&(e.$el||e);if(!t||typeof window>`u`)return;let n=Math.round(t.getBoundingClientRect().height);document.documentElement.style.setProperty(`--nav-h`,`${n}px`)}return r(()=>{if(v(),$(),typeof ResizeObserver<`u`&&Z.value){let e=Z.value.$el||Z.value;Q=new ResizeObserver($),Q.observe(e)}window.addEventListener(`resize`,$)}),te(()=>{Q&&Q.disconnect(),typeof window<`u`&&window.removeEventListener(`resize`,$)}),(e,r)=>(t(),p(d,null,[c(y,{ref_key:`navRef`,ref:Z,variant:`brand`,layout:`standard`,items:ue,"secondary-items":de,"cart-count":n(K).count,products:n(m),onCart:r[0]||=e=>q.value=!0,onSearch:pe},null,8,[`cart-count`,`products`]),f(`div`,w,[f(`div`,T,[f(`div`,E,[f(`h1`,D,[u(o(n(G)(`shop.headline`))+` `,1),f(`em`,O,o(n(G)(`shop.headline.em`)),1)]),f(`p`,k,o(n(G)(`shop.sub`)),1)]),f(`ul`,A,[(t(!0),p(d,null,i(Y.value,e=>(t(),p(`li`,{key:e.id},[f(`a`,{href:`#${e.id}`,class:`group flex h-full flex-col items-center gap-4 p-4 md:p-5 rounded-md border border-cream-line bg-cream-wash hover:bg-cream-wash-strong transition-colors duration-base`},[f(`div`,M,[f(`img`,{src:e.product.image,alt:e.product.title,loading:`lazy`,decoding:`async`,class:`w-full h-full object-contain p-4 md:p-5`},null,8,N)]),f(`div`,P,[f(`p`,F,o(e.label),1),f(`h3`,I,o(e.product.title),1)]),f(`span`,se,[u(o(e.cta)+` `,1),r[2]||=f(`span`,{"aria-hidden":`true`,class:`transition-transform duration-base group-hover:translate-x-1`},`→`,-1)])],8,j)]))),128))])])]),(t(!0),p(d,null,i(X.value,(e,n)=>(t(),p(d,{key:e.id},[c(x,{from:n===0?`brand`:X.value[n-1].tone,to:e.tone},null,8,[`from`,`to`]),f(`section`,{id:e.id,class:ee([`-mt-px scroll-mt-[calc(var(--nav-h)+1rem)]`,e.tone===`cream`?`bg-cream text-ink`:`bg-surface text-ink`])},[f(`div`,R,[f(`div`,z,[f(`h2`,B,[u(o(e.headline)+` `,1),f(`em`,V,o(e.headlineEm),1)]),f(`p`,H,o(e.sub),1)]),e.products.length?(t(),p(`div`,U,[(t(!0),p(d,null,i(e.products,e=>(t(),a(b,{key:e.id,title:e.title,size:e.size,price:e.price,image:e.image,"image-alt":e.title,href:e.href,tone:`cream`,"in-stock":e.inStock,"cta-variant":n%2==1?`accent`:`primary`,onAdd:t=>fe(e)},null,8,[`title`,`size`,`price`,`image`,`image-alt`,`href`,`in-stock`,`cta-variant`,`onAdd`]))),128))])):s(``,!0)])],10,L)],64))),128)),c(S),r[3]||=f(`div`,{"aria-hidden":`true`,class:`md:hidden`,style:{height:`calc(100px + env(safe-area-inset-bottom))`}},null,-1),c(C,{modelValue:q.value,"onUpdate:modelValue":r[1]||=e=>q.value=e,items:n(K).items,subtotal:n(K).subtotal,count:n(K).count,onUpdateQuantity:me,onRemove:he,onCheckout:le},null,8,[`modelValue`,`items`,`subtotal`,`count`])],64))}};export{W as default}; |