Skip to content

Commit 751a569

Browse files
authored
Merge pull request WebXDAO#238 from abhikrishnaram/main
Create project page
2 parents 30735d2 + daa5986 commit 751a569

File tree

2 files changed

+74
-75
lines changed

2 files changed

+74
-75
lines changed

src/components/Projcts/ RepoCard.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {FaStar} from "react-icons/fa";
2+
3+
const RepoCard = ({ repo }) => {
4+
const { name, html_url, stargazers_count, language, owner, description } = repo;
5+
return (
6+
<a href={html_url} target="_blank" rel="noopener noreferrer"
7+
className="bg-slate-900 border flex flex-col justify-between rounded-lg border-gray-700 p-5 shadow hover:bg-gray-700 delay-100 h-full duration-200 w-full">
8+
<div>
9+
<div className="flex flex-row">
10+
{/*<img src={owner?.avatar_url} className="rounded h-40 w-40"/>*/}
11+
<p>
12+
<span className="text-gray-500 font-semibold">{owner.login}/</span>
13+
<span className="text-gray-300 font-semibold">{name}</span>
14+
</p>
15+
</div>
16+
<p className="text-xs text-gray-500 mt-3">
17+
{ description }
18+
</p>
19+
</div>
20+
<div className="flex justify-between mt-4">
21+
<span className="text-xs text-gray-500">{language}</span>
22+
<div className="flex flex-row justify-between">
23+
<div className="flex flex-row text-gray-500 hover:text-white">
24+
<FaStar className="h-4 w-4"/>
25+
<span className="text-xs ml-1">{stargazers_count}</span>
26+
</div>
27+
</div>
28+
</div>
29+
</a>
30+
)
31+
}
32+
33+
export default RepoCard;

src/pages/projects.js

Lines changed: 41 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
11
import Head from "next/head";
2-
import { prefix } from "../constants";
2+
import RepoCard from "../components/Projcts/ RepoCard";
33

4-
export default function Projects({ projectsData }) {
4+
export const getStaticProps = async () => {
5+
try {
6+
const res = await fetch('https://api.github.com/users/WebXDAO/repos');
7+
const data = await res.json()
8+
9+
if (!data) {
10+
return {
11+
props: {
12+
success: false,
13+
message: "No data found"
14+
}
15+
};
16+
}
17+
return {
18+
props: {
19+
success: true,
20+
projectsData: data
21+
}
22+
};
23+
} catch (e) {
24+
return {
25+
props: {
26+
success: false,
27+
message: e
28+
}
29+
};
30+
}
31+
}
32+
33+
const Projects = ({ success = false, projectsData = [] }) => {
534
return (
635
<>
736
<Head>
@@ -20,85 +49,22 @@ export default function Projects({ projectsData }) {
2049
</section>
2150

2251
<div className="container max-w-screen-xl mx-auto my-8 grid pb-8 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 mb-0 sm:mb-8 gap-6 px-8">
23-
{projectsData.map(
24-
({ name, imgUrl, type, title, text, tags }, index) => (
52+
{ success ? projectsData.length > 0 && projectsData.map((repo, index) => (
2553
<div
26-
key={name + index}
54+
key={index}
2755
className="flex flex-col justify-between items-stretch col-span-3 md:col-span-1 cursor-pointer p-2 shadow rounded-md focus:outline-none focus:shadow-outline transform transition hover:shadow-lg hover:scale-105 duration-300 ease-in-out"
2856
>
29-
<div className="bg-white p-4 rounded-lg flex flex-col justify-between">
30-
<div className="relative mb-6">
31-
<img
32-
className="h-44 md:h-64 lg:h-60 xl:h-56 w-full object-cover object-center rounded-md"
33-
src={prefix + imgUrl}
34-
alt={name}
35-
/>
36-
</div>
37-
<div className="flex justify-between items-center md:items-start mb-2 md:mb-4">
38-
<h2 className="text-lg md:text-xl text-gray-900 font-semibold">
39-
{title}
40-
</h2>
41-
<h3
42-
className={`tracking-widest ${type === 'FREE' ? 'text-green-500' : 'text-yellow-500'
43-
} text-sm font-semibold title-font`}
44-
>
45-
{type}
46-
</h3>
47-
</div>
48-
49-
<p className="leading-relaxed text-sm md:text-base text-gray-800 mb-5">
50-
{text}
51-
</p>
52-
53-
<div className="mt-auto justify-items-end text-sm flex flex-wrap gap-3">
54-
{tags.map((item, index) => (
55-
<button
56-
key={item + index}
57-
className="whitespace-nowrap font-semibold bg-blue-100 text-blue-600 rounded-md py-2 px-4 focus:outline-none"
58-
>
59-
{item}
60-
</button>
61-
))}
62-
</div>
63-
</div>
57+
<RepoCard repo={repo}/>
6458
</div>
65-
)
66-
)}
59+
)
60+
) : (
61+
<div>
62+
Error fetching data! Please try again later.
63+
</div>
64+
) }
6765
</div>
6866
</>
6967
);
7068
}
7169

72-
export function getStaticProps() {
73-
const data = [
74-
{
75-
name: "InVision",
76-
imgUrl: "/blogs_inVision.png",
77-
type: "PREMIUM",
78-
title: "Start Here",
79-
text: "InVision is the digital product design platform used to make the worlds best customer experiences.",
80-
tags: ["Documentation"],
81-
},
82-
{
83-
name: "Adobe XD",
84-
imgUrl: "/blogs_xd.png",
85-
type: "FREE",
86-
title: "Blockchain Dev Path",
87-
text: "Adobe XD is your UI/UX design solution platform for website and mobile appcreation.",
88-
tags: ["Documentation"],
89-
},
90-
{
91-
name: "Figma",
92-
imgUrl: "/blogs_figma.png",
93-
type: "FREE",
94-
title: "Website",
95-
text: "Figma helps the teams to create, test, and ship better designs from start to finish.",
96-
tags: ["Tailwind Css", "Eleventy", "Alpine.js"],
97-
},
98-
];
99-
return {
100-
props: {
101-
projectsData: data,
102-
},
103-
};
104-
}
70+
export default Projects;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy