import React, { useMemo, useState, useEffect } from "react";
/**
* 39DG Multi-Brand Mobile Demo
*
* What’s included:
* - Global header that always shows 39DollarGlasses (parent identity)
* - Brand ribbon on sub-brand pages with logo + “A 39DG company” (links to 39dg.co)
* - Gap-style brand tabs (single-row, horizontally scrollable)
* - Bottom-sheet brand switcher (logo grid) with endorsement under each logo
* - Simple product grid + shared cart (to demonstrate one checkout for all brands)
*
* Notes:
* - Mobile-first layout; use responsive devtools (375–430px wide) for best view
* - TailwindCSS utility classes are used (no external imports required here)
*/
// --- Sample brand data (placeholder logos implemented as inline SVGs) ---
const BRAND_PALETTE = {
neurolux: "#6E44FF",
lumeo: "#0EA5E9",
studyspecs: "#F59E0B",
oculusleep: "#4F46E5", // unused; kept for example
ocusleep: "#4F46E5",
trailview: "#0EA44E",
};
const BRANDS = [
{
name: "Neurolux",
slug: "neurolux",
color: BRAND_PALETTE.neurolux,
tagline: "Blue‑light filtering lenses for screen-heavy days.",
},
{
name: "Lumeo",
slug: "lumeo",
color: BRAND_PALETTE.lumeo,
tagline: "Clarity-forward optics for daily focus.",
},
{
name: "StudySpecs",
slug: "studyspecs",
color: BRAND_PALETTE.studyspecs,
tagline: "Durable, kid‑proof frames built for school.",
},
{
name: "OcuSleep",
slug: "ocusleep",
color: BRAND_PALETTE.ocusleep,
tagline: "Evening eyewear to support better sleep.",
},
{
name: "TrailView",
slug: "trailview",
color: BRAND_PALETTE.trailview,
tagline: "Adventure‑ready shades for the outdoors.",
},
];
function BrandLogo({ brand, size = 24 }) {
// simple letter-based logo circle; replace with real SVGs later
const letter = brand?.name?.[0] || "?";
const fill = brand?.color || "#111827";
return (
);
}
function Pill({ active, color, children, onClick }) {
const activeStyle = active ? { color, borderColor: color, boxShadow: `inset 0 -2px 0 0 ${color}` } : {};
return (
);
}
function BottomSheet({ open, onClose, children }) {
useEffect(() => {
function onEsc(e) { if (e.key === "Escape") onClose?.(); }
if (open) document.addEventListener("keydown", onEsc);
return () => document.removeEventListener("keydown", onEsc);
}, [open, onClose]);
return (
{ if (e.target === e.currentTarget) onClose?.(); }}
>
{/* overlay */}
{/* sheet */}
);
}
function Products({ brand, onAdd }) {
// sample product list (3 items per brand)
const items = useMemo(() => {
const base = [
{ name: "Classic", price: 39 },
{ name: "LiteFlex", price: 49 },
{ name: "ProShield", price: 69 },
];
return base.map((b, i) => ({ ...b, id: `${brand?.slug || "home"}-${i}`, brand: brand?.name || "39DG" }));
}, [brand]);
return (
{items.map((p) => (
{p.brand} · {p.name}
))}
);
}
export default function App() {
const [currentBrand, setCurrentBrand] = useState(null); // null = Home
const [sheetOpen, setSheetOpen] = useState(false);
const [cart, setCart] = useState([]);
const activeColor = currentBrand?.color || "#111827";
const addToCart = (item) => setCart((c) => [...c, item]);
// Simulate route changes when pressing back/forward (optional demo nicety)
useEffect(() => {
const onPop = () => {
const hash = (location.hash || "").replace("#", "");
const found = BRANDS.find((b) => b.slug === hash) || null;
setCurrentBrand(found);
};
window.addEventListener("popstate", onPop);
onPop();
return () => window.removeEventListener("popstate", onPop);
}, []);
const goBrand = (brand) => {
setCurrentBrand(brand);
history.pushState({}, "", brand ? `#${brand.slug}` : "#");
};
return (
{/* --- Global header: always 39DollarGlasses (parent identity) --- */}
{/* --- Brand ribbon (shows only on sub-brand pages) --- */}
{currentBrand && (
A 39DG company
)}
{/* --- Brand tabs (Gap-style) --- */}
{/* --- Page Content --- */}
{/* Hero */}
{currentBrand ? (
{currentBrand.name}
{currentBrand.tagline}
) : (
Welcome to 39DollarGlasses
Explore our family of brands – all with secure checkout, one cart, and the same great service.
{BRANDS.map((b) => (
))}
)}
{/* Trust strip */}
Shop with confidence — Secure checkout & 30‑day returns across all brands.
by 39DollarGlasses
{/* Products */}
{currentBrand ? `${currentBrand.name} picks` : "Featured products"}
{/* Cross-links */}
{currentBrand && (
More from 39dg
{BRANDS.filter((b) => b.slug !== currentBrand.slug).map((b) => (
))}
)}
{/* --- Bottom-sheet brand switcher --- */}
setSheetOpen(false)}>
{BRANDS.map((b) => (
))}
{/* --- Footer (light) --- */}
);
}