Skip to content

Commit db7c8b3

Browse files
authored
Merge pull request #134 from CodeChefVIT/samya/changes
fixed some changes required
2 parents 0d69294 + 74bc345 commit db7c8b3

File tree

9 files changed

+45
-235
lines changed

9 files changed

+45
-235
lines changed

src/app/page.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import SearchBar from "@/components/searchbar";
21
import Navbar from "@/components/Navbar";
32
import StoredPapers from "@/components/StoredPapers";
43
import Footer from "@/components/Footer";
54
import Hero from "@/components/Hero";
65
import Faq from "@/components/Faq";
6+
import SearchBar from "@/components/Searchbar/searchbar";
77

88
const HomePage = () => {
99
return (
1010
<div className="flex min-h-screen w-full flex-col vipna dark:bg-[#070114] bg-[#F3F5FF]">
1111
<div>
1212
<Navbar />
1313
</div>
14-
<div className="mt-2 flex flex-grow flex-col items-center justify-center gap-y-10">
14+
<div className="flex flex-grow flex-col items-center justify-center gap-y-10">
1515
<div className="w-full max-w-2xl space-y-10 text-center">
1616
<h1 className="vipnabd font-extrabold text-3xl md:text-3xl mx-auto mt-14 mb-6">
1717
Built by Students for Students
1818
</h1>
1919
</div>
20-
<div className="z-20 w-full max-w-xl mb-6">
20+
<div className="z-20 w-full max-w-xl">
2121
<SearchBar />
2222
</div>
23-
<div className="w-full max-w-7xl">
23+
<div className="w-full max-w-8xl">
2424
<StoredPapers />
2525
</div>
2626
<div className="w-full max-w-7xl">

src/components/Card.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
6464
return (
6565
<div
6666
className={cn(
67-
"overflow-hidden rounded-md border-2 border-[#36266D] bg-[#171720] hover:bg-[#262635]",
67+
"overflow-hidden play rounded-sm border-2 dark:border-[#36266D] border-[#734DFF] bg-[#FFFFFF] dark:bg-[#171720] hover:bg-[#EFEAFF] hover:dark:bg-[#262635]",
6868
checked && "bg-[#262635]",
6969
)}
7070
>
@@ -90,7 +90,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
9090
</div>
9191
</div>
9292

93-
<div className="h-[1px] w-full bg-[#36266D]" />
93+
<div className="h-[1px] w-full dark:bg-[#36266D] bg-[#734DFF]" />
9494

9595
<div className="space-y-2 p-4">
9696
<div className="font-sans text-base font-semibold">
@@ -106,7 +106,7 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
106106
</div>
107107
</Link>
108108

109-
<div className="hidden items-center justify-between gap-2 px-4 pb-4 md:flex">
109+
<div className="hidden play items-center justify-between gap-2 px-4 pb-4 md:flex">
110110
<div className="flex items-center gap-2">
111111
<input
112112
checked={checked}
@@ -127,4 +127,4 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => {
127127
);
128128
};
129129

130-
export default Card;
130+
export default Card;

src/components/Faq.tsx

+10-8
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@ function Faq() {
2222
</div>
2323
<div className="max-w-7xl play mx-auto space-y-6">
2424
{faqs.map((faq, index) => (
25-
<div key={index} className="p-4 border-b-2 border-[#453D60]">
26-
<div className="flex items-center">
25+
<div
26+
key={index}
27+
className="p-4 border-b-2 border-[#453D60] cursor-pointer"
28+
onClick={() => handleClick(index)}
29+
>
30+
<div className="flex items-center justify-between w-full">
2731
<h2
28-
className={`text-lg play font-semibold ${faqActive === index ? "dark:text-[#A47DE5] text-[#6F2DA6]" : "dark:text-[#C0BACE] text-black"} w-full pr-15`}
32+
className={`text-lg font-semibold w-full ${faqActive === index ? "text-[#A47DE5]" : "text-[#C0BACE]"}`}
2933
>
3034
{faq.question}
3135
</h2>
3236
<button
33-
onClick={() => handleClick(index)}
34-
className={`text-md font-bold w-11 h-6 flex items-center justify-center rounded-full transition-all duration-200 ${faqActive === index ? "text-white dark:bg-[#A47DE5] bg-[#6F2DA6]" : "dark:bg-white bg-[#EDEFF0] text-[#99979F]"}`}
37+
className={`text-md font-bold w-11 h-6 flex items-center justify-center rounded-full transition-all duration-200
38+
${faqActive === index ? "text-white bg-[#A47DE5]" : "bg-white text-[#99979F]"}`}
3539
>
3640
{faqActive === index ? "−" : "+"}
3741
</button>
3842
</div>
39-
{faqActive === index && (
40-
<p className="mt-2 play text-black dark:text-[#C0BACE]">{faq.answer}</p>
41-
)}
43+
{faqActive === index && <p className="mt-2 text-white">{faq.answer}</p>}
4244
</div>
4345
))}
4446
</div>

src/components/Hero.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ function Hero() {
1515
<div id="hero" className="m-10 pt-10 flex flex-col lg:flex-row items-center justify-between">
1616
<div className="w-full lg:w-[50%] text-center lg:text-left">
1717
<div className="vignabd mb-8 text-3xl lg:text-5xl font-extrabold text-[#120020] dark:text-white">
18-
<span className="mb-2 block">Prepare to excel in</span>
19-
<span className="mb-2 block">your CATs and FATs</span>
20-
<span className="mb-2 block ">with CodeChef-</span>
21-
<span className="mb-2 block">VIT’s dedicated</span>
22-
<span className="mb-2 block">repository of past</span>
23-
<span className="mb-6 block">exam papers</span>
18+
<span className="mb-2 block font-extrabold">Prepare to excel in</span>
19+
<span className="mb-2 block font-extrabold">your CATs and FATs</span>
20+
<span className="mb-2 block font-extabold ">with CodeChef-</span>
21+
<span className="mb-2 block font-extrabold">VIT’s dedicated</span>
22+
<span className="mb-2 block font-extrabold">repository of past</span>
23+
<span className="mb-6 block font-extrabold">exam papers</span>
2424
</div>
2525
<div className="play mt-6 flex flex-col lg:flex-row lg:gap-6 text-[#120020] dark:text-white items-center">
2626
<div className="flex flex-col gap-4 lg:w-[200px]">

src/components/PreviewCard.tsx

-52
This file was deleted.

src/components/Searchbar/searchbar-child.tsx

+8-18
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ function SearchBarChild({ initialSubjects }: { initialSubjects: string[] }) {
99
const router = useRouter();
1010
const [searchText, setSearchText] = useState("");
1111
const [suggestions, setSuggestions] = useState<string[]>([]);
12-
const [isSearching, setIsSearching] = useState(false);
1312
const [subjects] = useState<string[]>(initialSubjects);
1413
const suggestionsRef = useRef<HTMLUListElement | null>(null);
15-
const inputRef = useRef<HTMLInputElement | null>(null);
1614

1715
const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
1816
const text = e.target.value;
1917
setSearchText(text);
20-
setIsSearching(true);
2118

2219
if (text.length > 1 && subjects.length > 0) {
2320
const filteredSuggestions = subjects.filter((subject) =>
@@ -32,18 +29,15 @@ function SearchBarChild({ initialSubjects }: { initialSubjects: string[] }) {
3229
const handleSelectSuggestion = (suggestion: string) => {
3330
setSearchText(suggestion);
3431
setSuggestions([]);
35-
setIsSearching(false);
3632
router.push(`/catalogue?subject=${encodeURIComponent(suggestion)}`);
3733
};
3834

3935
const handleClickOutside = (event: MouseEvent) => {
4036
if (
4137
suggestionsRef.current &&
42-
!suggestionsRef.current.contains(event.target as Node) &&
43-
!inputRef.current?.contains(event.target as Node)
38+
!suggestionsRef.current.contains(event.target as Node)
4439
) {
4540
setSuggestions([]);
46-
setIsSearching(false);
4741
}
4842
};
4943

@@ -55,39 +49,35 @@ function SearchBarChild({ initialSubjects }: { initialSubjects: string[] }) {
5549
}, []);
5650

5751
return (
58-
<div className="mx-4 md:mx-0">
52+
<div className="mx-4 md:mx-0 play">
5953
<form
6054
className="w-full max-w-xl"
6155
onSubmit={(e) => {
6256
e.preventDefault();
6357
if (searchText) {
64-
setIsSearching(false);
6558
router.push(`/catalogue?subject=${encodeURIComponent(searchText)}`);
6659
}
6760
}}
6861
>
6962
<div className="relative">
7063
<Input
71-
ref={inputRef}
7264
type="text"
7365
value={searchText}
7466
onChange={handleSearchChange}
75-
onFocus={() => setIsSearching(true)}
7667
placeholder="Search by subject..."
77-
className="text-md w-full rounded-full border bg-[#434dba] px-4 py-6 pr-10 font-sans tracking-wider text-white shadow-sm placeholder:text-white focus:outline-none focus:ring-2"
68+
className="text-md w-full rounded-lg play bg-[#B2B8FF] dark:bg-[#7480FF66] px-4 py-6 pr-10 font-sans tracking-wider dark:text-white text-black shadow-sm placeholder:dark:text-white placeholder:text-black focus:outline-none focus:ring-2"
7869
/>
7970
<button
8071
type="submit"
8172
className="absolute inset-y-0 right-0 flex items-center pr-3"
8273
>
83-
<Search className="h-5 w-5 text-white" />
74+
<Search className="h-5 w-5 text-black dark:text-white" />
8475
</button>
85-
{isSearching &&
86-
(suggestions.length > 0 ||
87-
(searchText.length > 1 && subjects.length > 0)) && (
76+
{(suggestions.length > 0 ||
77+
(searchText.length > 1 && subjects.length > 0)) && (
8878
<ul
8979
ref={suggestionsRef}
90-
className="absolute z-20 mx-0.5 mt-2 w-full max-w-xl rounded-md border border-[#434dba] bg-white text-center shadow-lg dark:bg-[#030712] md:mx-0"
80+
className="absolute z-20 mx-0.5 mt-2 w-full max-w-xl rounded-md bg-white text-center shadow-lg dark:bg-[#030712] md:mx-0"
9181
>
9282
{suggestions.length > 0 ? (
9383
suggestions.map((suggestion, index) => (
@@ -112,4 +102,4 @@ function SearchBarChild({ initialSubjects }: { initialSubjects: string[] }) {
112102
);
113103
}
114104

115-
export default SearchBarChild;
105+
export default SearchBarChild;

src/components/Searchbar/searchbar.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ async function fetchSubjects() {
1818
export default async function SearchBar() {
1919
const subjects = await fetchSubjects();
2020

21+
console.log("Fetched subjects:", subjects);
22+
2123
return <SearchBarChild initialSubjects={subjects} />;
22-
}
24+
}

src/components/StoredPapers.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import papers from "ongoing-papers";
33
import { useEffect, useState } from "react";
44
import axios from "axios";
5-
import PreviewCard from "@/components/PreviewCard";
5+
import Card from "@/components/Card";
66
import { type IPaper } from "@/interface";
77
import Loader from "./ui/loader";
88
import Link from "next/link";
@@ -30,13 +30,18 @@ function StoredPapers() {
3030

3131
return (
3232
<>
33-
<p className="mt-2 mb-6 text-center play text-lg font-semibold">Most Viewed Papers</p>
34-
<div className="flex flex-wrap justify-center gap-4">
33+
<p className="mt-2 mb-4 text-center play text-lg font-semibold">Most Viewed Papers</p>
34+
<div className="flex flex-wrap justify-center gap-6">
3535
{displayPapers.map((paper: IPaper) => (
36-
<PreviewCard key={paper._id} paper={paper} />
36+
<Card
37+
key={paper._id}
38+
paper={paper}
39+
onSelect={() => { "" }}
40+
isSelected={false}
41+
/>
3742
))}
3843
</div>
39-
<h1 className="play text-md text-center mt-10">Learn More</h1>
44+
<h1 className="play text-md text-center mt-4">Learn More</h1>
4045
<Link href="#hero" className="play flex items-center justify-center text-center text-md dark:text-white text-black"></Link>
4146
</>
4247
);

0 commit comments

Comments
 (0)