add productdetailpage
This commit is contained in:
1 parent
6479792acf
commit
624c8c8f1a
9 files changed
+1218
-386
No files matched your search
+8
-349
@@ -1,355 +1,14 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { gsap } from "gsap";
|
||||
import "./App.css";
|
||||
|
||||
// Hallo im Code,
|
||||
// ich streue hier bewusst Kommentare ein, damit ihr euch nicht auf eine jahrlange
|
||||
// archäologische Expedition begeben müsst. So bleibt besser sichtbar, wo
|
||||
// einzelne Sections anfangen und aufhören und wo wichtige Elemente oder
|
||||
// Funktionen liegen.
|
||||
|
||||
// Euer Freund und Helfer Salih
|
||||
|
||||
// Bei Bugs, kleinen Krisen oder emotionalem Kontrollverlust bitte
|
||||
// https://stackoverflow.com/questions konsultieren
|
||||
// oder fragen Sie Salih oder eine KI Ihres Vertrauens.
|
||||
|
||||
//Erreichbar unter salih.hasicic@stud.fhgr.ch oder telefonisch, falls ihr die Nummer habt*/
|
||||
|
||||
//Elements and Images for the grid
|
||||
const perfumes = [
|
||||
{
|
||||
id: "01",
|
||||
name: "KALTER BETON",
|
||||
image:
|
||||
"/kalter-beton-product.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/kalter-beton-hover.webm",
|
||||
text: "Mineralisch. Roh. Unberührt.",
|
||||
},
|
||||
{
|
||||
id: "02",
|
||||
name: "NASSER MARMOR",
|
||||
image:
|
||||
"/NASSER MARMOR.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/nasser-marmor-hover.webm",
|
||||
text: "Kühl. Glatt. Sinnlich.",
|
||||
},
|
||||
{
|
||||
id: "03",
|
||||
name: "BLASSE SEIDE",
|
||||
image:
|
||||
"/BLASSE SEIDE.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/blasse-seide-hover.webm",
|
||||
text: "Blass. Sanft. Kostbar.",
|
||||
},
|
||||
{
|
||||
id: "04",
|
||||
name: "WEISSE ASCHE",
|
||||
image:
|
||||
"/WEISSE ASCHE.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/weisse-asche-hover.webm",
|
||||
text: "Still. Staubig. Erhaben.",
|
||||
},
|
||||
{
|
||||
id: "05",
|
||||
name: "VERBRANNTES CHROM",
|
||||
image:
|
||||
"/VERBRANNTES CHROM.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/verbranntes-chrom-hover.webm",
|
||||
text: "Metallisch. Verzehrt. Edel.",
|
||||
},
|
||||
{
|
||||
id: "06",
|
||||
name: "SCHWARZES BENZIN",
|
||||
image:
|
||||
"/SCHWARZES BENZIN.png",
|
||||
fillImage: "/platzhalter.png",
|
||||
fillVideo: "/schwarzes-benzin-hover.webm",
|
||||
text: "Dunkel. Glänzend. Verboten.",
|
||||
},
|
||||
];
|
||||
import LandingPage from "./pages/LandingPage";
|
||||
import ProductDetailPage from "./components/ProductDetailPage";
|
||||
|
||||
function App() {
|
||||
const cardRefs = useRef([]);
|
||||
const showDetailPage = true;
|
||||
|
||||
useEffect(() => {
|
||||
const cards = cardRefs.current.filter(Boolean);
|
||||
const cardStates = cards
|
||||
.map((card) => {
|
||||
const hoverFill = card.querySelector(".product-hover-fill");
|
||||
const hoverVideo = card.querySelector(".product-hover-video");
|
||||
const productImage = card.querySelector(".product-image");
|
||||
const arrow = card.querySelector(".arrow");
|
||||
if (showDetailPage) {
|
||||
return <ProductDetailPage perfumeSlug="kalter-beton" />;
|
||||
}
|
||||
|
||||
if (!hoverFill || !productImage || !arrow) {
|
||||
return null;
|
||||
}
|
||||
|
||||
gsap.set(hoverFill, { autoAlpha: 0, scale: 1.08 });
|
||||
gsap.set(productImage, { autoAlpha: 1, scale: 1 });
|
||||
gsap.set(arrow, { x: 0 });
|
||||
|
||||
return { card, hoverFill, hoverVideo, productImage, arrow };
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
const stopVideo = (video) => {
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
|
||||
video.pause();
|
||||
try {
|
||||
video.currentTime = 0;
|
||||
} catch {
|
||||
// Ignore if browser blocks random access while buffering.
|
||||
}
|
||||
};
|
||||
|
||||
const playVideo = (video) => {
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
video.currentTime = 0;
|
||||
} catch {
|
||||
// Ignore if browser blocks random access while buffering.
|
||||
}
|
||||
|
||||
const playAttempt = video.play();
|
||||
if (playAttempt && typeof playAttempt.catch === "function") {
|
||||
playAttempt.catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
const deactivate = (state) => {
|
||||
gsap.killTweensOf([state.hoverFill, state.productImage, state.arrow]);
|
||||
stopVideo(state.hoverVideo);
|
||||
|
||||
gsap.to(state.hoverFill, {
|
||||
autoAlpha: 0,
|
||||
scale: 1.08,
|
||||
duration: 0.35,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
gsap.to(state.productImage, {
|
||||
scale: 1,
|
||||
autoAlpha: 1,
|
||||
duration: 0.35,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
gsap.to(state.arrow, {
|
||||
x: 0,
|
||||
duration: 0.35,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
};
|
||||
|
||||
const activate = (state) => {
|
||||
cardStates.forEach((item) => {
|
||||
if (item !== state) {
|
||||
deactivate(item);
|
||||
}
|
||||
});
|
||||
|
||||
gsap.killTweensOf([state.hoverFill, state.productImage, state.arrow]);
|
||||
playVideo(state.hoverVideo);
|
||||
|
||||
gsap.to(state.hoverFill, {
|
||||
autoAlpha: 1,
|
||||
scale: 1,
|
||||
duration: 0.45,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
gsap.to(state.productImage, {
|
||||
scale: 0.92,
|
||||
autoAlpha: 0.35,
|
||||
duration: 0.45,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
gsap.to(state.arrow, {
|
||||
x: 8,
|
||||
duration: 0.45,
|
||||
ease: "power2.out",
|
||||
overwrite: "auto",
|
||||
});
|
||||
};
|
||||
|
||||
const cardCleanups = cardStates.map((state) => {
|
||||
const onEnter = () => activate(state);
|
||||
const onLeave = () => deactivate(state);
|
||||
|
||||
state.card.addEventListener("pointerenter", onEnter);
|
||||
state.card.addEventListener("pointerleave", onLeave);
|
||||
|
||||
return () => {
|
||||
state.card.removeEventListener("pointerenter", onEnter);
|
||||
state.card.removeEventListener("pointerleave", onLeave);
|
||||
};
|
||||
});
|
||||
|
||||
const resetAll = () => {
|
||||
cardStates.forEach((state) => deactivate(state));
|
||||
};
|
||||
|
||||
const onMouseOutWindow = (event) => {
|
||||
if (!event.relatedTarget) {
|
||||
resetAll();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("blur", resetAll);
|
||||
document.addEventListener("mouseout", onMouseOutWindow);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("blur", resetAll);
|
||||
document.removeEventListener("mouseout", onMouseOutWindow);
|
||||
cardCleanups.forEach((cleanup) => cleanup());
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
{/* Hero */}
|
||||
<header className="hero">
|
||||
{/* Navbar */}
|
||||
<nav className="navbar">
|
||||
<div className="nav-pill">
|
||||
<a href="#home" className="nav-link active">
|
||||
Name
|
||||
</a>
|
||||
<a href="#dufte" className="nav-link">
|
||||
Düfte
|
||||
</a>
|
||||
<a href="#testen" className="nav-link">
|
||||
Testen
|
||||
</a>
|
||||
<a href="#cart" className="nav-link">
|
||||
Cart
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
{/* --- Navbar End --- */}
|
||||
<div className="hero-overlay" />
|
||||
|
||||
<div className="hero-content">
|
||||
<p className="eyebrow">NISCHENDÜFTE</p>
|
||||
<h1>
|
||||
DÜFTE ALS
|
||||
<br />
|
||||
AUSDRUCK
|
||||
<br />
|
||||
VON KONZEPT
|
||||
</h1>
|
||||
<p className="hero-text">
|
||||
Konzeptuelle Düfte zwischen Materialität, Raum und Charakter.
|
||||
</p>
|
||||
|
||||
<div className="hero-actions">
|
||||
<button className="btn btn-primary">Aktuelle Düfte</button>
|
||||
<button className="btn btn-secondary">Discovery Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
{/* --- Hero End --- */}
|
||||
|
||||
<main>
|
||||
{/* Grid with Core Collection */}
|
||||
<section className="section" id="dufte">
|
||||
<div className="section-heading">
|
||||
<h2>
|
||||
WÄHLE EINE
|
||||
<br />
|
||||
ATMOSPHÄRE
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div className="product-grid">
|
||||
{perfumes.map((item, index) => (
|
||||
<article
|
||||
className="product-card"
|
||||
key={item.id}
|
||||
ref={(el) => {
|
||||
cardRefs.current[index] = el;
|
||||
}}
|
||||
>
|
||||
<div className="product-hover-fill" aria-hidden="true">
|
||||
{item.fillVideo ? (
|
||||
<video
|
||||
className="product-hover-video"
|
||||
src={item.fillVideo}
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
preload="metadata"
|
||||
/>
|
||||
) : (
|
||||
<div
|
||||
className="product-hover-image"
|
||||
style={{ backgroundImage: `url(${item.fillImage || item.image})` }}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="product-top">
|
||||
<span className="product-id">{item.id}</span>
|
||||
<h3>{item.name}</h3>
|
||||
</div>
|
||||
|
||||
<div className="product-image-wrap">
|
||||
<img src={item.image} alt={item.name} className="product-image" />
|
||||
</div>
|
||||
|
||||
<div className="product-bottom">
|
||||
<p>{item.text}</p>
|
||||
<span className="arrow">→</span>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
{/* --- Grid End --- */}
|
||||
|
||||
{/* Dicovery Set Section */}
|
||||
<section className="discovery-section" id="testen">
|
||||
<div className="discovery-copy">
|
||||
<h2>
|
||||
DER SICHERE EINSTIEG
|
||||
<br />
|
||||
DISCOVERY SET
|
||||
</h2>
|
||||
<p>
|
||||
6 Samples × 2ml.
|
||||
<br />
|
||||
Jeden Duft eine Woche tragen.
|
||||
<br />
|
||||
Verstehen, was funktioniert.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="discovery-banner">
|
||||
<img
|
||||
src="/DISCOVERYSET.png"
|
||||
alt="Discovery Set"
|
||||
/>
|
||||
<button className="banner-btn">Discovery Set bestellen</button>
|
||||
</div>
|
||||
</section>
|
||||
{/* --- Dicovery Set Section End--- */}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
return <LandingPage />;
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App;
|
||||
Reference in new issue
Block a user