import { AnimatePresence } from 'framer-motion' import { Pencil, Users, Users2 } from 'lucide-react' import Link from 'next/link' import React, { useEffect, useState } from 'react' import { Swiper, SwiperSlide } from 'swiper/react' import { cn, LogoLoader } from 'ui' import RepoCard from './RepoCard' interface TabProps { label: string isActive: boolean icon?: string onClick: VoidFunction } const Tab = ({ isActive, label, icon, onClick }: TabProps) => ( ) export interface RepoTab { label: string icon?: string repos?: string[] } interface Props { tabs: RepoTab[] } enum SWIPER_STATE { START = 'START', MIDDLE = 'MIDDLE', END = 'END', } const Repos = ({ tabs }: Props) => { const [repos, setRepos] = useState(null) const [activeTab, setActiveTab] = useState(0) const [apiSwiper, setApiSwiper] = useState(undefined) const [swiperState, setSwiperState] = useState(SWIPER_STATE.START) useEffect(() => { async function fetchOctoData() { const { Octokit } = await import('@octokit/core') const octokit = new Octokit() const res = await octokit.request('GET /orgs/{org}/repos', { org: 'supabase', type: 'public', per_page: 200, page: 1, }) setRepos(res.data) } fetchOctoData() }, []) useEffect(() => { if (!apiSwiper) return // @ts-ignore apiSwiper.slideTo(activeTab) }, [activeTab]) const handleTabClick = (tabIndex: number) => { setActiveTab(tabIndex) } const activeTabRepos = repos ? repos ?.filter((repo) => tabs[activeTab].repos?.includes(repo.name)) ?.sort((a, b) => (a.stargazers_count < b.stargazers_count ? 1 : -1)) : [] return (
How to contribute Code of Conduct SupaSquad Community Content Program
setSwiperState( slider.isEnd ? SWIPER_STATE.END : slider.isBeginning ? SWIPER_STATE.START : SWIPER_STATE.MIDDLE ) } className="relative flex md:hidden! justify-center max-w-full w-full overflow-hidden items-center rounded-full bg-surface-100 p-2" >
{tabs.map((tab, index) => ( handleTabClick(index)} /> ))}
{tabs.map((tab, index) => ( handleTabClick(index)} /> ))}
{repos === null ? (
) : ( activeTabRepos?.map((repo: any, i: number) => ( )) )}
) } const GitHubIcon = () => ( ) export default Repos