|
|
@@ -87,6 +87,40 @@ const getProductTypeMenuLabel = (productType = "") => {
|
|
87
|
87
|
return normalizeTitle(productType) === "BEAUTY" ? "Essentials" : productType;
|
|
88
|
88
|
};
|
|
89
|
89
|
|
|
|
90
|
+const NAV_MENU_STRUCTURE = [
|
|
|
91
|
+ {
|
|
|
92
|
+ productType: "Apparel",
|
|
|
93
|
+ label: "APPAREL",
|
|
|
94
|
+ groups: [
|
|
|
95
|
+ {
|
|
|
96
|
+ label: "Casual",
|
|
|
97
|
+ children: [
|
|
|
98
|
+ { label: "ND X Marii for Amber", titles: ["ND X MARII FOR AMBER"] },
|
|
|
99
|
+ { label: "Somewhere Somehow Someone", titles: ["SOMEWHERE SOMEHOW SOMEONE"] },
|
|
|
100
|
+ { label: "Flower Power", titles: ["FLOWER POWER"] },
|
|
|
101
|
+ ],
|
|
|
102
|
+ },
|
|
|
103
|
+ {
|
|
|
104
|
+ label: "Traditional",
|
|
|
105
|
+ children: [
|
|
|
106
|
+ { label: "Eid's Time For Love", titles: ["EID'S TIME FOR LOVE"] },
|
|
|
107
|
+ { label: "Raya Romantics", titles: ["RAYA ROMANTICS COLLECTION 2025"] },
|
|
|
108
|
+ { label: "Atma Sari", titles: ["ATMA SARI"] },
|
|
|
109
|
+ { label: "Oasis abaya collection", titles: ["OASIS ABAYA COLLECTION", "MIRAGE COLLECTION"] },
|
|
|
110
|
+ ],
|
|
|
111
|
+ },
|
|
|
112
|
+ ],
|
|
|
113
|
+ },
|
|
|
114
|
+ {
|
|
|
115
|
+ productType: "BEAUTY",
|
|
|
116
|
+ label: "Essentials",
|
|
|
117
|
+ children: [
|
|
|
118
|
+ { label: "Cosmetics", titles: ["COSMETICS"] },
|
|
|
119
|
+ { label: "Hand & Body Lotion", titles: ["HAND & BODY LOTION"] },
|
|
|
120
|
+ ],
|
|
|
121
|
+ },
|
|
|
122
|
+];
|
|
|
123
|
+
|
|
90
|
124
|
const sortCollectionsByPriority = (collection = [], productType = "") => {
|
|
91
|
125
|
const typeKey = (productType || "").trim().toLowerCase();
|
|
92
|
126
|
const priorityList = COLLECTION_PRIORITY_BY_TYPE[typeKey] || [];
|
|
|
@@ -165,6 +199,7 @@ function getUniqueCollections(data) {
|
|
165
|
199
|
const Navbar = () => {
|
|
166
|
200
|
|
|
167
|
201
|
const swiperRef = useRef(null); // Create a ref for the Swiper instance
|
|
|
202
|
+ const childTransitionTimerRef = useRef(null);
|
|
168
|
203
|
const [showHeader, setShowHeader] = useState(true);
|
|
169
|
204
|
const [showSearch, setShowSearch] = useState(false);
|
|
170
|
205
|
const [isAtTop, setIsAtTop] = useState(false);
|
|
|
@@ -181,6 +216,8 @@ const Navbar = () => {
|
|
181
|
216
|
const [openSideCart, setOpenSideCart] = useState(false);
|
|
182
|
217
|
const [navItem, setNavItem] = useState([]);
|
|
183
|
218
|
const [navItemCompanyInfo, setNavItemCompanyInfo] = useState([]);
|
|
|
219
|
+ const [activeMenu, setActiveMenu] = useState(null);
|
|
|
220
|
+ const [activeGroup, setActiveGroup] = useState(null);
|
|
184
|
221
|
|
|
185
|
222
|
const [displayCollection, setDisplayCollection] = useState({
|
|
186
|
223
|
productType: null,
|
|
|
@@ -342,6 +379,35 @@ const Navbar = () => {
|
|
342
|
379
|
setDisplayCollection([])
|
|
343
|
380
|
}
|
|
344
|
381
|
|
|
|
382
|
+ const handleGroupMouseEnter = (groupLabel) => {
|
|
|
383
|
+ if (activeGroup === groupLabel) return;
|
|
|
384
|
+
|
|
|
385
|
+ if (childTransitionTimerRef.current) {
|
|
|
386
|
+ clearTimeout(childTransitionTimerRef.current);
|
|
|
387
|
+ }
|
|
|
388
|
+
|
|
|
389
|
+ setActiveGroup(null);
|
|
|
390
|
+ childTransitionTimerRef.current = setTimeout(() => {
|
|
|
391
|
+ setActiveGroup(groupLabel);
|
|
|
392
|
+ }, 40);
|
|
|
393
|
+ }
|
|
|
394
|
+
|
|
|
395
|
+ const navigateToMenuItem = (productType, item = null) => {
|
|
|
396
|
+ sessionStorage.setItem('amber-select-product-type', productType)
|
|
|
397
|
+ sessionStorage.removeItem('amber-select-collection')
|
|
|
398
|
+ sessionStorage.removeItem('amber-select-collections')
|
|
|
399
|
+
|
|
|
400
|
+ if (item) {
|
|
|
401
|
+ sessionStorage.setItem('amber-select-collection', JSON.stringify({
|
|
|
402
|
+ title: item.label,
|
|
|
403
|
+ image: null
|
|
|
404
|
+ }))
|
|
|
405
|
+ sessionStorage.setItem('amber-select-collections', JSON.stringify(item.titles || []))
|
|
|
406
|
+ }
|
|
|
407
|
+
|
|
|
408
|
+ window.location.href = `/products`;
|
|
|
409
|
+ }
|
|
|
410
|
+
|
|
345
|
411
|
return (
|
|
346
|
412
|
<>
|
|
347
|
413
|
<AppBar position="fixed"
|
|
|
@@ -364,6 +430,8 @@ const Navbar = () => {
|
|
364
|
430
|
}}
|
|
365
|
431
|
onMouseLeave={() => {
|
|
366
|
432
|
hideCollectionList()
|
|
|
433
|
+ setActiveMenu(null)
|
|
|
434
|
+ setActiveGroup(null)
|
|
367
|
435
|
}}
|
|
368
|
436
|
>
|
|
369
|
437
|
|
|
|
@@ -444,6 +512,202 @@ const Navbar = () => {
|
|
444
|
512
|
}}
|
|
445
|
513
|
>
|
|
446
|
514
|
|
|
|
515
|
+ {NAV_MENU_STRUCTURE.map((menu) => (
|
|
|
516
|
+ <Box
|
|
|
517
|
+ key={menu.label}
|
|
|
518
|
+ sx={{ position: "relative" }}
|
|
|
519
|
+ onMouseEnter={() => {
|
|
|
520
|
+ if (childTransitionTimerRef.current) {
|
|
|
521
|
+ clearTimeout(childTransitionTimerRef.current);
|
|
|
522
|
+ }
|
|
|
523
|
+ setActiveMenu(menu.label);
|
|
|
524
|
+ setActiveGroup(null);
|
|
|
525
|
+ }}
|
|
|
526
|
+ >
|
|
|
527
|
+ <Button
|
|
|
528
|
+ sx={{
|
|
|
529
|
+ position: "relative",
|
|
|
530
|
+ ':hover': {
|
|
|
531
|
+ backgroundColor: "rgba(0,0,0,0)",
|
|
|
532
|
+ }
|
|
|
533
|
+ }}
|
|
|
534
|
+ color="inherit"
|
|
|
535
|
+ onClick={() => {
|
|
|
536
|
+ if (!menu.groups && !menu.children) {
|
|
|
537
|
+ navigateToMenuItem(menu.productType)
|
|
|
538
|
+ }
|
|
|
539
|
+ }}
|
|
|
540
|
+ >
|
|
|
541
|
+ <Typography variant="body2"
|
|
|
542
|
+ className="navItem"
|
|
|
543
|
+ sx={{
|
|
|
544
|
+ fontSize: {
|
|
|
545
|
+ xs: "0.73rem",
|
|
|
546
|
+ sm: "0.73rem",
|
|
|
547
|
+ md: "0.875rem",
|
|
|
548
|
+ },
|
|
|
549
|
+ color: (isAtTop) ? "white" : "black",
|
|
|
550
|
+ transition: "all 0.3s ease-in-out",
|
|
|
551
|
+ ":hover": {
|
|
|
552
|
+ color: "#95AAC5 !important"
|
|
|
553
|
+ },
|
|
|
554
|
+ "&::after": {
|
|
|
555
|
+ content: '""',
|
|
|
556
|
+ position: "absolute",
|
|
|
557
|
+ left: "50%",
|
|
|
558
|
+ transform: "translateX(-50%)",
|
|
|
559
|
+ bottom: 2,
|
|
|
560
|
+ width: activeMenu === menu.label ? "70%" : "0%",
|
|
|
561
|
+ height: "2px",
|
|
|
562
|
+ backgroundColor: "#95AAC5",
|
|
|
563
|
+ transition: "width 0.3s ease-in-out",
|
|
|
564
|
+ },
|
|
|
565
|
+ ":hover::after": {
|
|
|
566
|
+ width: "70%",
|
|
|
567
|
+ },
|
|
|
568
|
+ }}>{menu.label}</Typography>
|
|
|
569
|
+ </Button>
|
|
|
570
|
+
|
|
|
571
|
+ {(
|
|
|
572
|
+ <>
|
|
|
573
|
+ <Box
|
|
|
574
|
+ sx={{
|
|
|
575
|
+ position: "absolute",
|
|
|
576
|
+ top: "100%",
|
|
|
577
|
+ left: 0,
|
|
|
578
|
+ width: menu.groups ? (activeGroup ? 560 : 260) : 260,
|
|
|
579
|
+ height: 28,
|
|
|
580
|
+ zIndex: 1000,
|
|
|
581
|
+ backgroundColor: "transparent",
|
|
|
582
|
+ visibility: activeMenu === menu.label ? "visible" : "hidden",
|
|
|
583
|
+ pointerEvents: activeMenu === menu.label ? "auto" : "none",
|
|
|
584
|
+ }}
|
|
|
585
|
+ />
|
|
|
586
|
+ <Box
|
|
|
587
|
+ sx={{
|
|
|
588
|
+ position: "absolute",
|
|
|
589
|
+ top: 60,
|
|
|
590
|
+ left: 0,
|
|
|
591
|
+ width: menu.groups ? (activeGroup ? 560 : 260) : 260,
|
|
|
592
|
+ backgroundColor: "#FFF",
|
|
|
593
|
+ color: "#000",
|
|
|
594
|
+ border: "1px solid rgba(0,0,0,0.08)",
|
|
|
595
|
+ borderTop: 0,
|
|
|
596
|
+ boxShadow: "0 2px 6px rgba(0,0,0,0.12)",
|
|
|
597
|
+ display: "flex",
|
|
|
598
|
+ minHeight: "auto",
|
|
|
599
|
+ zIndex: 1001,
|
|
|
600
|
+ overflow: "hidden",
|
|
|
601
|
+ opacity: activeMenu === menu.label ? 1 : 0,
|
|
|
602
|
+ visibility: activeMenu === menu.label ? "visible" : "hidden",
|
|
|
603
|
+ pointerEvents: activeMenu === menu.label ? "auto" : "none",
|
|
|
604
|
+ clipPath: activeMenu === menu.label ? "polygon(0 0, 100% 0, 100% 100%, 0 100%)" : "polygon(0 0, 100% 0, 100% 0, 0 0)",
|
|
|
605
|
+ transition: activeGroup ? "clip-path .45s ease-in-out, visibility .45s ease-in-out, opacity .45s ease-in-out, width .55s ease-in-out" : "clip-path .45s ease-in-out, visibility .45s ease-in-out, opacity .45s ease-in-out",
|
|
|
606
|
+ }}
|
|
|
607
|
+ >
|
|
|
608
|
+ {menu.groups ? (
|
|
|
609
|
+ <>
|
|
|
610
|
+ <Box sx={{ width: 260, pb: 1.5, borderRight: "1px solid rgba(0,0,0,0.12)" }}>
|
|
|
611
|
+ {menu.groups.map((group) => (
|
|
|
612
|
+ <Button
|
|
|
613
|
+ key={group.label}
|
|
|
614
|
+ fullWidth
|
|
|
615
|
+ onMouseEnter={() => handleGroupMouseEnter(group.label)}
|
|
|
616
|
+ sx={{
|
|
|
617
|
+ justifyContent: "space-between",
|
|
|
618
|
+ color: activeGroup === group.label ? "#95AAC5" : "#000",
|
|
|
619
|
+ textTransform: "none",
|
|
|
620
|
+ fontSize: "0.875rem",
|
|
|
621
|
+ py: 1.5,
|
|
|
622
|
+ px: 3,
|
|
|
623
|
+ '&:hover': {
|
|
|
624
|
+ backgroundColor: "transparent",
|
|
|
625
|
+ color: "#95AAC5",
|
|
|
626
|
+ }
|
|
|
627
|
+ }}
|
|
|
628
|
+ >
|
|
|
629
|
+ {group.label?.toUpperCase()}
|
|
|
630
|
+ <KeyboardArrowRightIcon sx={{ fontSize: 20 }} />
|
|
|
631
|
+ </Button>
|
|
|
632
|
+ ))}
|
|
|
633
|
+ </Box>
|
|
|
634
|
+
|
|
|
635
|
+ {activeGroup && (
|
|
|
636
|
+ <Box key={activeGroup} sx={{
|
|
|
637
|
+ pb: 1.5,
|
|
|
638
|
+ px: 3,
|
|
|
639
|
+ width: 300,
|
|
|
640
|
+ clipPath: "polygon(0 0, 100% 0, 100% 100%, 0 100%)",
|
|
|
641
|
+ overflow: "hidden",
|
|
|
642
|
+ position: "relative",
|
|
|
643
|
+ animation: "childCardReveal .55s ease-in-out",
|
|
|
644
|
+ "@keyframes childCardReveal": {
|
|
|
645
|
+ "0%": {
|
|
|
646
|
+ clipPath: "polygon(0 0, 0 0, 0 100%, 0 100%)",
|
|
|
647
|
+ },
|
|
|
648
|
+ "100%": {
|
|
|
649
|
+ clipPath: "polygon(0 0, 100% 0, 100% 100%, 0 100%)",
|
|
|
650
|
+ },
|
|
|
651
|
+ },
|
|
|
652
|
+ }}>
|
|
|
653
|
+ {menu.groups
|
|
|
654
|
+ .find((group) => group.label === activeGroup)
|
|
|
655
|
+ ?.children.map((item) => (
|
|
|
656
|
+ <Button
|
|
|
657
|
+ key={item.label}
|
|
|
658
|
+ fullWidth
|
|
|
659
|
+ onClick={() => navigateToMenuItem(menu.productType, item)}
|
|
|
660
|
+ sx={{
|
|
|
661
|
+ justifyContent: "flex-start",
|
|
|
662
|
+ color: "#000",
|
|
|
663
|
+ textTransform: "none",
|
|
|
664
|
+ fontSize: "0.875rem",
|
|
|
665
|
+ py: 1.1,
|
|
|
666
|
+ px: 0,
|
|
|
667
|
+ '&:hover': {
|
|
|
668
|
+ backgroundColor: "transparent",
|
|
|
669
|
+ color: "#95AAC5",
|
|
|
670
|
+ }
|
|
|
671
|
+ }}
|
|
|
672
|
+ >
|
|
|
673
|
+ {item.label?.toUpperCase()}
|
|
|
674
|
+ </Button>
|
|
|
675
|
+ ))}
|
|
|
676
|
+ </Box>
|
|
|
677
|
+ )}
|
|
|
678
|
+ </>
|
|
|
679
|
+ ) : (
|
|
|
680
|
+ <Box sx={{ pb: 1.5, px: 3, width: 260 }}>
|
|
|
681
|
+ {menu.children.map((item) => (
|
|
|
682
|
+ <Button
|
|
|
683
|
+ key={item.label}
|
|
|
684
|
+ fullWidth
|
|
|
685
|
+ onClick={() => navigateToMenuItem(menu.productType, item)}
|
|
|
686
|
+ sx={{
|
|
|
687
|
+ justifyContent: "flex-start",
|
|
|
688
|
+ color: "#000",
|
|
|
689
|
+ textTransform: "none",
|
|
|
690
|
+ fontSize: "0.875rem",
|
|
|
691
|
+ py: 1.1,
|
|
|
692
|
+ px: 0,
|
|
|
693
|
+ '&:hover': {
|
|
|
694
|
+ backgroundColor: "transparent",
|
|
|
695
|
+ color: "#95AAC5",
|
|
|
696
|
+ }
|
|
|
697
|
+ }}
|
|
|
698
|
+ >
|
|
|
699
|
+ {item.label?.toUpperCase()}
|
|
|
700
|
+ </Button>
|
|
|
701
|
+ ))}
|
|
|
702
|
+ </Box>
|
|
|
703
|
+ )}
|
|
|
704
|
+ </Box>
|
|
|
705
|
+ </>
|
|
|
706
|
+ )}
|
|
|
707
|
+ </Box>
|
|
|
708
|
+ ))}
|
|
|
709
|
+
|
|
|
710
|
+ {/*
|
|
447
|
711
|
{navItem.map(({ productType, collection }) => (<Button
|
|
448
|
712
|
sx={{
|
|
449
|
713
|
position: "relative",
|
|
|
@@ -481,12 +745,12 @@ const Navbar = () => {
|
|
481
|
745
|
transform: "translateX(-50%)",
|
|
482
|
746
|
bottom: 2,
|
|
483
|
747
|
width: "0%",
|
|
484
|
|
- height: "2px", // Thickness of the underline
|
|
|
748
|
+ height: "2px",
|
|
485
|
749
|
backgroundColor: "#95AAC5",
|
|
486
|
750
|
transition: "width 0.3s ease-in-out",
|
|
487
|
751
|
},
|
|
488
|
752
|
":hover::after": {
|
|
489
|
|
- width: "50%", // Expands on hover
|
|
|
753
|
+ width: "50%",
|
|
490
|
754
|
},
|
|
491
|
755
|
}}>{getProductTypeMenuLabel(productType)}</Typography>
|
|
492
|
756
|
</Button>))}
|
|
|
@@ -523,15 +787,16 @@ const Navbar = () => {
|
|
523
|
787
|
transform: "translateX(-50%)",
|
|
524
|
788
|
bottom: 2,
|
|
525
|
789
|
width: "0%",
|
|
526
|
|
- height: "2px", // Thickness of the underline
|
|
|
790
|
+ height: "2px",
|
|
527
|
791
|
backgroundColor: "#95AAC5",
|
|
528
|
792
|
transition: "width 0.3s ease-in-out",
|
|
529
|
793
|
},
|
|
530
|
794
|
":hover::after": {
|
|
531
|
|
- width: "70%", // Expands on hover
|
|
|
795
|
+ width: "70%",
|
|
532
|
796
|
},
|
|
533
|
797
|
}}>{name}</Typography>
|
|
534
|
798
|
</Button>))}
|
|
|
799
|
+ */}
|
|
535
|
800
|
|
|
536
|
801
|
|
|
537
|
802
|
|
|
|
@@ -638,7 +903,7 @@ const Navbar = () => {
|
|
638
|
903
|
</AppBar>
|
|
639
|
904
|
{showSearch && <SearchProduct onClose={() => { setShowSearch(false) }} />}
|
|
640
|
905
|
|
|
641
|
|
- <MobileNav open={openSideMenu} menu={navItem} infomenu={navItemCompanyInfo} onClose={() => { setOpenSideMenu(false) }} />
|
|
|
906
|
+ <MobileNav open={openSideMenu} menu={NAV_MENU_STRUCTURE} infomenu={navItemCompanyInfo} onClose={() => { setOpenSideMenu(false) }} />
|
|
642
|
907
|
<SideCart open={openSideCart} onClose={() => { setOpenSideCart(false) }} />
|
|
643
|
908
|
|
|
644
|
909
|
</>
|