Skip to content

Commit 69bb49d

Browse files
fixes
1 parent a9f483f commit 69bb49d

File tree

3 files changed

+45
-21
lines changed

3 files changed

+45
-21
lines changed

src/app/upload/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const Page = () => {
103103
};
104104

105105
return (
106-
<div className="h-screen">
106+
<div className="h-screen flex flex-col justify-between">
107107
<div>
108108
<Navbar />
109109
</div>

src/components/Footer.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use client"
1+
"use client";
22
import { Separator } from "./ui/separator";
33
import ccLogo from "../assets/codechef_logo.svg";
44
import Image from "next/image";
@@ -9,13 +9,20 @@ import meta_icon_dark from "../assets/meta_icon_dark.svg";
99
import x_twitter_icon_dark from "../assets/x_twitter_icon_dark.svg";
1010
import Link from "next/link";
1111
import { useTheme } from "next-themes";
12+
import { useEffect, useState } from "react";
1213

1314
export default function Footer() {
1415
const { theme, setTheme } = useTheme();
15-
const isDarkMode = theme === "dark";
16+
const [isDarkMode, setIsDarkMode] = useState<boolean | null>(true);
17+
18+
useEffect(() => {
19+
if (theme) {
20+
setIsDarkMode(theme === "dark");
21+
}
22+
}, [theme]);
1623

1724
return (
18-
<div className="mx-auto flex flex-col items-center justify-between lg:justify-around gap-y-12 pt-12 md:pt-8 lg:w-full lg:flex-row lg:px-12">
25+
<div className="mx-auto flex flex-col items-center justify-between gap-y-12 pt-12 md:pt-8 lg:w-full lg:flex-row lg:justify-around lg:px-12">
1926
<div className="flex items-center">
2027
<h1 className="jost bg-gradient-to-r from-[#562EE7] to-[#FFC6E8] bg-clip-text text-center text-3xl font-bold text-transparent lg:text-5xl">
2128
Papers
@@ -45,15 +52,15 @@ export default function Footer() {
4552
</Link>
4653
<Link href="https://www.facebook.com/codechefvit/">
4754
<Image
48-
src={isDarkMode ? meta_icon : meta_icon_dark}
55+
src={isDarkMode ? meta_icon_dark : meta_icon}
4956
alt="meta-icon"
5057
height={24}
5158
width={24}
5259
/>
5360
</Link>
5461
<Link href="https://x.com/codechefvit">
5562
<Image
56-
src={isDarkMode ? x_twitter_icon : x_twitter_icon_dark}
63+
src={isDarkMode ? x_twitter_icon_dark : x_twitter_icon}
5764
alt="x_twitter_icon"
5865
height={24}
5966
width={24}

src/components/searchbar.tsx

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useState, useCallback } from "react";
3+
import { useState, useCallback, useRef, useEffect } from "react";
44
import axios, { AxiosError } from "axios";
55
import { Search } from "lucide-react";
66
import debounce from 'debounce';
@@ -13,6 +13,7 @@ function SearchBar () {
1313
const [suggestions, setSuggestions] = useState<string[]>([]);
1414
const [error, setError] = useState<string | null>(null);
1515
const [loading, setLoading] = useState(false);
16+
const suggestionsRef = useRef<HTMLUListElement | null>(null);
1617

1718
const debouncedSearch = useCallback(
1819
debounce(async (text: string) => {
@@ -56,6 +57,19 @@ function SearchBar () {
5657
router.push(`/catalogue?subject=${encodeURIComponent(suggestion)}`);
5758
};
5859

60+
const handleClickOutside = (event: MouseEvent) => {
61+
if (suggestionsRef.current && !suggestionsRef.current.contains(event.target as Node)) {
62+
setSuggestions([]);
63+
}
64+
};
65+
66+
useEffect(() => {
67+
document.addEventListener("mousedown", handleClickOutside);
68+
return () => {
69+
document.removeEventListener("mousedown", handleClickOutside);
70+
};
71+
}, []);
72+
5973
return (
6074
<div className="mx-4 md:mx-0">
6175
<form className="w-full max-w-xl">
@@ -76,24 +90,27 @@ function SearchBar () {
7690
Loading suggestions...
7791
</div>
7892
)}
79-
{suggestions.length > 0 && !loading && (
80-
<ul className="absolute mx-0.5 md:mx-0 md:w-full text-center max-w-xl z-20 border bg-white border-[#7480FF] dark:bg-[#030712] rounded-md mt-2">
81-
{suggestions.map((suggestion, index) => (
82-
<li
83-
key={index}
84-
onClick={() => handleSelectSuggestion(suggestion)}
85-
className="cursor-pointer p-2 truncate hover:opacity-50"
86-
style={{ width: '100%', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}
87-
>
88-
{suggestion}
89-
</li>
90-
))}
93+
{(suggestions.length > 0 || error) && !loading && (
94+
<ul ref={suggestionsRef} className="absolute mx-0.5 md:mx-0 md:w-full text-center max-w-xl z-20 border bg-white border-[#7480FF] dark:bg-[#030712] rounded-md mt-2">
95+
{error ? (
96+
<li className="p-2 text-red">{error}</li>
97+
) : (
98+
suggestions.map((suggestion, index) => (
99+
<li
100+
key={index}
101+
onClick={() => handleSelectSuggestion(suggestion)}
102+
className="cursor-pointer p-2 truncate hover:opacity-50"
103+
style={{ width: '100%', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }}
104+
>
105+
{suggestion}
106+
</li>
107+
))
108+
)}
91109
</ul>
92110
)}
93111
</form>
94-
{error && <p className="mt-4 text-red">{error}</p>}
95112
</div>
96113
);
97-
};
114+
}
98115

99116
export default SearchBar;

0 commit comments

Comments
 (0)