| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998 |
- import { Img } from "./media";
- import { useEffect, useRef, useState, ReactNode, FormEvent } from "react";
- import {
- ArrowUpRight,
- ArrowRight,
- Search,
- Heart,
- ShoppingBag,
- UserRound,
- Menu,
- X,
- Plus,
- Minus,
- Leaf,
- MapPin,
- Package,
- MessageCircle,
- Instagram,
- Facebook,
- Check,
- ChevronLeft,
- ChevronDown,
- ChevronRight,
- Quote,
- Pause,
- Play,
- Mail,
- } from "lucide-react";
- import {
- Product,
- products,
- money,
- categories,
- collections,
- reviews,
- social,
- contact,
- articles,
- } from "./data";
- import { useStore } from "./store";
- import { Link, navigate } from "./router";
- export function Button({
- children,
- href,
- onClick,
- secondary = false,
- className = "",
- type = "button",
- disabled = false,
- }: {
- children: ReactNode;
- href?: string;
- onClick?: () => void;
- secondary?: boolean;
- className?: string;
- type?: "button" | "submit";
- disabled?: boolean;
- }) {
- const cls = `button ${secondary ? "secondary" : ""} ${className}`;
- return href ? (
- <Link className={cls} href={href} onClick={onClick}>
- {children}
- </Link>
- ) : (
- <button className={cls} onClick={onClick} type={type} disabled={disabled}>
- {children}
- </button>
- );
- }
- export function IconButton({
- label,
- children,
- onClick,
- className = "",
- }: {
- label: string;
- children: ReactNode;
- onClick: () => void;
- className?: string;
- }) {
- return (
- <button
- className={"icon-button " + className}
- aria-label={label}
- onClick={onClick}
- >
- {children}
- </button>
- );
- }
- export function SectionHeading({
- eyebrow,
- title,
- copy,
- link,
- label = "Explore all",
- }: {
- eyebrow?: string;
- title: string;
- copy?: string;
- link?: string;
- label?: string;
- }) {
- return (
- <div className="section-heading">
- <div>
- {eyebrow && <p className="eyebrow">{eyebrow}</p>}
- <h2>{title}</h2>
- {copy && <p className="muted">{copy}</p>}
- </div>
- {link && (
- <Link className="text-link" href={link}>
- {label}
- <ArrowUpRight size={18} />
- </Link>
- )}
- </div>
- );
- }
- export const nav = [
- ["Home", "/"],
- ["Shop", "/shop"],
- ["Collections", "/collections"],
- ["About", "/about"],
- ["Journal", "/journal"],
- ["Contact", "/contact"],
- ];
- const shopLinks = [
- { label: "All snacks", href: "/shop", note: "Find your next favourite" },
- { label: "New arrivals", href: "/shop?new=1", note: "Fresh to the snack club" },
- ...categories.filter(category => category !== "All snacks").map(category => ({
- label: category, href: "/shop?category=" + encodeURIComponent(category), note: "",
- })),
- ];
-
- function ShopDropdown({ path = "", mobile = false, onNavigate }: { path?: string; mobile?: boolean; onNavigate?: () => void }) {
- const [open, setOpen] = useState(false);
- const root = useRef<HTMLDivElement>(null);
- const trigger = useRef<HTMLButtonElement>(null);
- const id = mobile ? "mobile-shop-links" : "desktop-shop-links";
- useEffect(() => { setOpen(false); }, [path]);
- useEffect(() => {
- if (!open) return;
- const outside = (event: PointerEvent) => {
- if (!root.current?.contains(event.target as Node)) setOpen(false);
- };
- document.addEventListener("pointerdown", outside);
- return () => document.removeEventListener("pointerdown", outside);
- }, [open]);
- return <div ref={root} className={`shop-dropdown ${mobile ? "shop-dropdown-mobile" : ""}`}
- onBlur={event => { if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setOpen(false); }}
- onKeyDown={event => { if (event.key === "Escape" && open) { event.preventDefault(); event.stopPropagation(); setOpen(false); trigger.current?.focus(); } }}>
- <div className="shop-dropdown-heading">
- {mobile && <Link href="/shop" onClick={onNavigate}>Shop</Link>}
- <button ref={trigger} type="button" className="shop-dropdown-trigger" data-active={path.startsWith("/shop")}
- aria-label={mobile ? "Shop categories" : undefined} aria-expanded={open} aria-controls={id}
- onClick={() => setOpen(value => !value)}>
- {!mobile && "Shop"}<ChevronDown size={14} aria-hidden="true" />
- </button>
- </div>
- <div id={id} className="shop-dropdown-panel" hidden={!open}>
- <p className="eyebrow">CHOOSE YOUR CRUNCH</p>
- {shopLinks.map(link => <Link key={link.href} href={link.href} onClick={() => { setOpen(false); onNavigate?.(); }}>
- <span><strong>{link.label}</strong>{link.note && <small>{link.note}</small>}</span><ArrowUpRight size={16} aria-hidden="true" />
- </Link>)}
- </div>
- </div>;
- }
-
- export function Header({ path }: { path: string }) {
- const { setOverlay, count, wishlist } = useStore();
- const [scrolled, setScrolled] = useState(false);
- const [announcementPaused, setAnnouncementPaused] = useState(false);
- useEffect(() => {
- const f = () => setScrolled(scrollY > 20);
- window.addEventListener("scroll", f, { passive: true });
- return () => window.removeEventListener("scroll", f);
- }, []);
- return (
- <>
- <div className="announcement" data-paused={announcementPaused}>
- <Link className="announcement-viewport" href="/shop?new=1">
- <div className="announcement-track">
- {[0, 1].map(copy => (
- <div className="announcement-group" key={copy} aria-hidden={copy === 1 ? true : undefined}>
- <span>GOOD SNACKS. GREAT MOMENTS.</span>
- <span>MEET YOUR NEW FAVOURITE CRUNCH <ArrowUpRight size={12} /></span>
- <span>MALAYSIAN MADE, SHARED WITH THE WORLD</span>
- </div>
- ))}
- </div>
- </Link>
- <button className="announcement-toggle" type="button"
- aria-label={announcementPaused ? "Resume announcement animation" : "Pause announcement animation"}
- onClick={() => setAnnouncementPaused(paused => !paused)}>
- {announcementPaused ? <Play size={12} aria-hidden="true" /> : <Pause size={12} aria-hidden="true" />}
- </button>
- </div>
- <header className={scrolled ? "header scrolled" : "header"}>
- <div className="header-inner">
- <IconButton
- className="mobile-only"
- label="Open menu"
- onClick={() => setOverlay("menu")}
- >
- <Menu />
- </IconButton>
- <Link href="/" className="brand" aria-label="ADUCKTIVE home">
- <Img
- src="/images/logo.webp"
- width="128"
- height="72"
- alt="ADUCKTIVE"
- />
- </Link>
- <nav className="desktop-nav" aria-label="Main navigation">
- {nav.map(([label, href]) => label === "Shop" ? <ShopDropdown key={href} path={path} /> : (
- <Link
- key={href}
- href={href}
- aria-current={
- (href === "/" ? path === "/" : path.startsWith(href))
- ? "page"
- : undefined
- }
- >
- {label}
- </Link>
- ))}
- </nav>
- <div className="header-tools">
- <IconButton label="Search" onClick={() => setOverlay("search")}>
- <Search />
- </IconButton>
- <Link
- href="/account"
- className="icon-button desktop-only"
- aria-label="My account"
- >
- <UserRound />
- </Link>
- <Link
- href="/wishlist"
- className="icon-button desktop-only"
- aria-label={`Wishlist (${wishlist.length})`}
- >
- <Heart />
- </Link>
- <button
- className="cart-trigger"
- onClick={() => setOverlay("cart")}
- aria-label={`Open shopping bag (${count})`}
- >
- <ShoppingBag size={21} />
- <span>{count}</span>
- </button>
- </div>
- </div>
- </header>
- </>
- );
- }
- export function ProductCard({ product: p }: { product: Product }) {
- const { add, wishlist, toggleWish } = useStore();
- return (
- <article className="product-card">
- <div className={`product-picture tone-${p.id % 4}`} data-category={p.category}>
- <Link
- className="product-image-link"
- href={"/product/" + p.slug}
- aria-label={"View " + p.name}
- >
- <Img
- src={p.images[0]}
- sizes="(max-width: 900px) 45vw, 24vw"
- alt={`${p.name} ${p.weight}`}
- loading="lazy"
- width="500"
- height="500"
- />
- {p.images[1] && (
- <Img
- className="secondary-image"
- sizes="(max-width: 900px) 45vw, 24vw"
- src={p.images[1]}
- alt=""
- loading="lazy"
- width="500"
- height="500"
- />
- )}
- </Link>
- <div className="product-badges">
- {p.isNew ? (
- <span className="badge">JUST LANDED</span>
- ) : p.regularPrice > p.price ? (
- <span className="badge">SPECIAL PRICE</span>
- ) : (
- <span className="badge neutral">
- {p.spicy ? "A LITTLE HEAT" : "THE ORIGINAL"}
- </span>
- )}
- </div>
- <button
- className={"wish-button " + (wishlist.includes(p.id) ? "saved" : "")}
- aria-label={`${wishlist.includes(p.id) ? "Remove" : "Save"} ${p.name} ${wishlist.includes(p.id) ? "from" : "to"} wishlist`}
- aria-pressed={wishlist.includes(p.id)}
- onClick={() => toggleWish(p.id)}
- >
- <Heart size={18} />
- </button>
- <Link className="view-product" href={"/product/" + p.slug}>
- View product <ArrowUpRight size={15} />
- </Link>
- </div>
- <div className="product-meta">
- <span>
- {p.pack} {p.weight && `· ${p.weight}`}
- </span>
- <span>{p.spicy ? "Spicy" : "Original"}</span>
- </div>
- <h3>
- <Link href={"/product/" + p.slug}>{p.name}</Link>
- </h3>
- <p className="product-caption">
- {p.category === "Cornflakes"
- ? "Golden crunch. Rich salted egg."
- : p.category === "Mushroom crisps"
- ? "A satisfyingly different crunch."
- : p.category === "Tempeh chips"
- ? "A new twist on snack time."
- : "Made for the moments you share."}
- </p>
- <div className="product-bottom">
- <div>
- <strong>{money(p.price)}</strong>
- {p.regularPrice > p.price && <del>{money(p.regularPrice)}</del>}
- </div>
- <button
- className="quick-add"
- disabled={!p.stock}
- aria-label={`Quick add ${p.name} ${p.weight}`}
- onClick={() => add(p)}
- >
- <span>{p.stock ? "Quick add" : "Sold out"}</span>
- <Plus size={17} />
- </button>
- </div>
- </article>
- );
- }
- export function ProductGrid({ items }: { items: Product[] }) {
- return (
- <div className="product-grid">
- {items.map((p) => (
- <ProductCard key={p.id} product={p} />
- ))}
- </div>
- );
- }
- export function QuantitySelector({
- value,
- onChange,
- max = 99,
- label = "Quantity",
- }: {
- value: number;
- onChange: (q: number) => void;
- max?: number;
- label?: string;
- }) {
- return (
- <div className="quantity">
- <button
- aria-label={"Decrease " + label}
- disabled={value <= 1}
- onClick={() => onChange(value - 1)}
- >
- <Minus size={15} />
- </button>
- <output aria-label={label}>{value}</output>
- <button
- aria-label={"Increase " + label}
- disabled={value >= max}
- onClick={() => onChange(value + 1)}
- >
- <Plus size={15} />
- </button>
- </div>
- );
- }
- export function Benefits() {
- return (
- <div className="benefits">
- {[
- [MapPin, "Malaysian at heart", "Our story began in Subang Jaya."],
- [
- Leaf,
- "Flavour comes first",
- "Discover our signature salted egg snacks.",
- ],
- [
- Package,
- "A pack for every moment",
- "From a little treat to something to share.",
- ],
- [
- MessageCircle,
- "Let’s talk snacks",
- "Our team is just a message away.",
- ],
- ].map(([Icon, title, text]: any) => (
- <div key={title}>
- <Icon size={28} strokeWidth={1.4} />
- <h3>{title}</h3>
- <p>{text}</p>
- </div>
- ))}
- </div>
- );
- }
- export function CollectionGrid({ all = false }: { all?: boolean }) {
- return (
- <div className={"collection-grid " + (all ? "all-collections" : "")}>
- {collections.slice(0, all ? 4 : 2).map((c, i) => (
- <Link
- key={c.title}
- className={"collection-card collection-" + i}
- href={"/shop?category=" + encodeURIComponent(c.category)}
- >
- <Img
- src={c.image}
- alt={c.category + " by ADUCKTIVE"}
- loading="lazy"
- />
- <div className="collection-shade" />
- <div className="collection-content">
- <p className="eyebrow">THE {c.category.toUpperCase()} COLLECTION</p>
- <h3>{c.title}</h3>
- <p>{c.subtitle}</p>
- <span className="text-link">
- {c.label}
- <ArrowUpRight size={20} />
- </span>
- </div>
- <span className="collection-number">0{i + 1}</span>
- </Link>
- ))}
- </div>
- );
- }
- export function Testimonials() {
- const ref = useRef<HTMLDivElement>(null);
- return (
- <section className="section testimonials">
- <SectionHeading
- eyebrow="THE WORD AROUND THE TABLE"
- title="One bite. And they’re hooked."
- />
- <div className="review-top">
- <p className="muted">Real words from the ADUCKTIVE community.</p>
- <div className="arrows">
- <IconButton
- label="Previous reviews"
- onClick={() =>
- ref.current?.scrollBy({ left: -400, behavior: "smooth" })
- }
- >
- <ChevronLeft />
- </IconButton>
- <IconButton
- label="Next reviews"
- onClick={() =>
- ref.current?.scrollBy({ left: 400, behavior: "smooth" })
- }
- >
- <ChevronRight />
- </IconButton>
- </div>
- </div>
- <div
- className="reviews"
- ref={ref}
- tabIndex={0}
- aria-label="Customer testimonials"
- >
- {reviews.map((r, i) => (
- <article className="review" key={i}>
- <Quote size={28} strokeWidth={1.2} />
- <blockquote>{r.message}</blockquote>
- <div className="review-author">
- <span className="avatar">{r.name.charAt(0)}</span>
- <div>
- <strong>{r.name}</strong>
- <small>From our customer community</small>
- </div>
- </div>
- </article>
- ))}
- </div>
- </section>
- );
- }
- export function Newsletter() {
- const [status, setStatus] = useState("");
- function submit(e: FormEvent<HTMLFormElement>) {
- e.preventDefault();
- const data = new FormData(e.currentTarget);
- const email = String(data.get("email"));
- window.location.href = `mailto:${contact.email}?subject=${encodeURIComponent("ADUCKTIVE newsletter sign-up request")}&body=${encodeURIComponent(`Please add ${email} to the ADUCKTIVE newsletter. I agree to receive new product and brand updates.`)}`;
- setStatus(
- "Your email app will open with a sign-up request. Send it to ask our team to subscribe you.",
- );
- }
- return (
- <section className="newsletter">
- <div>
- <p className="eyebrow">A LITTLE SOMETHING IN YOUR INBOX</p>
- <h2>Your inbox. Extra crunchy.</h2>
- <p>New releases, tasty updates, and more reasons to snack.</p>
- </div>
- <form onSubmit={submit}>
- <label htmlFor="newsletter-email">Email address</label>
- <div className="newsletter-field">
- <input
- id="newsletter-email"
- name="email"
- type="email"
- required
- placeholder="Your email address"
- autoComplete="email"
- />
- <button type="submit" aria-label="Subscribe to newsletter">
- SUBSCRIBE
- <ArrowUpRight size={20} />
- </button>
- </div>
- <p className="small">
- Request your subscription by email.{" "}
- <Link href="/help/privacy">Privacy information</Link>
- </p>
- <p role="status">{status}</p>
- </form>
- </section>
- );
- }
- export function Footer() {
- const groups = [
- [
- "SHOP",
- ["All snacks", "/shop"],
- ["New arrivals", "/shop?new=1"],
- ["Featured favourites", "/shop?featured=1"],
- ["Collections", "/collections"],
- ],
- [
- "OUR WORLD",
- ["Our story", "/about"],
- ["Journal", "/journal"],
- ["Find us", "https://aducktive.com/find-us"],
- ["Contact", "/contact"],
- ],
- [
- "HERE TO HELP",
- ["FAQs", "/help/faq"],
- ["Shipping", "/help/shipping"],
- ["Returns", "/help/returns"],
- ["Privacy", "/help/privacy"],
- ["Terms & conditions", "/help/terms"],
- ],
- ];
- return (
- <footer className="footer">
- <div className="footer-main">
- <div className="footer-brand">
- <Link href="/" aria-label="ADUCKTIVE home">
- <Img
- src="/images/logo.webp"
- alt="ADUCKTIVE"
- width="160"
- height="90"
- loading="lazy"
- />
- </Link>
- <p>
- Bold flavours. Savoury snacks.
- <br />
- Taste adventures.
- </p>
- <div className="social-links">
- <a
- href={social[0]}
- aria-label="ADUCKTIVE on Facebook"
- target="_blank"
- rel="noreferrer"
- >
- <Facebook size={19} />
- </a>
- <a
- href={social[1]}
- aria-label="ADUCKTIVE on Instagram"
- target="_blank"
- rel="noreferrer"
- >
- <Instagram size={19} />
- </a>
- <a
- href={social[2]}
- target="_blank"
- rel="noreferrer"
- aria-label="ADUCKTIVE on TikTok"
- >
- TikTok ↗
- </a>
- </div>
- </div>
- {groups.map(([title, ...links]) => (
- <div className="footer-column" key={String(title)}>
- <h3>{title}</h3>
- {links.map(([label, href]) => (
- <Link key={label} href={href}>
- {label}
- </Link>
- ))}
- </div>
- ))}
- <div className="footer-column footer-contact">
- <h3>SAY HELLO</h3>
- <a href={"mailto:" + contact.email}>{contact.email}</a>
- <a href="tel:+60182654321">{contact.phone}</a>
- <p>Selangor, Malaysia</p>
- <span className="country">MY / MYR (RM)</span>
- </div>
- </div>
- <div className="footer-signoff" aria-hidden="true">
- SO DUCKIN’ GOOD.
- </div>
- <div className="footer-bottom">
- <span>
- © {new Date().getFullYear()} Aducktive Food Sdn. Bhd. 1384616-H. All
- rights reserved.
- </span>
- <span>
- Made for the joy of snacking. <span aria-hidden="true">↗</span>
- </span>
- </div>
- </footer>
- );
- }
- export function EmptyState({ title, copy }: { title: string; copy: string }) {
- return (
- <div className="empty-state">
- <ShoppingBag size={42} strokeWidth={1} />
- <h2>{title}</h2>
- <p>{copy}</p>
- <Button href="/shop">
- Explore the snacks
- <ArrowUpRight size={18} />
- </Button>
- </div>
- );
- }
- export function Modal({
- title,
- children,
- onClose,
- side = false,
- }: {
- title: string;
- children: ReactNode;
- onClose: () => void;
- side?: boolean;
- }) {
- const ref = useRef<HTMLDialogElement>(null);
- const closeRef = useRef(onClose);
- closeRef.current = onClose;
- useEffect(() => {
- const d = ref.current!;
- const prev = document.activeElement as HTMLElement;
- d.showModal();
- d.querySelector<HTMLInputElement>("input")?.focus();
- const original = document.body.style.overflow;
- document.body.style.overflow = "hidden";
- return () => {
- d.close();
- document.body.style.overflow = original;
- prev?.focus();
- };
- }, []);
- return (
- <dialog
- ref={ref}
- className={"modal " + (side ? "drawer" : "")}
- aria-label={title}
- onKeyDownCapture={(e) => {
- if (e.key === "Escape") {
- e.preventDefault();
- e.stopPropagation();
- closeRef.current();
- }
- }}
- onCancel={(e) => {
- e.preventDefault();
- closeRef.current();
- }}
- onClick={(e) => {
- if (e.target === ref.current) {
- const r = ref.current.getBoundingClientRect();
- if (
- e.clientX < r.left ||
- e.clientX > r.right ||
- e.clientY < r.top ||
- e.clientY > r.bottom
- )
- onClose();
- }
- }}
- >
- <div className="modal-heading">
- <h2>{title}</h2>
- <IconButton label={"Close " + title.toLowerCase()} onClick={onClose}>
- <X />
- </IconButton>
- </div>
- {children}
- </dialog>
- );
- }
- export function CartItems() {
- const { cart, update } = useStore();
- return (
- <div className="cart-items">
- {cart.map((line) => {
- const p = products.find((p) => p.id === line.id)!;
- return (
- <article className="cart-line" key={p.id}>
- <Link href={"/product/" + p.slug}>
- <Img src={p.images[0]} alt={p.name} width="100" height="110" />
- </Link>
- <div className="cart-line-content">
- <Link href={"/product/" + p.slug}>
- <h3>{p.name}</h3>
- </Link>
- <p>
- {p.pack} · {p.weight}
- </p>
- <QuantitySelector
- value={line.quantity}
- max={p.stock}
- onChange={(q) => update(p.id, q)}
- label={p.name}
- />
- </div>
- <div className="cart-line-price">
- <strong>{money(p.price * line.quantity)}</strong>
- <button
- className="text-button"
- onClick={() => update(p.id, 0)}
- aria-label={"Remove " + p.name}
- >
- Remove
- </button>
- </div>
- </article>
- );
- })}
- </div>
- );
- }
- export function Overlays() {
- const { overlay, setOverlay, cart, subtotal, count, toast } = useStore();
- return (
- <>
- {overlay === "menu" && (
- <Modal title="Explore ADUCKTIVE" onClose={() => setOverlay(null)} side>
- <nav className="mobile-nav" aria-label="Mobile navigation">
- {[
- ...nav,
- ["Wishlist", "/wishlist"],
- ["My account", "/account"],
- ].map(([title, path]) => title === "Shop" ? <ShopDropdown key={path} mobile onNavigate={() => setOverlay(null)} /> : (
- <Link key={path} href={path} onClick={() => setOverlay(null)}>
- {title}
- <ArrowUpRight />
- </Link>
- ))}
- </nav>
- <p className="menu-foot">A little crunch. A lot of joy.</p>
- </Modal>
- )}
- {overlay === "search" && <SearchOverlay />}
- {overlay === "cart" && (
- <Modal
- title={`Your bag (${count})`}
- side
- onClose={() => setOverlay(null)}
- >
- {cart.length ? (
- <>
- <div className="drawer-body">
- <p className="bag-message">A little happiness, ready to go.</p>
- <CartItems />
- </div>
- <div className="cart-summary">
- <div>
- <span>Subtotal</span>
- <strong>{money(subtotal)}</strong>
- </div>
- <p>
- Shipping and any discounts are confirmed by the official
- store.
- </p>
- <Button href="/checkout" onClick={() => setOverlay(null)}>
- Review & checkout
- <ArrowRight size={18} />
- </Button>
- <Link
- className="text-link"
- href="/cart"
- onClick={() => setOverlay(null)}
- >
- View your bag
- </Link>
- </div>
- </>
- ) : (
- <div
- onClick={(e) => {
- if ((e.target as HTMLElement).closest("a")) setOverlay(null);
- }}
- >
- <EmptyState
- title="Your bag is empty"
- copy="Good things start with a little crunch."
- />
- </div>
- )}
- </Modal>
- )}
- {toast && (
- <div className="toast" role="status">
- <Check size={18} />
- {toast}
- </div>
- )}
- </>
- );
- }
- function SearchOverlay() {
- const { setOverlay } = useStore();
- const [q, setQ] = useState("");
- const query = q.trim().toLowerCase();
- const results = products.filter((p) =>
- (p.name + " " + p.pack + " " + p.category).toLowerCase().includes(query),
- );
- const news = articles.filter((a) => a.title.toLowerCase().includes(query));
- return (
- <Modal title="Find your next favourite" onClose={() => setOverlay(null)}>
- <form
- className="search-form"
- onSubmit={(e) => {
- e.preventDefault();
- setOverlay(null);
- navigate("/shop?q=" + encodeURIComponent(q));
- }}
- >
- <Search size={22} />
- <label className="sr-only" htmlFor="search-query">
- Search snacks, collections and stories
- </label>
- <input
- id="search-query"
- type="search"
- value={q}
- onChange={(e) => setQ(e.target.value)}
- placeholder="Search snacks, collections, stories…"
- />
- <button
- type="submit"
- className="icon-button"
- aria-label="View all search results"
- >
- <ArrowRight />
- </button>
- </form>
- {!query && (
- <div className="popular">
- <p className="eyebrow">POPULAR SEARCHES</p>
- <div>
- {["Salted egg", "Mushroom", "Tempeh", "Fun pack"].map((x) => (
- <button key={x} onClick={() => setQ(x)}>
- {x}
- <ArrowUpRight size={14} />
- </button>
- ))}
- </div>
- </div>
- )}
- <p className="eyebrow">
- {query ? `${results.length} PRODUCT RESULTS` : "EXPLORE OUR SNACKS"}
- </p>
- <div className="search-results">
- {results.slice(0, 5).map((p) => (
- <Link
- href={"/product/" + p.slug}
- key={p.id}
- onClick={() => setOverlay(null)}
- >
- <Img src={p.images[0]} alt="" width="65" height="65" />
- <div>
- <strong>{p.name}</strong>
- <small>
- {p.pack} · {p.weight}
- </small>
- </div>
- <span>{money(p.price)}</span>
- <ArrowUpRight size={18} />
- </Link>
- ))}
- </div>
- {query &&
- categories
- .filter((c) => c.toLowerCase().includes(query))
- .map((c) => (
- <Link
- key={c}
- className="search-category"
- href={"/shop?category=" + encodeURIComponent(c)}
- onClick={() => setOverlay(null)}
- >
- Collection: {c}
- <ArrowUpRight size={16} />
- </Link>
- ))}
- {query &&
- news.slice(0, 3).map((a) => (
- <Link
- className="search-category"
- key={a.id}
- href={"/journal/" + a.id}
- onClick={() => setOverlay(null)}
- >
- Journal: {a.title}
- <ArrowUpRight size={16} />
- </Link>
- ))}
- {query && !results.length && !news.length && (
- <p className="muted">
- No matches yet. Try “cornflakes”, “mushroom” or “tempeh”.
- </p>
- )}
- </Modal>
- );
- }
- export function SocialGallery() {
- const imgs = [
- "/images/snack-23-2.webp",
- "/images/snack-26-2.webp",
- "/images/snack-22-3.webp",
- "/images/snack-130-2.webp",
- "/images/snack-25-2.webp",
- "/images/snack-145-1.webp",
- ];
- return (
- <section className="section social-section">
- <SectionHeading
- eyebrow="GOOD SNACKS BRING PEOPLE TOGETHER"
- title="A seriously ADUCKTIVE world."
- link={social[1]}
- label="@aducktive.saltedegg.hq"
- />
- <div className="social-grid">
- {imgs.map((src, i) => (
- <a
- key={src}
- href={social[1]}
- target="_blank"
- rel="noreferrer"
- aria-label={"Follow ADUCKTIVE on Instagram, photo " + (i + 1)}
- >
- <Img
- src={src}
- alt={`ADUCKTIVE ${["cornflakes", "mushroom crisps", "salted egg snacks", "tempeh chips", "original mushroom crisps", "party pack"][i]}`}
- loading="lazy"
- width="300"
- height="300"
- />
- <Instagram size={20} />
- </a>
- ))}
- </div>
- <p className="muted">
- Follow us for the latest products, updates, and a little snack
- inspiration.
- </p>
- </section>
- );
- }
|