Просмотр исходного кода

feat module 1,2,4 : [UI] fixed navbar transition

master
nadia 2 дней назад
Родитель
Сommit
09fb75ad0f
1 измененных файлов: 76 добавлений и 40 удалений
  1. 76
    40
      src/components/Navbar/Navbar.jsx

+ 76
- 40
src/components/Navbar/Navbar.jsx Просмотреть файл

389
       clearTimeout(childTransitionTimerRef.current);
389
       clearTimeout(childTransitionTimerRef.current);
390
     }
390
     }
391
 
391
 
392
-    setActiveGroup(null);
393
-    childTransitionTimerRef.current = setTimeout(() => {
394
-      setActiveGroup(groupLabel);
395
-    }, 40);
392
+    setActiveGroup(groupLabel);
396
   }
393
   }
397
 
394
 
398
   const findCollectionForMenuItem = (productType, item) => {
395
   const findCollectionForMenuItem = (productType, item) => {
615
                           position: "absolute",
612
                           position: "absolute",
616
                           top: "100%",
613
                           top: "100%",
617
                           left: 0,
614
                           left: 0,
618
-                          width: menu.groups ? (activeGroup ? 560 : 260) : 260,
615
+                          width: menu.groups ? 560 : 260,
619
                           height: dropdownTopOffset,
616
                           height: dropdownTopOffset,
620
                           zIndex: 1000,
617
                           zIndex: 1000,
621
                           backgroundColor: "transparent",
618
                           backgroundColor: "transparent",
622
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
619
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
623
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
620
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
621
+                          transition: "width .25s ease-in-out",
624
                         }}
622
                         }}
625
                       />
623
                       />
626
                       {/* Submenu dropdown card: controls dropdown position, width, background, and animation */}
624
                       {/* Submenu dropdown card: controls dropdown position, width, background, and animation */}
630
                           // Measured from this menu label to the real bottom of the navbar.
628
                           // Measured from this menu label to the real bottom of the navbar.
631
                           top: dropdownTopOffset,
629
                           top: dropdownTopOffset,
632
                           left: 0,
630
                           left: 0,
633
-                          width: menu.groups ? (activeGroup ? 560 : 260) : 260,
634
-                          backgroundColor: "#FFF",
631
+                          width: menu.groups ? 560 : 260,
632
+                          backgroundColor: menu.groups ? "transparent" : "#FFF",
635
                           color: "#000",
633
                           color: "#000",
636
-                          border: "1px solid rgba(0,0,0,0.08)",
634
+                          border: menu.groups ? 0 : "1px solid rgba(0,0,0,0.08)",
637
                           borderTop: 0,
635
                           borderTop: 0,
638
-                          boxShadow: "0 2px 6px rgba(0,0,0,0.12)",
636
+                          boxShadow: menu.groups ? "none" : "0 2px 6px rgba(0,0,0,0.12)",
639
                           display: "flex",
637
                           display: "flex",
640
-                          minHeight: "auto",
638
+                          minHeight: menu.groups && activeGroup
639
+                            ? `${Math.max(
640
+                              160,
641
+                              ((menu.groups.find((group) => group.label === activeGroup)?.children.length || 0) * 50) + 24
642
+                            )}px`
643
+                            : "auto",
641
                           zIndex: 1001,
644
                           zIndex: 1001,
642
-                          overflow: "hidden",
645
+                          overflow: "visible",
643
                           opacity: activeMenu === menu.label ? 1 : 0,
646
                           opacity: activeMenu === menu.label ? 1 : 0,
644
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
647
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
645
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
648
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
646
                           clipPath: activeMenu === menu.label ? "polygon(0 0, 100% 0, 100% 100%, 0 100%)" : "polygon(0 0, 100% 0, 100% 0, 0 0)",
649
                           clipPath: activeMenu === menu.label ? "polygon(0 0, 100% 0, 100% 100%, 0 100%)" : "polygon(0 0, 100% 0, 100% 0, 0 0)",
647
-                          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",
650
+                          willChange: "clip-path, opacity",
651
+                          transition: "clip-path .4s ease-in-out, visibility .4s ease-in-out, opacity .4s ease-in-out",
648
                         }}
652
                         }}
649
                       >
653
                       >
