Skip to content

Commit 728bd82

Browse files
committed
sponsors animation
1 parent 5658cfc commit 728bd82

File tree

2 files changed

+82
-36
lines changed

2 files changed

+82
-36
lines changed

src/app/page.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Sponsors from "@/components/sponsors";
1212
const sponsorsData = [
1313
{ imagePath: "/sponsors/open-ai.png", link: "https://openai.com" },
1414
{ imagePath: "/sponsors/azure.png", link: "https://azure.microsoft.com" },
15-
{ imagePath: "/sponsors/google.png", link: "https://google.com" },
1615
{
1716
imagePath: "/sponsors/replit.png",
1817
link: "https://replit.com",
@@ -27,20 +26,19 @@ const sponsorsData = [
2726
imagePath: "/sponsors/wolfram.png",
2827
link: "https://wolfram.com",
2928
},
30-
29+
3130
{ imagePath: "/sponsors/axure.svg", link: "https://axure.com" },
32-
31+
3332
{
3433
imagePath: "/sponsors/interview-cake.jpg",
3534
link: "https://interviewcake.com",
3635
},
37-
36+
3837
{
3938
imagePath: "/sponsors/aops.png",
4039
link: "https://artofproblemsolving.com",
4140
},
42-
43-
41+
4442
{ imagePath: "/sponsors/cocalc.png", link: "https://cocalc.com" },
4543
{
4644
imagePath: "/sponsors/taskade.png",
@@ -61,11 +59,16 @@ export default function Home() {
6159
<Box my={["20px", "130px"]} px={5}>
6260
<Popup />
6361
<HeroHeader />
64-
<Heading fontSize="4xl" textAlign="center" color="black" mt="70px">
62+
<Heading
63+
fontSize={["3xl", "4xl"]}
64+
textAlign="center"
65+
color="black"
66+
mt="70px"
67+
>
6568
Partners & Sponsors
6669
</Heading>
6770
<Heading
68-
fontSize="xl"
71+
fontSize={["md", "xl"]}
6972
textAlign="center"
7073
color="blackAlpha.800"
7174
fontWeight="medium"

src/components/sponsors.jsx

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,89 @@
11
import { Box, Flex, Link } from "@chakra-ui/react";
2-
2+
import React, { useRef, useEffect } from "react";
3+
import { motion } from "framer-motion";
34
const SponsorCard = ({ imagePath, link }) => {
45
return (
56
<Link href={link} isExternal>
6-
<Box
7-
mx={2}
8-
mb={4}
9-
borderRadius="md"
10-
width="140px"
11-
height="100px"
12-
display="flex"
13-
alignItems="center"
7+
<Box
8+
mx={4}
9+
mb={4}
10+
borderRadius="md"
11+
width="140px"
12+
height="100px"
13+
display="flex"
14+
alignItems="center"
1415
justifyContent="center"
1516
overflow="hidden"
16-
_hover={{ transform: 'scale(1.05)' }}
17+
_hover={{ transform: "scale(1.05)" }}
1718
transition="transform 0.2s ease-in-out"
1819
>
1920
<img src={imagePath} alt="Sponsor" width="100%" />
2021
</Box>
2122
</Link>
2223
);
23-
}
24-
24+
};
25+
const TranslateWrapper = ({ children, reverse }) => {
26+
return (
27+
<>
28+
<motion.div
29+
initial={{ translateX: reverse ? "-100%" : "0%" }}
30+
animate={{ translateX: reverse ? "0%" : "-100%" }}
31+
transition={{ duration: 20, repeat: Infinity, ease: "linear" }}
32+
>
33+
{children}
34+
35+
</motion.div>
36+
</>
37+
);
38+
};
2539
const Sponsors = ({ sponsors }) => {
26-
const halfLength = Math.ceil(sponsors.length / 2);
27-
const firstRowSponsors = sponsors.slice(0, halfLength);
28-
const secondRowSponsors = sponsors.slice(halfLength);
29-
3040
return (
31-
<Box mt="2rem" w="100%" >
32-
<Flex gap="10px" direction="row" justifyContent="center" wrap="wrap" mb={4}>
33-
{firstRowSponsors.map((sponsor, index) => (
34-
<SponsorCard key={index} imagePath={sponsor.imagePath} link={sponsor.link} />
35-
))}
36-
</Flex>
37-
<Flex gap="10px" direction="row" justifyContent="center" wrap="wrap">
38-
{secondRowSponsors.map((sponsor, index) => (
39-
<SponsorCard key={index} imagePath={sponsor.imagePath} link={sponsor.link} />
40-
))}
41-
</Flex>
41+
<Box
42+
mx="auto"
43+
mt="2rem"
44+
w={["100%", "80%"]}
45+
overflow="hidden"
46+
position="relative"
47+
sx={{
48+
"::before": {
49+
content: '""',
50+
position: "absolute",
51+
top: 0,
52+
left: 0,
53+
bottom: 0,
54+
width: ["70px", "100px", "200px", "250px"],
55+
background:
56+
"linear-gradient(to right, #FCFCFC, rgba(255, 255, 255, 0))",
57+
zIndex: 2,
58+
pointerEvents: "none",
59+
},
60+
"::after": {
61+
content: '""',
62+
position: "absolute",
63+
top: 0,
64+
right: 0,
65+
bottom: 0,
66+
width: ["70px", "100px", "200px", "250px"],
67+
background:
68+
"linear-gradient(to left, #FCFCFC, rgba(255, 255, 255, 0))",
69+
zIndex: 2,
70+
pointerEvents: "none",
71+
},
72+
}}
73+
>
74+
<TranslateWrapper>
75+
<Flex direction="row">
76+
{sponsors.map((sponsor, index) => (
77+
<SponsorCard
78+
key={index}
79+
imagePath={sponsor.imagePath}
80+
link={sponsor.link}
81+
/>
82+
))}
83+
</Flex>
84+
</TranslateWrapper>
4285
</Box>
4386
);
44-
}
87+
};
4588

4689
export default Sponsors;

0 commit comments

Comments
 (0)