From 21d7671480dc6318ee3f2e55dd4604b511dfd5ff Mon Sep 17 00:00:00 2001 From: pani2004 Date: Sat, 6 Jul 2024 00:55:02 +0530 Subject: [PATCH 1/2] Added contributors page --- frontend/src/App.tsx | 2 + frontend/src/components/Footer.tsx | 3 ++ frontend/src/pages/Contributors.tsx | 61 +++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 frontend/src/pages/Contributors.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d6ea8e7c..04d12e58 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -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/"; @@ -49,6 +50,7 @@ function App() { } /> } /> } /> + }/> } /> { +
  • + Our Contributors +
  • diff --git a/frontend/src/pages/Contributors.tsx b/frontend/src/pages/Contributors.tsx new file mode 100644 index 00000000..0863a674 --- /dev/null +++ b/frontend/src/pages/Contributors.tsx @@ -0,0 +1,61 @@ +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([]); + useEffect(() => { + async function fetchContributors() { + try { + const response = await axios.get( + 'https://api.github.com/repos/VaibhavArora314/StyleShare/contributors' + ); + setContributors(response.data); + } catch (error) { + console.error('Error fetching contributors:', error); + } + } + fetchContributors(); + }, []); + + return ( +
    +
    +

    Contributors

    +
    + {contributors.map((contributor) => ( +
    + + {contributor.login} + +

    {contributor.login}

    + +

    + Contributions: {contributor.contributions} +

    +
    + ))} +
    +
    +
    + ); +}; +export default Contributors; + From 0313aec6f1ae0743eae94f592c7ff1c1581cb732 Mon Sep 17 00:00:00 2001 From: pani2004 Date: Sat, 6 Jul 2024 12:51:09 +0530 Subject: [PATCH 2/2] Made it theme responsive --- frontend/src/pages/Contributors.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/Contributors.tsx b/frontend/src/pages/Contributors.tsx index 0863a674..c5fa88e4 100644 --- a/frontend/src/pages/Contributors.tsx +++ b/frontend/src/pages/Contributors.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; import axios from 'axios'; + interface Contributor { id: number; login: string; @@ -7,8 +8,10 @@ interface Contributor { avatar_url: string; contributions: number; } + const Contributors: React.FC = () => { const [contributors, setContributors] = useState([]); + useEffect(() => { async function fetchContributors() { try { @@ -24,14 +27,14 @@ const Contributors: React.FC = () => { }, []); return ( -
    +

    Contributors

    {contributors.map((contributor) => (
    { className="w-24 h-24 rounded-full object-cover mb-4" /> -

    {contributor.login}

    - -

    +

    + {contributor.login} +

    +

    Contributions: {contributor.contributions}

    @@ -57,5 +61,6 @@ const Contributors: React.FC = () => {
    ); }; + export default Contributors;