|
1 | | -import React from 'react'; |
| 1 | +import React, { useState, useEffect } from 'react'; |
2 | 2 | import { motion } from 'framer-motion'; |
3 | | -import { Github, UserRound, Users, UsersRound, PersonStanding } from 'lucide-react'; |
| 3 | +import { Github, UserRound } from 'lucide-react'; |
4 | 4 |
|
5 | | -const contributors = [ |
6 | | - { |
7 | | - name: 'Tola Leng', |
8 | | - role: 'Creator and Core Maintainer', |
9 | | - avatar: '/reamstack-uploads/a0f9d871-f20c-4743-ab95-982f55e0b84d.png', |
10 | | - github: 'https://github.com/tolalengoss' |
11 | | - }, |
12 | | - { |
13 | | - name: 'You are the Next to Be 1', |
14 | | - role: 'Maintainer', |
15 | | - icon: UserRound, |
16 | | - github: '#' |
17 | | - }, |
18 | | - { |
19 | | - name: 'You are the Next to Be 2', |
20 | | - role: 'Maintainer', |
21 | | - icon: Users, |
22 | | - github: '#' |
23 | | - }, |
24 | | - { |
25 | | - name: 'You are the Next to Be 3', |
26 | | - role: 'Maintainer', |
27 | | - icon: PersonStanding, |
28 | | - github: '#' |
29 | | - }, |
30 | | - { |
31 | | - name: 'You are the Next to Be 4', |
32 | | - role: 'Contributor', |
33 | | - icon: UsersRound, |
34 | | - github: '#' |
35 | | - }, |
36 | | - { |
37 | | - name: 'You are the Next to Be 5', |
38 | | - role: 'Contributor', |
39 | | - icon: UserRound, |
40 | | - github: '#' |
41 | | - }, |
42 | | -]; |
| 5 | +interface Contributor { |
| 6 | + login: string; |
| 7 | + avatar_url: string; |
| 8 | + html_url: string; |
| 9 | + contributions: number; |
| 10 | +} |
43 | 11 |
|
44 | 12 | const Contributors = () => { |
| 13 | + const [contributors, setContributors] = useState<Contributor[]>([]); |
| 14 | + const [loading, setLoading] = useState(true); |
| 15 | + |
| 16 | + useEffect(() => { |
| 17 | + const fetchContributors = async () => { |
| 18 | + try { |
| 19 | + const response = await fetch('https://api.github.com/repos/operacle/checkcle/contributors'); |
| 20 | + const data = await response.json(); |
| 21 | + setContributors(data.slice(0, 10)); // Show top 6 contributors |
| 22 | + } catch (error) { |
| 23 | + console.error('Error fetching contributors:', error); |
| 24 | + |
| 25 | + setContributors([]); |
| 26 | + } finally { |
| 27 | + setLoading(false); |
| 28 | + } |
| 29 | + }; |
| 30 | + |
| 31 | + fetchContributors(); |
| 32 | + }, []); |
| 33 | + |
| 34 | + if (loading) { |
| 35 | + return ( |
| 36 | + <section className="py-20 bg-black"> |
| 37 | + <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
| 38 | + <div className="text-center"> |
| 39 | + <h2 className="text-4xl font-bold text-white mb-4">Contributors</h2> |
| 40 | + <p className="text-xl text-gray-400">Loading contributors...</p> |
| 41 | + </div> |
| 42 | + </div> |
| 43 | + </section> |
| 44 | + ); |
| 45 | + } |
| 46 | + |
45 | 47 | return ( |
46 | | - <section className="py-20 bg-[#020617]"> |
| 48 | + <section className="py-20 bg-black"> |
47 | 49 | <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
48 | 50 | <div className="text-center mb-16"> |
49 | 51 | <h2 className="text-4xl font-bold text-white mb-4">Contributors</h2> |
50 | | - <p className="text-xl text-gray-400">Meet the amazing people behind ReamStack</p> |
| 52 | + <p className="text-xl text-gray-400">Meet our maintianers and contributors</p> |
51 | 53 | </div> |
52 | 54 |
|
53 | | - <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"> |
54 | | - {contributors.map((contributor, index) => ( |
55 | | - <motion.div |
56 | | - key={index} |
57 | | - initial={{ opacity: 0, x: -20 }} |
58 | | - whileInView={{ opacity: 1, x: 0 }} |
59 | | - transition={{ duration: 0.5, delay: index * 0.1 }} |
60 | | - className="flex items-center p-6 bg-white/5 rounded-lg hover:bg-white/10 transition-colors" |
61 | | - > |
62 | | - {contributor.avatar ? ( |
| 55 | + {contributors.length > 0 ? ( |
| 56 | + <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8"> |
| 57 | + {contributors.map((contributor, index) => ( |
| 58 | + <motion.div |
| 59 | + key={contributor.login} |
| 60 | + initial={{ opacity: 0, x: -20 }} |
| 61 | + whileInView={{ opacity: 1, x: 0 }} |
| 62 | + transition={{ duration: 0.5, delay: index * 0.1 }} |
| 63 | + className="flex items-center p-6 bg-white/5 rounded-lg hover:bg-white/10 transition-colors" |
| 64 | + > |
63 | 65 | <img |
64 | | - src={contributor.avatar} |
65 | | - alt={contributor.name} |
| 66 | + src={contributor.avatar_url} |
| 67 | + alt={contributor.login} |
66 | 68 | className="h-16 w-16 rounded-full mr-4" |
67 | 69 | /> |
68 | | - ) : ( |
69 | | - <div className="h-16 w-16 rounded-full mr-4 bg-gray-700 flex items-center justify-center"> |
70 | | - {contributor.icon && <contributor.icon className="h-8 w-8 text-gray-300" />} |
| 70 | + <div className="flex-1"> |
| 71 | + <h3 className="text-white font-medium">{contributor.login}</h3> |
| 72 | + <p className="text-gray-400">{contributor.contributions} contributions</p> |
71 | 73 | </div> |
72 | | - )} |
73 | | - <div className="flex-1"> |
74 | | - <h3 className="text-white font-medium">{contributor.name}</h3> |
75 | | - <p className="text-gray-400">{contributor.role}</p> |
76 | | - </div> |
77 | | - <a |
78 | | - href={contributor.github} |
79 | | - className="text-gray-400 hover:text-white transition-colors" |
80 | | - target="_blank" |
81 | | - rel="noopener noreferrer" |
82 | | - > |
83 | | - <Github className="h-6 w-6" /> |
84 | | - </a> |
85 | | - </motion.div> |
86 | | - ))} |
87 | | - </div> |
| 74 | + <a |
| 75 | + href={contributor.html_url} |
| 76 | + className="text-gray-400 hover:text-white transition-colors" |
| 77 | + target="_blank" |
| 78 | + rel="noopener noreferrer" |
| 79 | + > |
| 80 | + <Github className="h-6 w-6" /> |
| 81 | + </a> |
| 82 | + </motion.div> |
| 83 | + ))} |
| 84 | + </div> |
| 85 | + ) : ( |
| 86 | + <div className="text-center"> |
| 87 | + <div className="h-16 w-16 rounded-full mx-auto bg-gray-700 flex items-center justify-center mb-4"> |
| 88 | + <UserRound className="h-8 w-8 text-gray-300" /> |
| 89 | + </div> |
| 90 | + <p className="text-gray-400">No contributors found</p> |
| 91 | + </div> |
| 92 | + )} |
88 | 93 | </div> |
89 | 94 | </section> |
90 | 95 | ); |
|
0 commit comments