Skip to content

Commit

Permalink
Merge pull request #1 from SayarB/anirudh-dev
Browse files Browse the repository at this point in the history
feat: meet the team horizontal scroll
  • Loading branch information
SayarB authored Aug 20, 2023
2 parents 5dda772 + eaf8bd4 commit 8536da3
Show file tree
Hide file tree
Showing 11 changed files with 4,120 additions and 34 deletions.
25 changes: 25 additions & 0 deletions web/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,28 @@
* {
box-sizing: border-box;
}

.horizontal-section, .horizontal-section2 {
padding: 100px 0;
background-color: pink;
}

.sticky-wrapper, .sticky-wrapper2 {
position: sticky;
top: 100px;
width: 100%;
overflow: hidden;
}

.element-wrapper, .element-wrapper2 {
position: relative;
display: flex;
}

.element {
width: 500px;
height: 400px;
background-color: purple;
margin: 0 20px 0 0;
flex-shrink: 0;
}
2 changes: 1 addition & 1 deletion web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './globals.css'
import { Unbounded } from 'next/font/google'
import localFont from "@next/font/local"
import localFont from "next/font/local"

const unbounded = Unbounded({ subsets: ['latin'], variable: '--font-unbounded' })
const neue_machina = localFont({
Expand Down
65 changes: 37 additions & 28 deletions web/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ import projects from "@/content/projects.json"
import ProjectCard from '@/components/ProjectCard'
import blogs from "@/content/blogs.json"
import BlogListItem from '@/components/BlogListItem'
import HorizontalTranslate from '../components/HorizontalTranslate'
import styled from 'styled-components'
import React from 'react'
import Level from '@/components/Level'

const CardsContainer = styled.div`
position: relative;
height: 100%;
padding: 0 0 0 100px;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
`;

export default function Home() {
const [page, setPage] = useState("home");
const mainRef = useRef<HTMLElement>(null)
Expand All @@ -32,9 +47,8 @@ export default function Home() {
useEffect(() => {
console.log(scrollY)
}, [scrollY])

return (
<main ref={mainRef} className='h-[100vh] overflow-scroll'>
<main id='main-thing' ref={mainRef} className='h-[100vh] overflow-scroll overflow-x-hidden snap-y'>
<Navbar theme={page === "home" ? 'light' : "dark"} />
<Section color="dark" page="home" setIntersecting={setIntersecting}>

Expand Down Expand Up @@ -63,7 +77,7 @@ export default function Home() {
</motion.div>
</Section>
<Section color='blue' page='fame' setIntersecting={setIntersecting}>
<div className='top-0 left-0 w-full py-[8vh] text-dark'>
<div className='top-0 left-0 w-full pt-[15vh] text-dark'>
<motion.div initial={{ scale: 1.5 }} whileInView={{ scale: 1 }} viewport={{ once: false, amount: 1 }} transition={{ duration: 1 }} className='w-[100vw] lg:w-[30vw] lg:min-w-[600px] mx-auto'>
<h1 className='font-sans text-[3rem] font-extrabold text-center tracking-wider' >WALL OF FAME</h1>
<p className='font-mono text-xl tracking-[1.8rem] ml-10 text-center'>ACHIEVEMENTS</p>
Expand All @@ -81,8 +95,9 @@ export default function Home() {
</div>
</div>
</Section>
<Section color='green' page='events' setIntersecting={setIntersecting}>
<div className='top-0 left-0 w-full py-[8vh] text-dark'>
<Level level={"04"} />
<Section snap color='green' page='events' setIntersecting={setIntersecting}>
<div className='top-0 left-0 w-full pt-[15vh] text-dark'>
<motion.div initial={{ scale: 1.5 }} whileInView={{ scale: 1 }} viewport={{ once: false, amount: 1 }} transition={{ duration: 1 }} className='w-[100vw] lg:w-[30vw] lg:min-w-[600px] mx-auto'>
<h1 className='font-sans text-[3rem] font-extrabold text-center tracking-wider'>EVENTS</h1>
</motion.div>
Expand All @@ -92,41 +107,35 @@ export default function Home() {
</div>
</div>
</Section>
<Section color='yellow' page='fame' >
<div className=' top-0 left-0 w-full py-[8vh] text-dark'>
<motion.div initial={{ scale: 1.5 }} whileInView={{ scale: 1 }} viewport={{ once: false, amount: 1 }} transition={{ duration: 1 }} className='w-[100vw] lg:w-[30vw] lg:min-w-[600px] mx-auto'>
<h1 className='font-sans text-[3rem] font-extrabold text-center tracking-wider'>MEET THE TEAM</h1>
</motion.div>
</div>
<div className='text-dark mt-[20vh] top-[50vh] -translate-y-[50%] left-[50%] '>
<div className='flex justify-start w-[90vw] mx-auto overflow-scroll'>
<Level level={"03"} />
<Section snap color='yellow' page='team' >
<HorizontalTranslate title={"Meet the Team"}>
<CardsContainer className='text-dark'>
{/* <SampleCards /> */}
{team_members.map((mem, i) => <TeamCard key={"mem" + i} title={mem.name} img={mem.img} subtitle={mem.position} />)}
</div>
</div>
</CardsContainer>
</HorizontalTranslate>
</Section>
<Level level={"02"} />
<Section color='pastel_red' page='projects' >
<div className=' top-0 left-0 w-full py-[8vh] text-dark'>
<motion.div initial={{ scale: 1.5 }} whileInView={{ scale: 1 }} viewport={{ once: false, amount: 1 }} transition={{ duration: 1 }} className='w-[100vw] lg:w-[30vw] lg:min-w-[600px] mx-auto'>
<h1 className='font-sans text-[3rem] font-extrabold text-center tracking-wider'>Projects</h1>
</motion.div>
</div>
<div className='text-dark mt-[20vh] top-[50vh] -translate-y-[50%] left-[50%] '>
<div className='flex justify-start w-[90vw] mx-auto overflow-scroll'>
<HorizontalTranslate title={"Projects"}>
<CardsContainer className='text-dark'>
{projects.map((proj, i) => <ProjectCard key={"mem" + i} {...proj} />)}
</div>
</div>
</CardsContainer>
</HorizontalTranslate>
</Section>
<Section color='blue' page='blogs' >
<Level level={"01"} />
<Section snap color='blue' page='blogs' >

<div className='flex flex-col md:flex-row p-5 h-[100vh] items-center'>
<div className='flex flex-col md:flex-row xl:p-16 p-5 pt-[11vh] h-[100vh] items-center'>
<div className='flex-1 hidden md:block'>
<Image src="/blogs.svg" alt="" width={500} height={500} layout='responsive' />
</div>
<div className='w-full p-5 text-black md:flex-1 h-fit'>
<div className='flex flex-col'>
<motion.h1 className='text-black font-sans text-[3rem] font-extrabold tracking-wider'>Blogs</motion.h1>
<div className='self-center flex-1 block m-2 max max-h-[50vh] aspect-square md:hidden'>
<Image src="/blogs.svg" alt="" width={300} height={300} layout='responsive' />
<div className='self-center flex-1 block m-2 max-h-[50vh] mb-10 md:hidden'>
<Image className='mx-auto w-2/3 h-auto' src="/blogs.svg" alt="" width={200} height={200} />
</div>

<div className='flex flex-col overflow-scroll h-fit max-h-[60vh]'>{blogs.map((blog, i) => <BlogListItem key={"blog" + i} {...blog} />)}</div>
Expand Down
9 changes: 9 additions & 0 deletions web/assets/levelsNoise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions web/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ interface Props {
}
const Card: FC<Props> = ({ children, bg }) => {
return (
<div style={{ backgroundColor: bg || "white" }} className='flex-col p-3 m-2 lg:m-4 min-w-[300px] rounded-md border-2 border-black w-[80vw] sm:max-w-[40vw] lg:max-w-[25vw] xl:max-w-[15vw] h-fit'>
<div style={{ backgroundColor: bg || "white" }} className='flex-col p-3 m-2 lg:m-4 min-w-[300px] rounded-md border-2 border-black w-[80vw] sm:max-w-[40vw] lg:max-w-[25vw] xl:max-w-[20vw] h-fit'>
{children}
</div>
);
}

export default Card;
export default Card;
91 changes: 91 additions & 0 deletions web/components/HorizontalTranslate.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React, { useState, useEffect, useRef } from 'react';
import styled from 'styled-components';
import { motion } from 'framer-motion';

const TallOuterContainer = styled.div.attrs(({ dynamicHeight }) => ({
style: { height: `${dynamicHeight}px` },
}))`
position: relative;
width: 100%;
`;

const StickyInnerContainer = styled.div`
position: sticky;
top: 0;
height: 100vh;
width: 100%;
overflow-x: hidden;
`;

const HorizontalTranslateContainer = styled.div.attrs(({ translateX }) => ({
style: { transform: `translate(${translateX}px, -50%)` },
}))`
position: absolute;
will-change: transform;
top: 50%;
`;

const calcDynamicHeight = (objectWidth) => {
const vw = window.innerWidth;
const vh = window.innerHeight;
return objectWidth - vw + vh -160;
};

const handleDynamicHeight = (ref, setDynamicHeight) => {
const objectWidth = ref.current.scrollWidth;
const dynamicHeight = calcDynamicHeight(objectWidth);
setDynamicHeight(dynamicHeight*4/3);
};

const applyScrollListener = (ref, setTranslateX) => {
const elem = document.getElementById('main-thing');
elem?.addEventListener('scroll', () => {
// console.log(ref);
const offsetTop = -ref.current?.offsetTop;
setTranslateX(offsetTop*3/4);
// console.log(offsetTop);
});
};

const HorizontalScroll = ({ title, children }) => {
const [dynamicHeight, setDynamicHeight] = useState(null);
const [translateX, setTranslateX] = useState(0);

const containerRef = useRef(null);
const objectRef = useRef(null);

const resizeHandler = () => {
handleDynamicHeight(objectRef, setDynamicHeight);
};

useEffect(() => {
handleDynamicHeight(objectRef, setDynamicHeight);
window.addEventListener('resize', resizeHandler);
applyScrollListener(containerRef, setTranslateX);
}, []);

return (
<TallOuterContainer dynamicHeight={dynamicHeight}>
<StickyInnerContainer ref={containerRef}>
<div className=" top-0 left-0 w-full pt-[15vh] text-dark">
<motion.div
initial={{ scale: 1.5 }}
whileInView={{ scale: 1 }}
viewport={{ once: false, amount: 1 }}
transition={{ duration: 1 }}
className="w-[100vw] lg:w-[30vw] lg:min-w-[600px] mx-auto"
>
<h1 className="uppercase font-sans text-[3rem] font-extrabold text-center tracking-wider">
{title}
</h1>
</motion.div>
</div>
<HorizontalTranslateContainer translateX={translateX} ref={objectRef}>
{children}
</HorizontalTranslateContainer>
</StickyInnerContainer>
</TallOuterContainer>
);
};

export default HorizontalScroll;
18 changes: 18 additions & 0 deletions web/components/Level.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, {FC} from 'react'
import levelsNoise from '../assets/levelsNoise.svg'
import Image from 'next/image'

interface Props {
level: "01" | "02" | "03" | "04"
}

const Level: FC<Props> = ({ level }) => {
return (
<div className='relative'>
<Image className='w-full h-full' src={levelsNoise} alt='' />
<h1 className='uppercase absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-stone-500 font-extrabold text-center xl:text-7xl lg:text-6xl text-5xl'>Level {level}</h1>
</div>
)
}

export default Level
7 changes: 4 additions & 3 deletions web/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ interface Props {
page?: string
setIntersecting?: (page: string) => void
propRef?: RefObject<HTMLElement>
snap?: boolean
}

const Section: FC<Props> = ({ children, color, page, setIntersecting }) => {
const Section: FC<Props> = ({ children, color, page, setIntersecting, snap }) => {
const ref = useRef<HTMLElement>(null)


Expand Down Expand Up @@ -40,10 +41,10 @@ const Section: FC<Props> = ({ children, color, page, setIntersecting }) => {
}, [ref.current])

return (
<section className={`relative w-[100vw] text-white min-h-[100vh] h-fit snap-y`} style={{ backgroundColor: fullConfig?.theme?.colors![color as keyof typeof fullConfig.theme.colors] as string || "dark" }} ref={ref} >
<section className={`relative w-[100vw] text-white min-h-[100vh] max-h-fit snap-y ${snap ? "" :""}`} style={{ backgroundColor: fullConfig?.theme?.colors![color as keyof typeof fullConfig.theme.colors] as string || "dark" }} ref={ref} >
{children}
</section >
);
}

export default Section;
export default Section;
35 changes: 35 additions & 0 deletions web/content/team_members.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@
"position": "Community Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
"img": "/vishesh.jpg"
},
{
"name": "Yajat",
"position": "Tech Lead",
Expand Down
3 changes: 3 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"postcss": "8.4.24",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-horizontal-vertical": "^1.0.4",
"react-scroll-parallax": "^3.4.2",
"react-scroll-percentage": "^4.3.0",
"styled-components": "^6.0.7",
"tailwindcss": "3.3.2",
"typescript": "5.1.6"
}
Expand Down
Loading

0 comments on commit 8536da3

Please sign in to comment.