|
1 |
| -import React from 'react'; |
2 |
| -import Data from '../../data/Contributors.json'; |
3 |
| -import Header from '../../components/Header/Header'; |
| 1 | +import React, { useState, useEffect } from 'react'; |
| 2 | +// import Data from '../../data/Contributors.json'; |
| 3 | +import Layout from '../../components/Layout/Layout'; |
4 | 4 | import './css/index.css';
|
5 | 5 |
|
6 | 6 | function Contribute() {
|
| 7 | + const url = "https://api.github.com/repos/devvsakib/github-error-solve/contributors" |
| 8 | + const [data, setData] = useState([]); |
| 9 | + useEffect(() => { |
| 10 | + const fetchUsers = async (url) => { |
| 11 | + const response = await fetch(url); |
| 12 | + const users = await response.json(); |
| 13 | + setData(users) |
| 14 | + } |
| 15 | + fetchUsers(url) |
| 16 | + }, [data.length]) |
| 17 | + |
| 18 | + // fun purpose, but looks better, isn't it? |
| 19 | + const changeColor = () => { |
| 20 | + const colorArray = ["4024e0", "1a5ba5", "118d7c", "8d54e1", "40E4F0", "7e1aa5"] |
| 21 | + let element; |
| 22 | + |
| 23 | + return element = colorArray[Math.floor(Math.random() * 6)]; |
| 24 | + } |
7 | 25 | return (
|
8 |
| - <div> |
9 |
| - <Header /> |
| 26 | + <Layout> |
| 27 | + <section className='flex flex-wrap justify-center'> |
10 | 28 | {
|
11 |
| - Data.map(data => |
12 |
| - <div |
13 |
| - id="container" |
14 |
| - className="py-4 mb-4 col-span-12 md:col-span-6 xl:col-span-4 px-2 md:px-6 border-l-4 rounded-lg items-start bg-dark-secondary flex flex-col flex mt-8 items-center gap-2 px-3 py-2 border border-gray rounded-lg hover:border-primary hover:text-primary"> |
15 |
| - <h1>{data.name}</h1> |
16 |
| - <img className='pfp' src={data.image} /> |
17 |
| - <div className="links"> |
18 |
| - <a className='spf-link' href={data.github}>Github</a> |
19 |
| - <a className='spf-link' href={data.twiter}>Twiter</a> |
20 |
| - {/* spf-link : abbreviation of (specific-link) for css */} |
| 29 | + // User filtered by CONTRIBUTIONS number, contribute more to jump in first place |
| 30 | + |
| 31 | + data.map(user => |
| 32 | + <div |
| 33 | + id="container" |
| 34 | + className={`py-4 mb-4 col-span-12 md:col-span-6 xl:col-span-4 md:px-6 border-l-4 rounded-lg bg-dark-secondary flex flex-col mt-8 items-center mx-auto gap-2 px-3 border-[#${changeColor()}] hover:border-primary hover:text-primary`}> |
| 35 | + <h1>{user.login} <small className='text-violet-400 container:hover:text-white'>{user.contributions}</small></h1> |
| 36 | + <img className='pfp' src={user.avatar_url} /> |
| 37 | + <div className="links"> |
| 38 | + <a className='spf-link' href={user.html_url}>Github</a> |
| 39 | + <a className='spf-link' href={user.twiter}>Twiter</a> |
| 40 | + {/* spf-link : abbreviation of (specific-link) for css */} |
| 41 | + </div> |
21 | 42 | </div>
|
22 |
| - </div> |
23 | 43 | )
|
24 | 44 | }
|
25 |
| - </div> |
| 45 | + </section> |
| 46 | + </Layout> |
26 | 47 | )
|
27 | 48 | }
|
28 | 49 |
|
|
0 commit comments