Skip to content

Commit

Permalink
Merge pull request #227 from KGupta2601/main
Browse files Browse the repository at this point in the history
added cards for contributors
  • Loading branch information
MastanSayyad authored Nov 9, 2024
2 parents bc760ea + a5bbf6e commit e88a827
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
24 changes: 24 additions & 0 deletions chaosweb-v@2/src/components/ContributorCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.contributor-card {
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
margin: 10px;
transition: transform 0.3s ease;
opacity: 0;
transform: translateY(20px);
animation: slide-in 0.5s forwards;
}

.profile-pic {
width: 50px;
height: 50px;
border-radius: 50%;
}

@keyframes slide-in {
to {
opacity: 1;
transform: translateY(0);
}
}
43 changes: 43 additions & 0 deletions chaosweb-v@2/src/components/ContributorCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { useEffect, useState } from "react";
import ContributorCard from './ContributorCard'; // Import the ContributorCard component
import "./Contributors.css";

const Contributors = () => {
const [contributors, setContributors] = useState([]);

// Fetch contributors from GitHub API
useEffect(() => {
const fetchContributors = async () => {
try {
const response = await fetch(
"https://api.github.com/repos/vansh-codes/ChaosWeb/contributors"
);
const data = await response.json();
setContributors(data); // Store the contributors' data in state
} catch (error) {
console.error("Error fetching contributors:", error);
}
};

fetchContributors();
}, []);

return (
<div className="contributors-list">
{contributors.length > 0 ? (
contributors.map((contributor) => (
<ContributorCard
key={contributor.id} // Use contributor.id as the key
name={contributor.login} // Contributor's GitHub username
profilePic={contributor.avatar_url} // Contributor's avatar URL
contributions={contributor.contributions} // Number of contributions
/>
))
) : (
<p>Loading contributors...</p>
)}
</div>
);
};

export default Contributors;
5 changes: 5 additions & 0 deletions chaosweb-v@2/src/components/ContributorsList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.contributors-list {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
13 changes: 13 additions & 0 deletions chaosweb-v@2/src/components/ContributorsList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import ContributorsList from './ContributorsList';

const App = () => {
return (
<div>
<h1>Contributors</h1>
<ContributorsList />
</div>
);
};

export default App;

0 comments on commit e88a827

Please sign in to comment.