Skip to content

Commit bd55f3d

Browse files
committed
refactor(frontend): improve accordion transition and mobile view
1 parent 96cb5bc commit bd55f3d

File tree

6 files changed

+42
-34
lines changed

6 files changed

+42
-34
lines changed

frontend/src/components/IntegrateSection/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ const IntegrateSection: React.FC = async () => {
2323
<p className="text-base text-secondary-text lg:mb-4 lg:text-lg">
2424
{integrateData.description}
2525
</p>
26-
<AppsDropdownContent appsSection={integrateData.appsSection} />
26+
<AppsDropdownContent
27+
appsSection={integrateData.appsSection}
28+
className="pt-8 lg:pt-16"
29+
/>
2730
<LearnMore
2831
background={integrateData.getInTouchSection.background}
2932
title={integrateData.header}
3033
button={integrateData.arrowLink}
31-
className="!mt-16 lg:!mt-4"
34+
className="!mt-12 lg:!mt-16"
3235
/>
3336
<ExternalLink
3437
className="mt-12 flex-wrap justify-center text-center lg:mt-16"

frontend/src/components/Navbar/AppsDropdownContent/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import Card from "./Card";
88
interface AppsDropdownContentProps {
99
appsSection: AppsSection;
1010
closeFn?: () => void;
11+
className?: string;
1112
}
1213

1314
const AppsDropdownContent: React.FC<AppsDropdownContentProps> = ({
1415
appsSection,
1516
closeFn,
17+
className,
1618
}) => (
17-
<div className="mx-auto py-6 lg:max-w-[1172px] lg:py-12">
19+
<div className={clsx(className, "mx-auto lg:max-w-[1172px]")}>
1820
<div
1921
className={clsx(
2022
"grid w-full grid-cols-1 gap-3 bg-background-2 lg:grid-flow-col",

frontend/src/components/Navbar/DesktopNavigation.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,27 @@ const DesktopNavigation: React.FC<DesktopNavigationProps> = ({
8383
{openDropdownIndex === index && navLink.is_dropdown ? (
8484
<motion.div
8585
className={clsx(
86-
"fixed inset-0 top-20 z-40 h-dvh bg-black/50",
86+
"fixed inset-0 top-20 z-40 h-[calc(100dvh-5rem)]",
87+
"bg-black/50",
8788
)}
8889
initial={{ opacity: 0 }}
8990
animate={{ opacity: 1 }}
9091
exit={{ opacity: 0 }}
9192
onClick={() => setOpenDropdownIndex(null)}
9293
>
9394
<motion.div
94-
className="absolute top-0 w-full bg-background-2"
95+
className={clsx(
96+
"absolute top-0 max-h-full w-full overflow-y-auto",
97+
"bg-background-2",
98+
)}
9599
initial={{ translateY: "-5%" }}
96100
animate={{ translateY: 0 }}
97101
exit={{ translateY: "-5%" }}
98102
onClick={(e) => e.stopPropagation()}
99103
>
100104
{navLink?.title === "Apps" ? (
101105
<AppsDropdownContent
106+
className="px-6 py-12"
102107
{...{ appsSection }}
103108
closeFn={() => setOpenDropdownIndex(null)}
104109
/>

frontend/src/components/Navbar/MobileMenu.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useState } from "react";
44

55
import clsx from "clsx";
6+
import { motion, AnimatePresence } from "motion/react";
67
import Image from "next/image";
78

89
import DownArrowIcon from "@/assets/svgs/icons/down-arrow.svg";
@@ -66,6 +67,7 @@ const MobileMenu: React.FC<IMobileMenu> = ({
6667
"block text-white",
6768
pathname === `/${navLink.path_name}` && "font-bold",
6869
)}
70+
onClick={closeFn}
6971
>
7072
{navLink.title}
7173
</CustomLink>
@@ -86,21 +88,27 @@ const MobileMenu: React.FC<IMobileMenu> = ({
8688
height={12}
8789
/>
8890
</button>
89-
<div
90-
className={clsx(
91-
"transition-accordionHeight h-auto overflow-y-auto",
92-
"pl-2 pr-4",
93-
openDropdownIndex === index && "accordionOpen",
94-
)}
95-
>
96-
{navLink?.title === "Apps" ? (
97-
<AppsDropdownContent {...{ appsSection, closeFn }} />
98-
) : navLink?.title === "Resources" ? (
99-
<ResourcesDropdownContent
100-
{...{ resourceSections, socials, closeFn }}
101-
/>
91+
<AnimatePresence>
92+
{openDropdownIndex === index ? (
93+
<motion.div
94+
initial={{ height: 0 }}
95+
animate={{ height: "auto" }}
96+
exit={{ height: 0 }}
97+
className="mt-2 max-h-[30dvh] overflow-y-scroll pl-2 pr-4"
98+
>
99+
{navLink?.title === "Apps" ? (
100+
<AppsDropdownContent
101+
{...{ appsSection, closeFn }}
102+
className="mt-2"
103+
/>
104+
) : navLink?.title === "Resources" ? (
105+
<ResourcesDropdownContent
106+
{...{ resourceSections, socials, closeFn }}
107+
/>
108+
) : null}
109+
</motion.div>
102110
) : null}
103-
</div>
111+
</AnimatePresence>
104112
</>
105113
)}
106114
</div>

frontend/src/components/Navbar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ const Navbar: React.FC<INavbar> = ({ navbarData }) => {
7777
<AnimatePresence>
7878
{menuOpen ? (
7979
<motion.div
80-
className={clsx("fixed inset-0 top-20 z-40 h-dvh bg-black/50")}
80+
className={clsx(
81+
"fixed inset-0 top-20 z-40 h-[calc(100dvh-5rem)] bg-black/50",
82+
)}
8183
initial={{ opacity: 0 }}
8284
animate={{ opacity: 1 }}
8385
exit={{ opacity: 0 }}
8486
onClick={() => toggleMenuOpen(false)}
8587
>
8688
<motion.div
87-
className="absolute top-0"
89+
className="absolute bottom-0 top-0"
8890
initial={{ right: "-100%" }}
8991
animate={{ right: 0 }}
9092
exit={{ right: "-100%" }}
@@ -99,6 +101,7 @@ const Navbar: React.FC<INavbar> = ({ navbarData }) => {
99101
socials,
100102
navbarButton,
101103
}}
104+
className="h-full overflow-y-auto md:h-auto"
102105
closeFn={() => toggleMenuOpen(false)}
103106
/>
104107
</motion.div>

frontend/src/styles/globals.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ body {
6060
}
6161
}
6262

63-
.transition-accordionHeight {
64-
max-height: 0;
65-
transition:
66-
max-height 0.3s ease-out,
67-
opacity 0.3s ease-out;
68-
opacity: 0;
69-
}
70-
71-
.accordionOpen {
72-
max-height: 332px;
73-
opacity: 1;
74-
}
75-
7663
.border-gradient-purple-blue {
7764
position: relative;
7865
border-radius: 9999px;

0 commit comments

Comments
 (0)