diff --git a/src/components/Hero.tsx b/src/components/Hero.tsx index c62d1191..5c5cb478 100644 --- a/src/components/Hero.tsx +++ b/src/components/Hero.tsx @@ -1,139 +1,18 @@ -import { MutableRefObject, useRef, useState } from "react"; -import { useDebounce, useDidUpdate, useKeys } from "rooks"; - -import { fetchRecommendations } from "../lib/supabase"; -import searchNormal from "../assets/searchNormal.svg"; -import cmdKIcon from "../assets/cmdK.svg"; -import SearchedRepoCard from "./SearchedRepoCard"; -import { Combobox } from "@headlessui/react"; - -const Hero = () => { - const containerRef = useRef(document); - const searchBoxRef = useRef(null); - const comboButtonRef = useRef(null); - const [searchTerm, setSearchTerm] = useState(""); - const setValueDebounced = useDebounce(setSearchTerm, 500); - const [fetchedData, setFetchedData] = useState([]); - const [comboBoxSelection, setComboBoxSelection] = useState(""); - const [hasFocus, setFocus] = useState(false); - - const handleCmdK = async (e: KeyboardEvent) => { - comboButtonRef.current?.click(); - if (!hasFocus) { - searchBoxRef.current?.focus(); - setFocus(true); - const results = await fetchRecommendations(3, searchTerm); - - setFetchedData(results); - } else { - searchBoxRef.current?.blur(); - setFocus(false); - } - - // prevent browser from handling CMD/CTRL + K - e.preventDefault(); - }; - - const useKey = (superKey: string, key: string, target: MutableRefObject) => { - useKeys([superKey, key], handleCmdK, { target }); - }; - - useKey("ControlLeft", "KeyK", containerRef); - - useKey("ControlRight", "KeyK", containerRef); - - useKey("MetaRight", "KeyK", containerRef); - - useKey("MetaLeft", "KeyK", containerRef); - - useDidUpdate(async () => { - const results = await fetchRecommendations(3, searchTerm); - - setFetchedData(results); - }, [searchTerm]); - - return ( -
-
-

- {`Find `} - - - Open-Source Repositories - - -
- to contribute today -

-
- - -
-
- search icon - - - searchTerm} - placeholder="Search repositories" - type="text" - value={searchTerm} - onChange={e => setValueDebounced(e.target.value)} - onFocus={() => setFocus(true)} - onBlur={() => - setTimeout(() => { - setFocus(false); - }, 200)} - onKeyUp={(event: React.KeyboardEvent) => { - if (event.key === "Enter") { - window.open(comboBoxSelection, "_blank", "noreferrer"); - } - }} - /> - -
- - command k -
- -
- - {fetchedData.length > 0 && ( -
-
-

Repository

-
- - {fetchedData.map(data => ( - (active ? "bg-gray-50" : "")} - value={`https://app.opensauced.pizza/s/${data.full_name}`} - > - - - ))} -
- )} -
-
-
+const Hero = () => ( +
+
+

+ {`Find `} + + + Open-Source Repositories + + +
+ to contribute today +

- ); -}; +
+); export default Hero; diff --git a/src/components/HotRepoCard.tsx b/src/components/HotRepoCard.tsx index 37653d90..ba4ad403 100644 --- a/src/components/HotRepoCard.tsx +++ b/src/components/HotRepoCard.tsx @@ -27,7 +27,7 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => { rel="noreferrer" target="_blank" href={`${String( - `${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded` + `${bugReportLink} repo not found [${repoName}]&body=Please take a look why this ${repoName} not founded`, )}`} > Report a bug @@ -40,7 +40,10 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => { if (isLoading) { return (
- +
); } @@ -52,9 +55,15 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => {
- Hot Repo Icon - - {owner} + Hot Repo Icon + + + {owner} +
@@ -68,25 +77,40 @@ const HotRepoCard = ({ repoName }: HotRepoCardProps): JSX.Element => { {name} -

{description}

+

+ {description} +

- - - {humanizeNumber(issues)} + + + + {humanizeNumber(issues)} +
- - - {humanizeNumber(stars)} + + + + {humanizeNumber(stars)} +
- + 0
diff --git a/src/components/PrimaryNav.tsx b/src/components/PrimaryNav.tsx index 0de05cfb..4b2b9dd0 100644 --- a/src/components/PrimaryNav.tsx +++ b/src/components/PrimaryNav.tsx @@ -26,13 +26,11 @@ const PrimaryNav = (): JSX.Element => { useEffect(() => { const fetchAuthSession = async () => { if (currentUser?.access_token) { - await fetch(`${import.meta.env.VITE_API_URL}/auth/session`, { - headers: { accept: "application/json", Authorization: `Bearer ${currentUser.access_token}` }, - }).catch((err) => console.log("error: ", err)); + await fetch(`${import.meta.env.VITE_API_URL}/auth/session`, { headers: { accept: "application/json", Authorization: `Bearer ${currentUser.access_token}` } }).catch(err => console.log("error: ", err)); } }; - fetchAuthSession().catch((err) => console.log(err)); + fetchAuthSession().catch(err => console.log(err)); }, [userAndTokens]); return ( @@ -42,14 +40,21 @@ const PrimaryNav = (): JSX.Element => {
{userAndTokens && ( - +
@@ -90,9 +95,13 @@ const PrimaryNav = (): JSX.Element => {
-

{userAndTokens.user.user_metadata.full_name}

+

+ {userAndTokens.user.user_metadata.full_name} +

-

{userAndTokens.user.user_metadata.user_name}

+

+ {userAndTokens.user.user_metadata.user_name} +

@@ -100,8 +109,7 @@ const PrimaryNav = (): JSX.Element => { {({ active }) => (