Skip to content

Commit b7f89a7

Browse files
committed
search bar overflow and pinned search bug fix
1 parent f188699 commit b7f89a7

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

src/app/pinned/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Pinned = () => {
66
return (
77
<div id="pinned" className="mt-5 flex flex-col justify-between">
88
<h1 className="mx-auto my-8 hidden text-center font-vipnabd text-3xl font-extrabold md:block">
9-
Pinned Papers
9+
Pinned Subjects
1010
</h1>
1111

1212
<div className="mb-3 flex w-full flex-col items-center gap-2 px-6">

src/components/Card.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import {
99
extractBracketContent,
1010
extractWithoutBracketContent,
1111
} from "@/util/utils";
12-
import { getSecureUrl, generateFileName, downloadFile } from "@/util/download";
12+
import {
13+
getSecureUrl,
14+
generateFileName,
15+
downloadFile,
16+
} from "@/util/download_paper";
1317
import Link from "next/link";
1418
import { cn } from "@/lib/utils";
1519

src/components/CatalogueContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import { Filter } from "lucide-react";
1414
import { Sheet, SheetContent, SheetTrigger } from "./ui/sheet";
1515
import { Pin } from "lucide-react";
1616
import { StoredSubjects } from "@/interface";
17-
import { getSecureUrl, generateFileName, downloadFile } from "@/util/download";
17+
import {
18+
getSecureUrl,
19+
generateFileName,
20+
downloadFile,
21+
} from "@/util/download_paper";
1822

1923
const CatalogueContent = () => {
2024
const router = useRouter();

src/components/Searchbar/pinned-searchbar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function PinnedSearchBar({
5757
setPinned(currentPinnedSubjects.includes(suggestion));
5858
}
5959

60+
setShowControls(true);
6061
setSuggestions([]);
6162
filtersNotPulled?.();
6263
};
@@ -110,6 +111,9 @@ function PinnedSearchBar({
110111

111112
localStorage.setItem("userSubjects", JSON.stringify(updated));
112113
window.dispatchEvent(new Event("userSubjectsChanged"));
114+
115+
setSearchText("");
116+
setPinned(false);
113117
};
114118

115119
useEffect(() => {

src/components/Searchbar/searchbar-child.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,37 @@ function SearchBarChild({
135135
<li
136136
key={index}
137137
onClick={() => handleSelectSuggestion(suggestion)}
138-
className="flex cursor-pointer items-center truncate rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-800"
138+
className="flex cursor-pointer items-center rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-800"
139139
>
140140
<div
141141
id="paper_count"
142142
className="mr-4 flex h-10 w-10 items-center justify-center rounded-md bg-[#171720] text-sm font-semibold text-white"
143143
>
144144
{subjectCounts[suggestion] ?? "0"}
145145
</div>
146-
<span
147-
id="subject"
148-
className="items-center text-sm tracking-wide text-white sm:text-base"
149-
>
150-
{suggestion}
151-
</span>
146+
147+
{(() => {
148+
const codeMatch = /\[[^\]]+\]$/.exec(suggestion);
149+
const code = codeMatch ? codeMatch[0] : "";
150+
const title = suggestion.replace(/\s\[[^\]]+\]$/, "");
151+
152+
let displayTitle = title;
153+
if (title.length > 40) {
154+
const start = title.slice(0, 25).trim();
155+
const end = title.slice(-15).trim();
156+
displayTitle = `${start}.....${end}`;
157+
}
158+
159+
return (
160+
<span
161+
id="subject"
162+
className="flex w-full items-center text-sm tracking-wide text-white sm:text-base"
163+
>
164+
<span className="truncate">{displayTitle}</span>
165+
<span className="ml-2 shrink-0">{code}</span>
166+
</span>
167+
);
168+
})()}
152169
</li>
153170
))}
154171
</ul>

src/components/pdfViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useState, useRef, useCallback, useEffect } from "react";
66
import { Document, Page, pdfjs } from "react-pdf";
77
import { Download, ZoomIn, ZoomOut, Maximize2, Minimize2 } from "lucide-react";
88
import { Button } from "./ui/button";
9-
import { downloadFile } from "@/util/download";
9+
import { downloadFile } from "@/util/download_paper";
1010
import ShareButton from "./ShareButton";
1111
import Loader from "./ui/loader";
1212
import { FaGreaterThan, FaLessThan } from "react-icons/fa6";

0 commit comments

Comments
 (0)