/* ============================================================ GlowMerald — Navigation, Footer, ProductCard ============================================================ */ const { useState:useStateN, useEffect:useEffectN } = React; const NAV_LINKS = [ { route:'shop', label:'Shop' }, { route:'insight', label:'Beauty Insight' }, { route:'about', label:'About' }, { route:'contact', label:'Contact' }, ]; /* ---- Top navigation ---- */ function NavBar(){ const { route, navigate, cartCount, wishlist, openSearch } = useApp(); const [scrolled,setScrolled] = useStateN(false); const [menu,setMenu] = useStateN(false); useEffectN(()=>{ const f=()=>setScrolled(window.scrollY>10); f(); window.addEventListener('scroll',f); return ()=>window.removeEventListener('scroll',f); },[]); const onHomeHero = route==='home' && !scrolled; const barStyle = { position:'sticky', top:0, zIndex:200, height:'var(--nav-h)', background: onHomeHero ? 'transparent' : 'rgba(250,247,240,.88)', backdropFilter: onHomeHero ? 'none' : 'saturate(140%) blur(10px)', borderBottom: onHomeHero ? '1px solid transparent' : '1px solid var(--line)', transition:'background .3s, border-color .3s', }; const ic = 'var(--ink)'; const dark = false; return ( <> setMenu(true)} aria-label="Menu" style={{ background:'none', border:0, color:ic, display:'flex', padding:4 }}> navigate('home')} className="nav-logo" style={{ display:'flex', cursor:'pointer' }}> {NAV_LINKS.map(l=>( navigate(l.route)} style={{ fontSize:'.78rem', letterSpacing:'.08em', color: route===l.route?'var(--gold-deep)':ic, fontWeight:500, cursor:'pointer', paddingBottom:2, borderBottom: route===l.route?'1px solid var(--gold)':'1px solid transparent' }}> {l.label} ))} navigate('account','wishlist')} aria-label="Wishlist" style={{ position:'relative' }}> {wishlist.length>0 && {wishlist.length}} navigate('cart')} aria-label="Keranjang" style={{ position:'relative' }}> {cartCount>0 && {cartCount}} navigate('account')} aria-label="Akun"> {menu && setMenu(false)}/>} > ); } /* ---- Mobile drawer ---- */ function MobileMenu({ close }){ const { navigate } = useApp(); const go=(r,s)=>{ navigate(r,s); close(); }; return ( e.stopPropagation()}> {NAV_LINKS.map(l=>( go(l.route)} className="drawer-link">{l.label} ))} go('account')} className="drawer-link">Akun Saya go('account','wishlist')} className="drawer-link">Wishlist Glow from Within,Confidence Revealed. ); } /* ---- Bottom navigation (mobile) ---- */ function BottomNav(){ const { route, navigate } = useApp(); const items=[ { r:'home', label:'Home', icon:'home' }, { r:'shop', label:'Shop', icon:'shop' }, { r:'insight', label:'Insight', icon:'book' }, { r:'account', label:'Akun', icon:'user' }, ]; return ( {items.map(it=>{ const active = route===it.r; return ( navigate(it.r)} className={'bn-item'+(active?' active':'')}> {it.label} ); })} ); } /* ---- Footer ---- */ function Footer(){ const { navigate } = useApp(); return ( ); } /* ---- Shared Product Card ---- */ function ProductCard({ item, eager }){ const { navigate, addToCart, wishlist, toggleWishlist } = useApp(); const [adding,setAdding] = useStateN(false); const wished = wishlist.includes(item.id); const isBundle = item.type==='Bundle'; const add=(e)=>{ e.stopPropagation(); addToCart(item.id); setAdding(true); setTimeout(()=>setAdding(false),1400); }; return ( navigate('product',item.id)}> {item.bestSeller && Best Seller} {isBundle && Hemat {formatRp(item.was-item.price)}} {e.stopPropagation(); toggleWishlist(item.id);}} aria-label="Wishlist"> {item.type} {item.rating} · {item.reviews} navigate('product',item.id)}>{item.name} {formatRp(item.price)} {isBundle && {formatRp(item.was)}} {adding ? Ditambahkan : 'Tambah ke Keranjang'} ); } Object.assign(window, { NavBar, MobileMenu, BottomNav, Footer, ProductCard, NAV_LINKS });
Glow from Within,Confidence Revealed.