From e6a2bfc75e4d702e5cdf216eba8f23b44bb5de11 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 10:53:29 +0300 Subject: [PATCH 1/9] Github Issue Finider init --- src/app/gh-finder/page.jsx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/app/gh-finder/page.jsx diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx new file mode 100644 index 00000000..07be01c5 --- /dev/null +++ b/src/app/gh-finder/page.jsx @@ -0,0 +1,32 @@ +"use client"; +import { useState } from "react"; +import { NavBar } from "../components/navbar"; +export default function GhFinder() { + const [isDarkMode, setIsDarkMode] = useState(false); + const [selected, setSelected] = useState(1) + const toggleTheme = () => { + setIsDarkMode(!isDarkMode); + }; + return ( +
+ +
+
+

+ Github Issue Finder +

+
+ + +
+
+
+
+ ); +} From d91c472a7e4aa7cbaa0302ebeb4a3af35713c162 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 13:46:04 +0300 Subject: [PATCH 2/9] Responsive --- src/app/gh-finder/page.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index 07be01c5..faf868ae 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -17,11 +17,11 @@ export default function GhFinder() { toggleTheme={toggleTheme} />
-
+

Github Issue Finder

-
+
From fd0821ab94885e6b6955f453b6500ca4d56be108 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 14:42:24 +0300 Subject: [PATCH 3/9] Github Issue finder --- src/app/gh-finder/page.jsx | 114 +++++++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 5 deletions(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index faf868ae..d5e31ecc 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -1,15 +1,39 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { NavBar } from "../components/navbar"; +import Link from "next/link"; + export default function GhFinder() { const [isDarkMode, setIsDarkMode] = useState(false); - const [selected, setSelected] = useState(1) + const [selected, setSelected] = useState(1); + const [data, setData] = useState(); const toggleTheme = () => { setIsDarkMode(!isDarkMode); }; + useEffect(() => { + setData(undefined); + const url = selected == 1 ? "https://api.github.com/repos/bashamega/webdevtools/issues" : "https://api.github.com/search/issues?q=state:open+is:issue"; + fetch(url) + .then((res) => res.json()) + .then((d) => selected== 1? setData(d.filter((item) =>!item.node_id.includes("PR_"))):setData(d.items)) + .catch((error) => console.error("Error fetching data:", error)); + }, [selected]); + function isDarkColor(color) { + // Convert the color to RGB + const hexColor = color.replace("#", ""); + const r = parseInt(hexColor.substr(0, 2), 16); + const g = parseInt(hexColor.substr(2, 2), 16); + const b = parseInt(hexColor.substr(4, 2), 16); + + // Calculate the luminance + const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255; + + // Return true if luminance is less than 0.5 (considered dark) + return luminance < 0.5; + } return (
- - + +
+
+ {data ? ( + data.map((item, index) => ( +
+ + {item.title} + +
+ {item.labels && item.labels.length > 0 ? ( + item.labels.map((label) => { + const isDark = isDarkColor(label.color); + const textColor = isDark ? "text-white" : "text-gray-800"; + + return ( +

+ {label.name} +

+ ); + }) + ) : ( +

No labels

+ )} +
+
+

Created by:

+ + User Avatar +

{item.user.login}

+ +
+
+ )) + ) : ( +
+
+
+
+

Loading ...

+
+
+ )} +
); } From ac4f4968bf9b26a40ae89b81b1f52b2c203f6547 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 17:40:31 +0300 Subject: [PATCH 4/9] Quick Formatting --- src/app/gh-finder/page.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index d5e31ecc..6a574a6e 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -12,10 +12,17 @@ export default function GhFinder() { }; useEffect(() => { setData(undefined); - const url = selected == 1 ? "https://api.github.com/repos/bashamega/webdevtools/issues" : "https://api.github.com/search/issues?q=state:open+is:issue"; + const url = + selected == 1 + ? "https://api.github.com/repos/bashamega/webdevtools/issues" + : "https://api.github.com/search/issues?q=state:open+is:issue"; fetch(url) .then((res) => res.json()) - .then((d) => selected== 1? setData(d.filter((item) =>!item.node_id.includes("PR_"))):setData(d.items)) + .then((d) => + selected == 1 + ? setData(d.filter((item) => !item.node_id.includes("PR_"))) + : setData(d.items), + ) .catch((error) => console.error("Error fetching data:", error)); }, [selected]); function isDarkColor(color) { From 29a0a8ef75da6618b8b6a7dd08f264437fcfcfaf Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 18:17:57 +0300 Subject: [PATCH 5/9] Preview change --- src/app/gh-finder/page.jsx | 93 ++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index 6a574a6e..a8567994 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -77,49 +77,62 @@ export default function GhFinder() {
{data ? ( data.map((item, index) => ( -
- - {item.title} - -
- {item.labels && item.labels.length > 0 ? ( - item.labels.map((label) => { - const isDark = isDarkColor(label.color); - const textColor = isDark ? "text-white" : "text-gray-800"; - - return ( -

- {label.name} -

- ); - }) - ) : ( -

No labels

- )} -
-
-

Created by:

+
+
- User Avatar -

{item.user.login}

+ {item.title} +
+ {item.labels && item.labels.length > 0 ? ( + item.labels.map((label) => { + const isDark = isDarkColor(label.color); + const textColor = isDark ? "text-white" : "text-gray-800"; + + return ( +

+ {label.name} +

+ ); + }) + ) : ( +

No labels

+ )} +
+
+

Created by:

+ + User Avatar +

{item.user.login}

+ +
+
+
+
+

Assignees:

+ {item.assignees.length > 0 ? ( +
+ {item.assignees.map(assignee=>( + {assignee.login} + ))} +
+ ) : ( +

0

+ )} +
)) From 8024c48b7b4c5b98aa11274e1ae17bf742e0578d Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 18:22:19 +0300 Subject: [PATCH 6/9] Cliackable PFP --- src/app/gh-finder/page.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index a8567994..15de0199 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -77,7 +77,10 @@ export default function GhFinder() {
{data ? ( data.map((item, index) => ( -
+
Assignees:

{item.assignees.length > 0 ? (
- {item.assignees.map(assignee=>( - {assignee.login} + {item.assignees.map((assignee) => ( + + {assignee.login} + ))}
) : ( From fbd1309db7eee66359857b6443a13ede783b4654 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 18:35:12 +0300 Subject: [PATCH 7/9] Reactions --- src/app/gh-finder/page.jsx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index 15de0199..ae1d5dc2 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -79,7 +79,7 @@ export default function GhFinder() { data.map((item, index) => (
{item.user.login}

+
+

Reactions:

+
+
+ 👍

{item.reactions["+1"]}

+
+
+ 👎

{item.reactions["-1"]}

+
+
+ 😄

{item.reactions.laugh}

+
+
+ 🎉

{item.reactions.hooray}

+
+
+ 😕

{item.reactions.confused}

+
+
+ ❤️

{item.reactions.heart}

+
+
+ 🚀

{item.reactions.rocket}

+
+
+ 👀

{item.reactions.eyes}

+
+
+
From 432bbf46622a08e50ef10e9983dba926452c200e Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 18:40:12 +0300 Subject: [PATCH 8/9] Root Repository --- src/app/gh-finder/page.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/app/gh-finder/page.jsx b/src/app/gh-finder/page.jsx index ae1d5dc2..73716227 100644 --- a/src/app/gh-finder/page.jsx +++ b/src/app/gh-finder/page.jsx @@ -88,6 +88,20 @@ export default function GhFinder() { > {item.title} + + {item.repository_url.replace( + "https://api.github.com/repos/", + "", + )} + + +

{item.labels && item.labels.length > 0 ? ( item.labels.map((label) => { From 7e896944eebfa19d69ad288d1f5f773378d6855a Mon Sep 17 00:00:00 2001 From: Bashamega Date: Fri, 19 Jul 2024 18:47:57 +0300 Subject: [PATCH 9/9] Replaced the under development tool with the gh finder --- src/db/tools.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db/tools.json b/src/db/tools.json index 58cc3a55..6446804b 100644 --- a/src/db/tools.json +++ b/src/db/tools.json @@ -1,8 +1,8 @@ [ { "id": 1, - "name": "Code Snippets", - "link": "/snippet" + "name": "Github Issue Finder", + "link": "/gh-finder" }, { "id": 1,