Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cards for contributors #227

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading