Ver código fonte

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

master
nadia 2 dias atrás
pai
commit
09fb75ad0f
1 arquivos alterados com 76 adições e 40 exclusões
  1. 76
    40
      src/components/Navbar/Navbar.jsx

+ 76
- 40
src/components/Navbar/Navbar.jsx Ver arquivo

@@ -389,10 +389,7 @@ const Navbar = () => {
389 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 395
   const findCollectionForMenuItem = (productType, item) => {
@@ -615,12 +612,13 @@ const Navbar = () => {
615 612
                           position: "absolute",
616 613
                           top: "100%",
617 614
                           left: 0,
618
-                          width: menu.groups ? (activeGroup ? 560 : 260) : 260,
615
+                          width: menu.groups ? 560 : 260,
619 616
                           height: dropdownTopOffset,
620 617
                           zIndex: 1000,
621 618
                           backgroundColor: "transparent",
622 619
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
623 620
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
621
+                          transition: "width .25s ease-in-out",
624 622
                         }}
625 623
                       />
626 624
                       {/* Submenu dropdown card: controls dropdown position, width, background, and animation */}
@@ -630,27 +628,41 @@ const Navbar = () => {
630 628
                           // Measured from this menu label to the real bottom of the navbar.
631 629
                           top: dropdownTopOffset,
632 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 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 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 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 644
                           zIndex: 1001,
642
-                          overflow: "hidden",
645
+                          overflow: "visible",
643 646
                           opacity: activeMenu === menu.label ? 1 : 0,
644 647
                           visibility: activeMenu === menu.label ? "visible" : "hidden",
645 648
                           pointerEvents: activeMenu === menu.label ? "auto" : "none",
646 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 654
                       {menu.groups ? (
651 655
                         <>
652 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 666
                             {menu.groups.map((group) => (
655 667
                               <Button
656 668
                                 key={group.label}
@@ -678,13 +690,22 @@ const Navbar = () => {
678 690
                           {/* Child submenu links: collection names shown after hovering a submenu group */}
679 691
                           {activeGroup && (
680 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 704
                               width: 300,
684 705
                               clipPath: "polygon(0 0, 100% 0, 100% 100%, 0 100%)",
685 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 709
                               "@keyframes childCardReveal": {
689 710
                                 "0%": {
690 711
                                   clipPath: "polygon(0 0, 0 0, 0 100%, 0 100%)",
@@ -694,29 +715,44 @@ const Navbar = () => {
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 756
                             </Box>
721 757
                           )}
722 758
                         </>

Carregando…
Cancelar
Salvar