From ed14f2b1a59a8658b173879be0b398feaf75bb50 Mon Sep 17 00:00:00 2001 From: Anuj Kumar Singh Date: Mon, 20 May 2024 14:01:19 +0530 Subject: [PATCH] scrollbar ui update --- src/app/projects/page.tsx | 148 +++++++++++++++++--------------------- src/styles/global.css | 20 ++++-- 2 files changed, 82 insertions(+), 86 deletions(-) diff --git a/src/app/projects/page.tsx b/src/app/projects/page.tsx index a04ef64..c6b7b46 100644 --- a/src/app/projects/page.tsx +++ b/src/app/projects/page.tsx @@ -1,95 +1,79 @@ -"use client" +"use client"; import * as React from "react"; -import axios from 'axios'; +import axios from "axios"; import Navbar from "@/components/Navbar/page"; interface Project { - name: string; - stargazers_count: number; - html_url: string; + name: string; + stargazers_count: number; + html_url: string; } const Project: React.FC = () => { - const [query, setQuery] = React.useState(''); - const [searchResults, setSearchResults] = React.useState([]); - const [loading, setLoading] = React.useState(false); - const [error, setError] = React.useState(''); + const [query, setQuery] = React.useState(""); + const [searchResults, setSearchResults] = React.useState([]); + const [loading, setLoading] = React.useState(false); + const [error, setError] = React.useState(""); - const handleSearch = async () => { - try { - setLoading(true); - setError(''); - const response = await axios.get('https://api.github.com/search/repositories', { - params: { - q: `${query}`, - sort: 'stars', - order: 'desc' - } - }); - setSearchResults(response.data.items); - } catch (error) { - setError('Failed to fetch data'); - } finally { - setLoading(false); - } - }; + const handleSearch = async () => { + try { + setLoading(true); + setError(""); + const response = await axios.get("https://api.github.com/search/repositories", { + params: { + q: `${query}`, + sort: "stars", + order: "desc", + }, + }); + setSearchResults(response.data.items); + } catch (error) { + setError("Failed to fetch data"); + } finally { + setLoading(false); + } + }; - return ( - <> -
-

Search Open Source Projects

-
- setQuery(e.target.value)} - /> - -
- {loading &&

Loading...

} - {error &&

{error}

} -
- {searchResults.map((project, index) => ( -
-

{project.name}

-

{`Stars: ${project.stargazers_count}`}

-

URL: {`${project.html_url}`}

-
- ))} -
+ return ( + <> +
+

Search Open Source Projects

+
+ setQuery(e.target.value)} /> + +
+ {loading &&

Loading...

} + {error &&

{error}

} +
+ {searchResults.map((project, index) => ( +
+

{project.name}

+

{`Stars: ${project.stargazers_count}`}

+

+ + URL: {`${project.html_url}`} + +

- - - ); -} + ))} +
+
+ + ); +}; export default Project; diff --git a/src/styles/global.css b/src/styles/global.css index 41a308c..3a2e648 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -76,9 +76,21 @@ } @font-face { - font-family: 'DM_Mono'; - src: url('/src/fonts/DMMono-Regular.ttf') format('truetype'); - font-weight: normal; - font-style: normal; + font-family: "DM_Mono"; + src: url("/src/fonts/DMMono-Regular.ttf") format("truetype"); + font-weight: normal; + font-style: normal; } +::-webkit-scrollbar { + width: 8px; /* Width of the scrollbar */ +} + +::-webkit-scrollbar-track { + background: rgb(28, 38, 52); /* Color of the track */ +} + +::-webkit-scrollbar-thumb { + background: rgb(230, 240, 230); /* Color of the thumb */ + border-radius: 6px; /* Roundness of the thumb */ +}