Skip to content

Commit cbdc596

Browse files
committed
fix: #308
1 parent bb822c3 commit cbdc596

5 files changed

Lines changed: 25 additions & 83 deletions

File tree

src/app/pinned/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Pinned = () => {
1010
const [displayPapers, setDisplayPapers] = useState<IUpcomingPaper[]>([]);
1111
return (
1212
<div id="pinned" className="mt-5 flex flex-col justify-between">
13-
<h1 className="mx-auto my-8 hidden text-center font-vipnabd text-3xl font-extrabold md:block">
13+
<h1 className="mx-auto my-8 text-center font-vipnabd text-xl font-extrabold sm:text-2xl md:text-3xl">
1414
Pinned Subjects
1515
</h1>
1616
<div className="mb-3 flex w-full flex-col items-center gap-2 px-6">

src/components/PinButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function PinButton({
1515
<button
1616
type="submit"
1717
onClick={onToggle}
18-
className={`ml-2 flex items-center gap-2 rounded-full border border-[#3A3745] px-4 py-2 text-sm font-medium transition ${
18+
className={`flex items-center gap-2 rounded-full border border-[#3A3745] px-3 py-3 sm:px-4 sm:py-2 text-sm font-medium transition ${
1919
isPinned
2020
? "bg-purple-700 text-white hover:bg-purple-600 dark:bg-purple-600 dark:hover:bg-purple-500"
2121
: "bg-[#e8e9ff] text-gray-700 hover:bg-slate-50 dark:bg-black dark:text-white dark:hover:bg-[#1A1823]"

src/components/PinnedPapersCarousel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function PinnedPapersCarousel({
110110
const plugins = [Autoplay({ delay: 8000, stopOnInteraction: true })];
111111

112112
return (
113-
<div className="px-4">
113+
<div className="px-4 sm:mt-4">
114114
<div className="">
115115
{displayPapers.length > 0 ?
116116
<Carousel

src/components/Searchbar/pinned-searchbar.tsx

Lines changed: 21 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ function PinnedSearchBar({
2424
const [searchText, setSearchText] = useState("");
2525
const [suggestions, setSuggestions] = useState<string[]>([]);
2626
const suggestionsRef = useRef<HTMLUListElement | null>(null);
27-
const floatingContainerRef = useRef<HTMLDivElement>(null);
2827
const [pinned, setPinned] = useState<boolean>(false);
29-
const [open, setOpen] = useState(false);
3028
const [showControls, setShowControls] = useState(false);
3129
const searchRef = useRef<HTMLInputElement>(null);
3230

@@ -69,19 +67,6 @@ function PinnedSearchBar({
6967
filtersNotPulled?.();
7068
};
7169

72-
const handleClickOutside = (event: MouseEvent) => {
73-
const target = event.target as Node;
74-
if (
75-
floatingContainerRef.current &&
76-
!floatingContainerRef.current.contains(target)
77-
) {
78-
setOpen(false);
79-
}
80-
81-
if (suggestionsRef.current && !suggestionsRef.current.contains(target)) {
82-
setSuggestions([]);
83-
}
84-
};
8570

8671
useEffect(() => {
8772
const handleAddClicked = () => {
@@ -146,7 +131,6 @@ function PinnedSearchBar({
146131
const handleRemoveAll = () => {
147132
localStorage.setItem("userSubjects", JSON.stringify([]));
148133
window.dispatchEvent(new Event("userSubjectsChanged"));
149-
setOpen(false);
150134
};
151135

152136
useEffect(() => {
@@ -157,23 +141,16 @@ function PinnedSearchBar({
157141
if (storedSubjects.length > 0) {
158142
setShowControls(true);
159143
}
160-
161-
document.addEventListener("mousedown", handleClickOutside);
162-
return () => {
163-
document.removeEventListener("mousedown", handleClickOutside);
164-
};
165144
}, []);
166145

167146
return (
168147
<div className="w-full font-play">
169148
<div className="flex justify-center">
170-
<div className="w-full max-w-xl">
149+
<div className="w-full max-w-2xl">
171150
<form
172151
onSubmit={(e) => {
173152
e.preventDefault();
174153
handlePinToggle();
175-
if(searchText.trim()!=="")
176-
setOpen(false);
177154
}}
178155
>
179156
<div className="flex items-center gap-2">
@@ -211,66 +188,31 @@ function PinnedSearchBar({
211188
</ul>
212189
)}
213190
</div>
214-
215-
<div className="hidden md:block">
216-
<PinButton
217-
isPinned={pinned}
218-
onToggle={handlePinToggle}
219-
disabled={!showControls || searchText.trim() === ""}
220-
/>
221-
</div>
222-
223-
<div
224-
ref={floatingContainerRef}
225-
className={`md:hidden ${showControls ? "block" : "hidden"}`}
191+
<PinButton
192+
isPinned={pinned}
193+
onToggle={handlePinToggle}
194+
disabled={!showControls || searchText.trim() === ""}
195+
/>
196+
<button
197+
onClick={() => {
198+
handleRemoveAll();
199+
}}
200+
className="items-center gap-2 rounded-full border border-[#3A3745] bg-[#e8e9ff] px-3 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-slate-50 dark:bg-black dark:text-white dark:hover:bg-[#1A1823] hidden sm:flex"
226201
>
227-
<NavDropdownButton
228-
isOpen={open}
229-
onClick={() => setOpen((prev) => !prev)}
230-
variant="pinned"
231-
/>
232-
233-
<div className={`${open ? "block" : "hidden"}`}>
234-
<FloatingControls>
235-
<PinButton
236-
isPinned={pinned}
237-
onToggle={() => {
238-
handlePinToggle();
239-
setOpen(false);
240-
}}
241-
disabled={!showControls || searchText.trim() === ""}
242-
/>
243-
{displayPapers &&
244-
<button
245-
onClick={() => {
246-
handleRemoveAll();
247-
setOpen(false);
248-
}}
249-
className="flex items-center gap-2 rounded-full border border-[#3A3745] bg-[#e8e9ff] px-3 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-slate-50 dark:bg-black dark:text-white dark:hover:bg-[#1A1823]"
250-
>
251-
Remove All <X className="h-4 w-4" />
252-
</button>}
253-
</FloatingControls>
254-
</div>
255-
</div>
202+
Remove All <X className="h-4 w-4" />
203+
</button>
256204
</div>
257205
</form>
258206
</div>
259207
</div>
260-
{displayPapers &&
261-
<div className="mt-2 hidden w-full md:block">
262-
<div className="ml-auto w-fit">
263-
<button
264-
onClick={() => {
265-
handleRemoveAll();
266-
setOpen(false);
267-
}}
268-
className="flex items-center gap-2 rounded-full border border-[#3A3745] bg-[#e8e9ff] px-3 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-slate-50 dark:bg-black dark:text-white dark:hover:bg-[#1A1823]"
269-
>
270-
Remove All <X className="h-4 w-4" />
271-
</button>
272-
</div>
273-
</div>}
208+
<button
209+
onClick={() => {
210+
handleRemoveAll();
211+
}}
212+
className="sm:hidden mt-4 flex items-center gap-2 rounded-full border border-[#3A3745] bg-[#e8e9ff] px-3 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-slate dark:bg-black dark:text-white dark:hover:bg-[#1A1823]"
213+
>
214+
Remove All <X className="h-4 w-4" />
215+
</button>
274216
</div>
275217
);
276218
}

src/components/bannerDismiss.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function Banner({
5252

5353
<button
5454
onClick={closeBanner}
55-
className="absolute right-4 top-6 transition hover:opacity-75 sm:static sm:self-start"
55+
className="absolute right-4 transition hover:opacity-75 sm:static sm:self-start"
5656
aria-label="Dismiss banner"
5757
style={{ color: accentColor }}
5858
>

0 commit comments

Comments
 (0)