Skip to content

Commit

Permalink
Fixed gitignore and club carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaanthenerd committed Oct 1, 2024
1 parent 25b096b commit e926b9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/node_modules
/.pnp
.pnp.js
pnpm-lock.yaml
yarn.lock

# testing
/coverage
Expand Down
32 changes: 19 additions & 13 deletions src/components/OrgDirectoryCarousel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Key, type FC } from 'react';
import { Key, useRef, type FC } from 'react';
import React, { useEffect, useState } from 'react';
import DirectoryOrgs from './DirectoryOrgs';
import { Session } from 'next-auth';
Expand All @@ -14,13 +14,19 @@ type Props = {

const OrgDirectoryCarousel: FC<Props> = ({ clubs, session }) => {
const [currentIndex, setCurrentIndex] = useState(0);
const clubCard = useRef(null);
const clubCardElement: HTMLDivElement = clubCard.current!;
let clubCardWidth = 40;
if (clubCardElement!) {
clubCardWidth = clubCardElement.scrollWidth / 9.05;
}

function prev() {
setCurrentIndex(currentIndex - 1)
setCurrentIndex(currentIndex - 1);
}

function next() {
setCurrentIndex(currentIndex + 1)
setCurrentIndex(currentIndex + 1);
}

if (session) {
Expand All @@ -42,16 +48,16 @@ const OrgDirectoryCarousel: FC<Props> = ({ clubs, session }) => {
}
<div className="carousel-wrapper flex w-full relative">
<div className="carousel-content-wrapper overflow-hidden w-full h-full">
<div
className="carousel-content flex w-full flex-shrink-0 flex-grow transition ease-in-out duration-500"
style={{ transform: `translateX(-${currentIndex * 40.25}%)` }}
>
{clubs.map((club) => (
<div className="px-8 py-8">
<DirectoryOrgs key={club.id} club={club} session={session} priority />
</div>
))}
</div>
<div
className="carousel-content flex w-full flex-shrink-0 flex-grow transition ease-in-out duration-500"
style={{ transform: `translateX(-${currentIndex * clubCardWidth}%)` }}
>
{clubs.map((club) => (
<div className="pr-8 py-8" ref={clubCard}>
<DirectoryOrgs key={club.id} club={club} session={session} priority />
</div>
))}
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit e926b9e

Please sign in to comment.