Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DangTinh422003 committed Nov 11, 2024
1 parent fe5452d commit 3ca2ea7
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 10 deletions.
12 changes: 10 additions & 2 deletions src/components/Awards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ const Awards = () => {
xl:grid-cols-4
`}
>
<div className="flex flex-col justify-center px-4">
<div
className={`
flex flex-col justify-center px-4
md:col-span-2
xl:col-span-1
`}
>
<p
className={`
font-bebas-neue text-4xl font-medium
Expand All @@ -95,7 +103,7 @@ const Awards = () => {
>
AWARDS
</p>
<p>
<p className="pr-10">
Our commitment to innovation and quality has brought Weminal
notable awards in the Web3 and technology community, including
over 10 competitions, both domestic and international with a total
Expand Down
5 changes: 1 addition & 4 deletions src/components/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ import { Card } from '@/components/ui/focus-cards'
import { SECTION_IDS } from '@/constants'
import { supabase } from '@/lib/supabase/client'

import { AnimatedTestimonials } from './ui/animated-testimonials'

const swiperConfig: SwiperProps = {
modules: [Autoplay],
spaceBetween: 2,
slidesPerView: 1.2,
loop: true,
navigation: false,
autoplay: {
delay: 1400,
delay: 0,
disableOnInteraction: false,
pauseOnMouseEnter: true,
},

breakpoints: {
768: {
slidesPerView: 2.2,
Expand Down
37 changes: 33 additions & 4 deletions src/components/Projects.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use client'
import { Loader } from 'lucide-react'
import React, { useEffect } from 'react'

import { HeroParallax } from '@/components/ui/hero-parallax'
import { SECTION_IDS } from '@/constants'
import { supabase } from '@/lib/supabase/client'

interface Project {
import { ParallaxScroll } from './ui/parallax-scroll'

export interface Project {
title: string
link: string
thumbnail: string
Expand All @@ -26,8 +28,35 @@ const Projects = () => {
fetchProjects()
}, [])
return (
<div id={SECTION_IDS.PROJECTS}>
<HeroParallax products={projects} />
<div
id={SECTION_IDS.PROJECTS}
className={`
py-10
lg:py-40
md:py-20
`}
>
<h2
className={`
py-10 text-center font-bebas-neue text-4xl font-medium
lg:text-8xl
md:py-20 md:text-6xl
`}
>
our projects
</h2>
{isLoading ?
<div className="flex h-96 items-center justify-center">
<Loader className="animate-spin" size={30} />
</div>
: <div className="mx-auto max-w-7xl">
<ParallaxScroll projects={projects} />
</div>
}
</div>
)
}
Expand Down
115 changes: 115 additions & 0 deletions src/components/ui/parallax-scroll-2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"use client";
import { motion,useScroll, useTransform } from "framer-motion";
import Image from "next/image";
import { useRef } from "react";

import { cn } from "@/lib/utils";

export const ParallaxScrollSecond = ({
images,
className,
}: {
images: string[];
className?: string;
}) => {
const gridRef = useRef<any>(null);
const { scrollYProgress } = useScroll({
container: gridRef, // remove this if your container is not fixed height
offset: ["start start", "end start"], // remove this if your container is not fixed height
});

const translateYFirst = useTransform(scrollYProgress, [0, 1], [0, -200]);
const translateXFirst = useTransform(scrollYProgress, [0, 1], [0, -200]);
const rotateXFirst = useTransform(scrollYProgress, [0, 1], [0, -20]);

const translateYThird = useTransform(scrollYProgress, [0, 1], [0, -200]);
const translateXThird = useTransform(scrollYProgress, [0, 1], [0, 200]);
const rotateXThird = useTransform(scrollYProgress, [0, 1], [0, 20]);

const third = Math.ceil(images.length / 3);

const firstPart = images.slice(0, third);
const secondPart = images.slice(third, 2 * third);
const thirdPart = images.slice(2 * third);

return (
<div
className={cn("h-[40rem] w-full items-start overflow-y-auto", className)}
ref={gridRef}
>
<div
className={`
mx-auto grid max-w-5xl grid-cols-1 items-start gap-10 px-10 py-40
lg:grid-cols-3
md:grid-cols-2
`}
ref={gridRef}
>
<div className="grid gap-10">
{firstPart.map((el, idx) => (
<motion.div
style={{
y: translateYFirst,
x: translateXFirst,
rotateZ: rotateXFirst,
}} // Apply the translateY motion value here
key={"grid-1" + idx}
>
<Image
src={el}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
<div className="grid gap-10">
{secondPart.map((el, idx) => (
<motion.div key={"grid-2" + idx}>
<Image
src={el}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
<div className="grid gap-10">
{thirdPart.map((el, idx) => (
<motion.div
style={{
y: translateYThird,
x: translateXThird,
rotateZ: rotateXThird,
}}
key={"grid-3" + idx}
>
<Image
src={el}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
</div>
</div>
);
};
130 changes: 130 additions & 0 deletions src/components/ui/parallax-scroll.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
'use client'
import { motion, useScroll, useTransform } from 'framer-motion'
import Image from 'next/image'
import { useRef } from 'react'

import { cn } from '@/lib/utils'

import { type Project } from '../Projects'

export const ParallaxScroll = ({
projects,
className,
}: {
projects: Project[]
className?: string
}) => {
const gridRef = useRef<any>(null)
const { scrollYProgress } = useScroll({
container: gridRef,
offset: ['start start', 'end start'],
})

const translateFirst = useTransform(scrollYProgress, [0, 1], [0, -200])
const translateSecond = useTransform(scrollYProgress, [0, 1], [0, 200])
const translateThird = useTransform(scrollYProgress, [0, 1], [0, -200])

const third = Math.ceil(projects.length / 3)

const firstPart = projects.slice(0, third)
const secondPart = projects.slice(third, 2 * third)
const thirdPart = projects.slice(2 * third)

return (
<div
className={cn(
`
h-auto w-full items-start overflow-y-auto
lg:h-[70vh]
`,
className,
)}
ref={gridRef}
>
<div
className={`
grid grid-cols-1 gap-8
lg:hidden
md:grid-cols-2
`}
>
{projects.map((el, idx) => (
<div key={idx} className="relative h-80 w-full">
<Image
src={el.thumbnail}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover object-left-top
!p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</div>
))}
</div>
<div
className={`
mx-auto hidden grid-cols-1 items-start gap-10 px-10
lg:grid lg:grid-cols-3
md:grid-cols-2
`}
ref={gridRef}
>
<div className="grid gap-10">
{firstPart.map((el, idx) => (
<motion.div style={{ y: translateFirst }} key={'grid-1' + idx}>
<Image
src={el.thumbnail}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
<div className="grid gap-10">
{secondPart.map((el, idx) => (
<motion.div style={{ y: translateSecond }} key={'grid-2' + idx}>
<Image
src={el.thumbnail}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
<div className="grid gap-10">
{thirdPart.map((el, idx) => (
<motion.div style={{ y: translateThird }} key={'grid-3' + idx}>
<Image
src={el.thumbnail}
className={`
!m-0 h-80 w-full gap-10 rounded-lg object-cover
object-left-top !p-0
`}
height="400"
width="400"
alt="thumbnail"
/>
</motion.div>
))}
</div>
</div>
</div>
)
}

0 comments on commit 3ca2ea7

Please sign in to comment.