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

fixed #58

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";

import { useEffect } from "react";
import { usePathname } from "next/navigation";
import Footer from "@/components/Footer";
import Header from "@/components/Header";
import ScrollToTop from "@/components/ScrollToTop";
Expand All @@ -8,28 +10,29 @@ import { ThemeProvider } from "next-themes";
import "../styles/index.css";
import "../styles/prism-vsc-dark-plus.css";
import ToasterContext from "./api/contex/ToasetContex";
import { useEffect, useState } from "react";
import PreLoader from "@/components/Common/PreLoader";
import { useState } from "react";

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const [loading, setLoading] = useState<boolean>(true);
const pathname = usePathname();

// Reset scroll position on route change
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

useEffect(() => {
setTimeout(() => setLoading(false), 1000);
}, []);

return (
<html suppressHydrationWarning={true} className="!scroll-smooth" lang="en">
{/*
<head /> will contain the components returned by the nearest parent
head.js. Find out more at https://beta.nextjs.org/docs/api-reference/file-conventions/head
*/}
<head />

<body>
{loading ? (
<PreLoader />
Expand Down
60 changes: 30 additions & 30 deletions src/components/projectData/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Repo {
description: string | null;
language: string | null;
stargazers_count: number;
forks_count: number; // Add forks_count
forks_count: number; // Add forks_count
}

const RepoList = () => {
Expand All @@ -24,7 +24,8 @@ const RepoList = () => {
const data: Repo[] = await response.json(); // Cast the response data to Repo[]
setRepos(data);
} catch (err) {
if (err instanceof Error) { // Narrow down the error type
if (err instanceof Error) {
// Narrow down the error type
setError(err.message);
} else {
setError("An unknown error occurred");
Expand All @@ -39,35 +40,34 @@ const RepoList = () => {
if (!repos.length) return <div>Loading repositories...</div>;

return (
<div className="projectsCard grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 p-4">
<div className="projectsCard grid grid-cols-1 gap-6 p-4 md:grid-cols-2 lg:grid-cols-3">
{repos.map((repo) => (
<div
key={repo.id}
className="p-6 border rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 dark:bg-gray-800 dark:border-gray-700"
>
<h2 className="text-xl font-bold mb-2 dark:text-gray-400 text-gray-900">
<a
href={repo.html_url}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 dark:text-blue-400 hover:underline"
>
{repo.name}
</a>
</h2>
<p className="text-gray-700 dark:text-[rgb(136,143,155)]">
{repo.description || "No description available."}
</p>
<div className="flex justify-between items-center mt-4">
<span className="text-sm text-gray-600 dark:text-[rgb(136,143,155)]">
Language: {repo.language || "N/A"}
</span>
<span className="text-sm text-gray-600 dark:text-[rgb(136,143,155)]">
⭐ {repo.stargazers_count}
</span>
</div>
</div>

<div
key={repo.id}
className="rounded-lg border p-6 shadow-md transition-shadow duration-300 hover:shadow-lg dark:border-gray-700 dark:bg-gray-800"
>
<h2 className="mb-2 text-xl font-bold text-gray-900 dark:text-gray-400">
<a
href={repo.html_url}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:underline dark:text-blue-400"
>
{repo.name}
</a>
</h2>
<p className="text-gray-700 dark:text-[rgb(136,143,155)]">
{repo.description || "No description available."}
</p>
<div className="mt-4 flex items-center justify-between">
<span className="text-sm text-gray-600 dark:text-[rgb(136,143,155)]">
Language: {repo.language || "N/A"}
</span>
<span className="text-sm text-gray-600 dark:text-[rgb(136,143,155)]">
⭐ {repo.stargazers_count}
</span>
</div>
</div>
))}
</div>
);
Expand Down