650
                       {menu.groups ? (
654
                       {menu.groups ? (
651
                         <>
655
                         <>
652
                           {/* Submenu group list: CASUAL, TRADITIONAL */}
656
                           {/* Submenu group list: CASUAL, TRADITIONAL */}
653
-                          <Box sx={{ width: 260, pb: 1.5, borderRight: "1px solid rgba(0,0,0,0.12)" }}>
657
+                          <Box sx={{
658
+                            width: 260,
659
+                            pb: 1.5,
660
+                            backgroundColor: "#FFF",
661
+                            border: "1px solid rgba(0,0,0,0.08)",
662
+                            borderTop: 0,
663
+                            borderRight: "1px solid rgba(0,0,0,0.12)",
664
+                            boxShadow: "0 2px 6px rgba(0,0,0,0.12)",
665
+                          }}>
654
                             {menu.groups.map((group) => (
666
                             {menu.groups.map((group) => (
655
                               <Button
667
                               <Button
656
                                 key={group.label}
668
                                 key={group.label}
678
                           {/* Child submenu links: collection names shown after hovering a submenu group */}
690
                           {/* Child submenu links: collection names shown after hovering a submenu group */}
679
                           {activeGroup && (
691
                           {activeGroup && (
680
                             <Box key={activeGroup} sx={{
692
                             <Box key={activeGroup} sx={{
681
-                              pb: 1.5,
682
-                              px: 3,
693
+                              position: "absolute",
694
+                              top: -1,
695
+                              left: 260,
696
+                              minHeight: "calc(100% + 24px)",
697
+                              height: "auto",
698
+                              boxSizing: "border-box",
699
+                              backgroundColor: "#FFF",
700
+                              border: "1px solid rgba(0,0,0,0.08)",
701
+                              borderLeft: 0,
702
+                              boxShadow: "2px 2px 6px rgba(0,0,0,0.08)",
703
+                              py: 1.5,
683
                               width: 300,
704
                               width: 300,
684
                               clipPath: "polygon(0 0, 100% 0, 100% 100%, 0 100%)",
705
                               clipPath: "polygon(0 0, 100% 0, 100% 100%, 0 100%)",
685
                               overflow: "hidden",
706
                               overflow: "hidden",
686
-                              position: "relative",
687
-                              animation: "childCardReveal .55s ease-in-out",
707
+                              willChange: "clip-path",
708
+                              animation: "childCardReveal .45s ease-in-out",
688
                               "@keyframes childCardReveal": {
709
                               "@keyframes childCardReveal": {
689
                                 "0%": {
710
                                 "0%": {
690
                                   clipPath: "polygon(0 0, 0 0, 0 100%, 0 100%)",
711
                                   clipPath: "polygon(0 0, 0 0, 0 100%, 0 100%)",
694
                                 },
715
                                 },
695
                               },
716
                               },
696
                             }}>
717
                             }}>
697
-                              {menu.groups
698
-                                .find((group) => group.label === activeGroup)
699
-                                ?.children.map((item) => (
700
-                                  <Button
701
-                                    key={item.label}
702
-                                    fullWidth
703
-                                    onClick={() => navigateToMenuItem(menu.productType, item)}
704
-                                    sx={{
705
-                                      justifyContent: "flex-start",
706
-                                      color: "#000",
707
-                                      textTransform: "none",
708
-                                      fontSize: "0.875rem",
709
-                                      py: 1.1,
710
-                                      px: 0,
711
-                                      '&:hover': {
712
-                                        backgroundColor: "transparent",
713
-                                        color: "#95AAC5",
714
-                                      }
715
-                                    }}
716
-                                  >
717
-                                    {item.label?.toUpperCase()}
718
-                                  </Button>
719
-                                ))}
718
+                              <Box sx={{ px: 3 }}>
719
+                                {menu.groups
720
+                                  .find((group) => group.label === activeGroup)
721
+                                  ?.children.map((item) => (
722
+                                    <Button
723
+                                      key={item.label}
724
+                                      fullWidth
725
+                                      onClick={() => navigateToMenuItem(menu.productType, item)}
726
+                                      sx={{
727
+                                        justifyContent: "flex-start",
728
+                                        color: "#000",
729
+                                        textTransform: "none",
730
+                                        fontSize: "0.875rem",
731
+                                        py: 1.1,
732
+                                        px: 0,
733
+                                        whiteSpace: "nowrap",
734
+                                        overflow: "hidden",
735
+                                        textAlign: "left",
736
+                                        '& .MuiButton-startIcon, & .MuiButton-endIcon': {
737
+                                          margin: 0,
738
+                                        },
739
+                                        '& .MuiButtonBase-root': {
740
+                                          textAlign: "left",
741
+                                        },
742
+                                        '& .MuiButton-label': {
743
+                                          width: "100%",
744
+                                          textAlign: "left",
745
+                                        },
746
+                                        '&:hover': {
747
+                                          backgroundColor: "transparent",
748
+                                          color: "#95AAC5",
749
+                                        }
750
+                                      }}
751
+                                    >
752
+                                      {item.label?.toUpperCase()}
753
+                                    </Button>
754
+                                  ))}
755
+                              </Box>
720
                             </Box>
756
                             </Box>
721
                           )}
757
                           )}
722
                         </>
758
                         </>

Загрузка…
Отмена
Сохранить