-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathRandomContributors.jsx
More file actions
51 lines (42 loc) · 1.36 KB
/
RandomContributors.jsx
File metadata and controls
51 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useEffect, useState } from "react";
import contributorsData from "../../Jsons/Contributors.json";
import styles from "./RandomContributor.module.css";
const RandomContributors = () => {
const [currentIndex, setCurrentIndex] = useState(0);
const pickRandomContributor = () => {
let randomIndex;
do {
randomIndex = Math.floor(Math.random() * contributorsData.length);
} while (randomIndex === currentIndex);
return randomIndex;
};
useEffect(() => {
setTimeout(() => {
setCurrentIndex(pickRandomContributor())
}, 5000);
}, [currentIndex]);
const currentUser = contributorsData[currentIndex];
return (
<>
<div
className={`${styles["card-container"]} ` }
style={
{ display : "flex" , opacity : 1 ,marginTop : "2rem", transition:' all 0.3s ease-in-out' }
}
>
<h1 className={styles.heading}>Thanking Our Before I Die Contributors</h1>
<a href={`${currentUser.GitHub}` target="_blank"}>
<div className={`${styles.cards} `}>
<img
src={currentUser.avatar}
className={styles.image}
alt={`${currentUser.name}'s avatar`}
/>
<p className={styles.name}>{currentUser.name}</p>
</div>
</a>
</div>
</>
);
};
export default RandomContributors;