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 contributors page #375

Merged
merged 2 commits into from
Jul 8, 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
2 changes: 2 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import EditPost from "./pages/EditPost";
import useTheme from './hooks/useTheme';
import CodeEditor from "./pages/CodeEditor";
import TrendingPosts from "./pages/TrendingPosts";
import Contributors from "./pages/Contributors";
// import axios from "axios";
// axios.defaults.baseURL = "http://localhost:3001/";

Expand All @@ -49,6 +50,7 @@ function App() {
<Route path="/app" element={<Home />} />
<Route path="/app/posts/:id" element={<Post />} />
<Route path="/app/posts" element={<Posts />} />
<Route path="/app/contributors" element={<Contributors/>}/>
<Route path="/app/profile/:id" element={<ShowProfile/>} />
<Route
path="/app/signin"
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const Footer = () => {
<CgProfile size={20} />
</Link>
</li>
<li className='py-1 cursor-pointer hover:text-[#2563EB]'>
<Link to="/app/contributors">Our Contributors</Link>
</li>
</ul>
</div>
<div className='md:w-1/3'>
Expand Down
66 changes: 66 additions & 0 deletions frontend/src/pages/Contributors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';

interface Contributor {
id: number;
login: string;
html_url: string;
avatar_url: string;
contributions: number;
}

const Contributors: React.FC = () => {
const [contributors, setContributors] = useState<Contributor[]>([]);

useEffect(() => {
async function fetchContributors() {
try {
const response = await axios.get<Contributor[]>(
'https://api.github.com/repos/VaibhavArora314/StyleShare/contributors'
);
setContributors(response.data);
} catch (error) {
console.error('Error fetching contributors:', error);
}
}
fetchContributors();
}, []);

return (
<div className="bg-white dark:bg-black text-black dark:text-gray-200 min-h-screen">
<div className="container mx-auto py-8">
<h1 className="text-center text-4xl font-semibold mb-8">Contributors</h1>
<div className="flex flex-wrap justify-center gap-8">
{contributors.map((contributor) => (
<div
key={contributor.id}
className="w-full md:w-1/3 lg:w-1/4 flex flex-col items-center bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-lg shadow-md p-4 transition-transform transform hover:scale-105 hover:shadow-xl"
>
<a
href={contributor.html_url}
className="block"
target="_blank"
rel="noopener noreferrer"
>
<img
src={contributor.avatar_url}
alt={contributor.login}
className="w-24 h-24 rounded-full object-cover mb-4"
/>
</a>
<h2 className="text-lg font-medium text-gray-900 dark:text-gray-100 mb-2">
{contributor.login}
</h2>
<p className="text-gray-700 dark:text-gray-400">
Contributions: {contributor.contributions}
</p>
</div>
))}
</div>
</div>
</div>
);
};

export default Contributors;

Loading