fix: resolve tooltip opacity, species icons, catalog pagination and swipe, image frames and description collapse
This commit is contained in:
1 parent
0b52f9e9e4
commit
9daaa22677
17 files changed
+3050
-2970
No files matched your search
@@ -128,15 +128,18 @@ export default function CatalogPageSpread({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Hero Render Frame */}
|
||||
{/* Hero Render Frame: Brand Identity */}
|
||||
<div className="pt-2 flex justify-center">
|
||||
<div className="w-36 h-36 md:w-44 md:h-44 rounded-2xl bg-gradient-to-b from-white/10 to-white/5 border border-white/15 backdrop-blur-md p-3 flex flex-col items-center justify-center shadow-2xl relative">
|
||||
<SafeImage
|
||||
src="/assets/images/hero-section-image.png"
|
||||
alt="Canina Pharma Germany"
|
||||
className="w-full h-full"
|
||||
imgClassName="object-contain filter drop-shadow-xl"
|
||||
/>
|
||||
<div className="w-40 h-40 md:w-48 md:h-48 rounded-2xl bg-gradient-to-b from-white/10 to-white/5 border border-white/15 backdrop-blur-md p-4 flex flex-col items-center justify-center shadow-2xl relative">
|
||||
<div className="w-16 h-16 rounded-2xl bg-gradient-to-br from-amber-400 to-amber-500 text-slate-950 flex items-center justify-center font-black text-3xl font-mono shadow-xl mb-2">
|
||||
CP
|
||||
</div>
|
||||
<span className="text-xl font-black font-lalezar text-white tracking-wide">
|
||||
Canina Pharma
|
||||
</span>
|
||||
<span className="text-[9px] text-amber-300 font-bold uppercase tracking-widest font-mono mt-0.5">
|
||||
Germany • Est. 1984
|
||||
</span>
|
||||
<div className="absolute -bottom-2.5 bg-gradient-to-r from-amber-400 to-amber-500 text-slate-950 font-black text-[9px] px-3 py-0.5 rounded-full shadow-md">
|
||||
Pharma Grade Certified
|
||||
</div>
|
||||
|
||||
@@ -46,9 +46,7 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
|
||||
// 1. Build Category Metadata with dynamic starting pages
|
||||
const categoryMetaList: CategoryMeta[] = useMemo(() => {
|
||||
let currentStartPage = 3; // Page 1 = Cover, Page 2 = TOC
|
||||
|
||||
const cats: { id: string; name: string; color: string; lightBg: string; borderBg: string; icon: React.ElementType; tagline: string; filterKey: string }[] = [
|
||||
const cats: { id: string; name: string; color: string; lightBg: string; borderBg: string; icon: React.ElementType; tagline: string; matcher: (p: Product) => boolean }[] = [
|
||||
{
|
||||
id: "joints",
|
||||
name: "مفاصل، استخوان و اسکلت",
|
||||
@@ -57,7 +55,7 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
borderBg: "border-sky-200",
|
||||
icon: Activity,
|
||||
tagline: "بازسازی غضروف، هیدروکسی آپاتیت طبیعی و تراکم استخوان",
|
||||
filterKey: "مفاصل و استخوان"
|
||||
matcher: (p: Product) => (p.category || '').includes("مفاصل") || p.categorySlug === 'joints'
|
||||
},
|
||||
{
|
||||
id: "special-care",
|
||||
@@ -67,7 +65,7 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
borderBg: "border-teal-200",
|
||||
icon: Sparkles,
|
||||
tagline: "تکنولوژی نقره میکروسیلور، اسیدهای چرب امگا و ترمیم بیولوژیک",
|
||||
filterKey: "مراقبتهای ویژه (پوست، دندان و چشم)"
|
||||
matcher: (p: Product) => (p.category || '').includes("پوست") || (p.category || '').includes("مراقبت") || p.categorySlug === 'special-care'
|
||||
},
|
||||
{
|
||||
id: "immune",
|
||||
@@ -77,7 +75,7 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
borderBg: "border-emerald-200",
|
||||
icon: ShieldCheck,
|
||||
tagline: "خمیر آغوز متمرکز (Colostrum) و تقویت فوری ایمونوگلوبولینها",
|
||||
filterKey: "تقویت سیستم ایمنی و گوارش"
|
||||
matcher: (p: Product) => (p.category || '').includes("ایمنی") || (p.category || '').includes("گوارش") || p.categorySlug === 'immune'
|
||||
},
|
||||
{
|
||||
id: "vitamins",
|
||||
@@ -87,7 +85,7 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
borderBg: "border-amber-200",
|
||||
icon: Zap,
|
||||
tagline: "تامین عناصر کمیاب، هموگلوبین و توان فیزیکی پتها",
|
||||
filterKey: "ویتامینها و انرژیبخشها"
|
||||
matcher: (p: Product) => (p.category || '').includes("ویتامین") || (p.category || '').includes("تقویت عمومی") || (p.category || '').includes("انرژی") || p.categorySlug === 'energy' || p.categorySlug === 'general'
|
||||
},
|
||||
{
|
||||
id: "nutrition",
|
||||
@@ -97,14 +95,22 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
borderBg: "border-purple-200",
|
||||
icon: Baby,
|
||||
tagline: "شیرهای جایگزین مادر با پروتئین بالا و فرنیهای تغذیه تکمیلی",
|
||||
filterKey: "تغذیه تخصصی"
|
||||
matcher: (p: Product) => (p.category || '').includes("تغذیه") || (p.category || '').includes("مکمل") || p.categorySlug === 'nutrition' || p.categorySlug === 'supplements' || (!p.category && !p.categorySlug)
|
||||
}
|
||||
];
|
||||
|
||||
let currentStartPage = 3; // Page 1 = Cover, Page 2 = TOC
|
||||
|
||||
return cats.map(cat => {
|
||||
const count = products.filter(p => p.category === cat.filterKey || (cat.id === "vitamins" && p.category === "تقویت عمومی")).length;
|
||||
const count = products.filter(cat.matcher).length;
|
||||
const meta: CategoryMeta = {
|
||||
...cat,
|
||||
id: cat.id,
|
||||
name: cat.name,
|
||||
color: cat.color,
|
||||
lightBg: cat.lightBg,
|
||||
borderBg: cat.borderBg,
|
||||
icon: cat.icon,
|
||||
tagline: cat.tagline,
|
||||
startPage: currentStartPage
|
||||
};
|
||||
currentStartPage += Math.max(count, 1);
|
||||
@@ -117,16 +123,21 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
const list: { product: Product; categoryMeta: CategoryMeta; pageNum: number }[] = [];
|
||||
let pageCounter = 3;
|
||||
|
||||
const matchedIds = new Set<string>();
|
||||
|
||||
categoryMetaList.forEach(cat => {
|
||||
const catProds = products.filter(p =>
|
||||
p.category === (cat.id === "joints" ? "مفاصل و استخوان" :
|
||||
cat.id === "special-care" ? "مراقبتهای ویژه (پوست، دندان و چشم)" :
|
||||
cat.id === "immune" ? "تقویت سیستم ایمنی و گوارش" :
|
||||
cat.id === "vitamins" ? (p.category === "ویتامینها و انرژیبخشها" || p.category === "تقویت عمومی") :
|
||||
p.category === "تغذیه تخصصی")
|
||||
);
|
||||
const matcher = (p: Product) => {
|
||||
if (cat.id === "joints") return (p.category || '').includes("مفاصل") || p.categorySlug === 'joints';
|
||||
if (cat.id === "special-care") return (p.category || '').includes("پوست") || (p.category || '').includes("مراقبت") || p.categorySlug === 'special-care';
|
||||
if (cat.id === "immune") return (p.category || '').includes("ایمنی") || (p.category || '').includes("گوارش") || p.categorySlug === 'immune';
|
||||
if (cat.id === "vitamins") return (p.category || '').includes("ویتامین") || (p.category || '').includes("تقویت عمومی") || (p.category || '').includes("انرژی") || p.categorySlug === 'energy' || p.categorySlug === 'general';
|
||||
return (p.category || '').includes("تغذیه") || (p.category || '').includes("مکمل") || p.categorySlug === 'nutrition' || p.categorySlug === 'supplements';
|
||||
};
|
||||
|
||||
const catProds = products.filter(p => !matchedIds.has(p.id) && matcher(p));
|
||||
|
||||
catProds.forEach(prod => {
|
||||
matchedIds.add(prod.id);
|
||||
list.push({
|
||||
product: prod,
|
||||
categoryMeta: cat,
|
||||
@@ -135,6 +146,19 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
});
|
||||
});
|
||||
|
||||
// Catch any remaining unmatched products and add under nutrition/general
|
||||
const remaining = products.filter(p => !matchedIds.has(p.id));
|
||||
if (remaining.length > 0) {
|
||||
const fallbackCat = categoryMetaList[categoryMetaList.length - 1] || categoryMetaList[0];
|
||||
remaining.forEach(prod => {
|
||||
list.push({
|
||||
product: prod,
|
||||
categoryMeta: fallbackCat,
|
||||
pageNum: pageCounter++
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}, [products, categoryMetaList]);
|
||||
|
||||
@@ -301,6 +325,38 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
const prevRightPageNum = currentPage <= 3 ? 1 : currentPage - 2;
|
||||
const prevLeftPageNum = currentPage <= 3 ? 0 : currentPage - 1;
|
||||
|
||||
// Touch swipe gesture handlers for mobile flip (RTL: swipe right -> next, swipe left -> prev)
|
||||
const touchStartXRef = useRef<number | null>(null);
|
||||
const touchStartYRef = useRef<number | null>(null);
|
||||
|
||||
const handleTouchStart = (e: React.TouchEvent) => {
|
||||
if (e.touches.length === 1) {
|
||||
touchStartXRef.current = e.touches[0].clientX;
|
||||
touchStartYRef.current = e.touches[0].clientY;
|
||||
}
|
||||
};
|
||||
|
||||
const handleTouchEnd = (e: React.TouchEvent) => {
|
||||
if (touchStartXRef.current === null || touchStartYRef.current === null) return;
|
||||
if (e.changedTouches.length === 1) {
|
||||
const diffX = e.changedTouches[0].clientX - touchStartXRef.current;
|
||||
const diffY = e.changedTouches[0].clientY - touchStartYRef.current;
|
||||
|
||||
// Horizontal swipe threshold: 40px, and horizontal displacement > vertical displacement
|
||||
if (Math.abs(diffX) > 40 && Math.abs(diffX) > Math.abs(diffY)) {
|
||||
if (diffX > 0) {
|
||||
// Swipe right in RTL -> Advance to next page
|
||||
handleNext();
|
||||
} else {
|
||||
// Swipe left in RTL -> Go to previous page
|
||||
handlePrev();
|
||||
}
|
||||
}
|
||||
}
|
||||
touchStartXRef.current = null;
|
||||
touchStartYRef.current = null;
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
@@ -310,6 +366,8 @@ export default function FlipbookCatalog({ products }: FlipbookCatalogProps) {
|
||||
: "h-[calc(100vh-140px)] min-h-[580px] max-h-[880px] py-2 px-3 sm:px-6"
|
||||
}`}
|
||||
dir="rtl"
|
||||
onTouchStart={handleTouchStart}
|
||||
onTouchEnd={handleTouchEnd}
|
||||
>
|
||||
{/* ========================================================================= */}
|
||||
{/* 1. TOP TOOLBAR (Controls, Search, Print, Fullscreen) - Fixed Height */}
|
||||
|
||||
Reference in new issue
Block a user