Skip to content

Commit b653749

Browse files
committed
Add page component transitions
1 parent c3fea5d commit b653749

7 files changed

Lines changed: 125 additions & 37 deletions

File tree

package-lock.json

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@heroicons/react": "^2.2.0",
15+
"framer-motion": "^12.35.0",
1516
"gsap": "^3.14.2",
1617
"lucide-react": "^0.564.0",
1718
"react": "^19.2.0",

src/components/AppLayout.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
/* Layout that each page will follow */
21
import '../css/app-layout.css';
32
import { Outlet } from 'react-router-dom';
4-
5-
import Navbar from './navbar/Navbar.tsx';
3+
import Navbar from './navbar/Navbar';
64

75
export default function AppLayout() {
8-
return (
9-
<div className="main-app-container">
10-
<Navbar />
11-
<div className="app-content">
12-
<Outlet />
13-
</div>
14-
</div>
15-
);
16-
}
6+
7+
return (
8+
<div className="main-app-container">
9+
<Navbar />
10+
<div className="app-content">
11+
<Outlet />
12+
</div>
13+
</div>
14+
);
15+
}

src/components/Carousel.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ type CarouselProps = {
88
export default function Carousel({ type }: CarouselProps) {
99
return (
1010
<>
11-
<div>
12-
<h2 className="carousel-title">{type}</h2>
13-
<div className="carousel">
14-
<Organization
15-
title="Math Club"
16-
desc="The RPI Math Faculty approved and Union affiliated math club!"
17-
/>
18-
<Organization
19-
title="Math Club"
20-
desc="The RPI Math Faculty approved and Union affiliated math club!"
21-
/>
22-
<Organization
23-
title="Math Club"
24-
desc="The RPI Math Faculty approved and Union affiliated math club!"
25-
/>
11+
<div className="carousel-container">
12+
<div>
13+
<span className="carousel-title">{type}</span>
14+
<div className="carousel">
15+
<Organization
16+
title="Math Club"
17+
desc="The RPI Math Faculty approved and Union affiliated math club!"
18+
/>
19+
<Organization
20+
title="Math Club"
21+
desc="The RPI Math Faculty approved and Union affiliated math club!"
22+
/>
23+
<Organization
24+
title="Math Club"
25+
desc="The RPI Math Faculty approved and Union affiliated math club!"
26+
/>
27+
</div>
2628
</div>
2729
</div>
2830
</>
Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
import { NavLink } from 'react-router-dom';
1+
import { NavLink, useNavigate } from 'react-router-dom';
2+
import type { MouseEvent } from 'react';
23

34
type NavbarLinkProps = {
4-
label: string;
5-
nav: string;
5+
label: string;
6+
nav: string;
67
};
78

89
export default function NavbarLink({ label, nav }: NavbarLinkProps) {
9-
return (
10-
<NavLink to={nav} className={({ isActive }) => `navlink ${isActive ? 'active-navlink' : ''}`}>
11-
{label}
12-
</NavLink>
13-
);
14-
}
10+
const navigate = useNavigate();
11+
12+
const handleClick = (e: MouseEvent<HTMLAnchorElement>) => {
13+
e.preventDefault();
14+
15+
const content = document.querySelector('.app-content');
16+
if (!content) {
17+
navigate(nav);
18+
return;
19+
}
20+
21+
content.classList.add('page-transition');
22+
setTimeout(() => { navigate(nav); }, 300);
23+
setTimeout(() => { content.classList.remove('page-transition'); }, 400);
24+
};
25+
26+
return (
27+
<NavLink
28+
to={nav}
29+
onClick={handleClick}
30+
className={({ isActive }) =>
31+
`navlink ${isActive ? 'active-navlink' : ''}`
32+
}
33+
>
34+
{label}
35+
</NavLink>
36+
);
37+
}

src/css/app-layout.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88

99
.app-content {
1010
padding: 3rem;
11-
width: 75%;
11+
width: 100%;
12+
position: relative;
13+
overflow: hidden;
14+
transition: transform 0.4s ease, opacity 0.4s ease;
1215
}
16+
17+
.app-content.page-transition {
18+
transform: scale(0.95);
19+
opacity: 0.10;
20+
}

src/css/carousel.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
gap: 4rem;
55
}
66

7+
.carousel-container {
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
}
12+
713
.carousel {
814
width: 100%;
915
background: var(--carousel-bg);

0 commit comments

Comments
 (0)