-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from bookpanda/link-responsive
Link extension + responsive
- Loading branch information
Showing
22 changed files
with
556 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
NEXT_PUBLIC_COURSE_TTL=3600000 # 1 hour | ||
NEXT_PUBLIC_FACULTY_TTL=86400000 # 1 day | ||
NEXT_PUBLIC_RECENT_COURSES_TTL=31536000000 # 1 year | ||
API_URL=http://localhost:5203 | ||
API_KEY=apikey | ||
API_KEY=apikey | ||
EXTENSION_URL= |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FaListCheck } from "react-icons/fa6"; | ||
|
||
export const HowTo = () => { | ||
return ( | ||
<div className="flex w-full flex-col gap-2 rounded-lg bg-white p-3 max-lg:h-auto lg:min-h-[356px] lg:py-4"> | ||
<div className="flex justify-between gap-4"> | ||
<div className="flex w-full items-center gap-2"> | ||
<FaListCheck className="h-5 w-5 text-secondary-default max-lg:h-4 max-lg:w-4" /> | ||
<div className="text-lg font-semibold text-high max-lg:text-base"> | ||
How to use extension | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
data-orientation="horizontal" | ||
role="separator" | ||
className="border-disable h-px border-b" | ||
/> | ||
<div className="flex flex-col gap-2 overflow-x-auto overflow-y-hidden pt-2 max-md:flex"> | ||
<li>Download and unzip the extension from this web</li> | ||
<li> | ||
Go to{" "} | ||
<span className="text-primary-default">chrome://extensions/</span>{" "} | ||
(you can copy and paste this link in your browser) | ||
</li> | ||
<li> | ||
Click <span className="text-primary-default">Load unpacked</span> and | ||
select the unzipped folder | ||
</li> | ||
<li>Now you can share your ideas with your friends</li> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { FaQuestion } from "react-icons/fa"; | ||
|
||
export const Intro = () => { | ||
return ( | ||
<div className="flex w-full flex-col gap-2 rounded-lg bg-white p-3 max-lg:h-auto lg:min-h-[356px] lg:py-4"> | ||
<div className="flex justify-between gap-4"> | ||
<div className="flex w-full items-center gap-2"> | ||
<FaQuestion className="h-5 w-5 text-secondary-default max-lg:h-4 max-lg:w-4" /> | ||
<div className="text-lg font-semibold text-high max-lg:text-base"> | ||
What is OurCourseVille | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
data-orientation="horizontal" | ||
role="separator" | ||
className="border-disable h-px border-b" | ||
/> | ||
<div className="flex flex-col gap-2 overflow-x-auto overflow-y-hidden pt-2 max-md:flex"> | ||
<li>Tired of taking screenshots of assignments?</li> | ||
<li> | ||
You can now "Share solution" of your assignment using our | ||
Chrome extension | ||
</li> | ||
<li>Share once, learn anywhere</li> | ||
<li> | ||
We do NOT condone any form of cheating or plagiarism, we only provide | ||
a platform for students to collaborate and share their ideas. | ||
</li> | ||
<li> | ||
We do NOT collect any Personally Identifiable Information data from | ||
you, we only collect solutions to the assignments. | ||
</li> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"use client"; | ||
|
||
import { FC } from "react"; | ||
import { FaChalkboard } from "react-icons/fa6"; | ||
import { CourseCard } from "../components/Card/CourseCard"; | ||
import { useGetRecentCourses } from "../hooks/useGetRecentCourses"; | ||
import { Faculty } from "../types"; | ||
|
||
interface RecentCoursesProps { | ||
faculties: Faculty[]; | ||
} | ||
|
||
export const RecentCourses: FC<RecentCoursesProps> = ({ faculties }) => { | ||
const { recentCourses } = useGetRecentCourses(); | ||
|
||
if (recentCourses.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<div className="flex flex-row gap-4 max-lg:flex-col-reverse"> | ||
<div className="flex w-full flex-col gap-2 rounded-lg bg-white p-3 max-lg:w-full"> | ||
<div className="flex justify-between gap-4"> | ||
<div className="flex w-full items-center gap-2"> | ||
<FaChalkboard className="h-5 w-5 text-secondary-default max-lg:h-4 max-lg:w-4" /> | ||
<div className="text-lg font-semibold text-high max-lg:text-base"> | ||
Recent | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
data-orientation="horizontal" | ||
role="separator" | ||
className="border-disable h-px border-b" | ||
/> | ||
<div className="grid grid-cols-3 gap-2 overflow-x-auto pt-2 max-md:flex"> | ||
{recentCourses.map((c) => { | ||
const faculty = faculties.find((f) => f.code === c.facultyCode); | ||
return ( | ||
<CourseCard | ||
href={`/faculty/${c.facultyCode}/course/${c.code}/assignment`} | ||
key={c.code} | ||
course={c} | ||
faculty={faculty} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
2 changes: 1 addition & 1 deletion
2
...aculty/[facultycode]/course/[coursecode]/assignment/[assignmentcode]/record/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
export default function Home() { | ||
return <></>; | ||
} | ||
import { FaHouse } from "react-icons/fa6"; | ||
import { getAllFaculty } from "../api/faculty"; | ||
import { HowTo } from "./HowTo"; | ||
import { Intro } from "./Intro"; | ||
import { RecentCourses } from "./RecentCourses"; | ||
|
||
const Home = async () => { | ||
const faculties = await getAllFaculty(); | ||
if (faculties instanceof Error) { | ||
return <div>Error: {faculties.message}</div>; | ||
} | ||
|
||
return ( | ||
<main> | ||
<div className="mx-auto max-w-[1440px] md:w-4/5"> | ||
<div className="m-4 flex flex-col gap-4 lg:mx-0 lg:my-6"> | ||
<div className="flex items-center gap-2"> | ||
<FaHouse className="h-6 w-6 text-secondary-default" /> | ||
<div className="text-2xl font-semibold text-high max-lg:text-xl"> | ||
Home | ||
</div> | ||
</div> | ||
<RecentCourses faculties={faculties} /> | ||
<div className="flex w-full flex-row items-center justify-between gap-4 max-lg:flex-col"> | ||
<div className="flex w-[calc(50%-4px)] flex-col gap-2 rounded-lg bg-white p-3 max-lg:w-full lg:min-h-[356px] lg:py-4"> | ||
<Intro /> | ||
</div> | ||
<div className="flex w-[calc(50%-4px)] flex-col gap-2 rounded-lg bg-white p-3 max-lg:w-full lg:min-h-[356px] lg:py-4"> | ||
<HowTo /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class LocalStorageManager { | ||
setItem(key: string, value: object, ttl: number) { | ||
const now = new Date(); | ||
|
||
const item = { | ||
value: value, | ||
expiry: now.getTime() + ttl, // Current time + TTL (in milliseconds) | ||
}; | ||
|
||
localStorage.setItem(key, JSON.stringify(item)); | ||
} | ||
|
||
getItem<T>(key: string): T | null { | ||
const itemStr = localStorage.getItem(key); | ||
|
||
if (!itemStr) { | ||
return null; | ||
} | ||
|
||
const item = JSON.parse(itemStr); | ||
const now = new Date(); | ||
|
||
if (now.getTime() > item.expiry) { | ||
localStorage.removeItem(key); | ||
return null; | ||
} | ||
|
||
return item.value; | ||
} | ||
|
||
deleteItem(key: string) { | ||
localStorage.removeItem(key); | ||
} | ||
|
||
clearAll() { | ||
localStorage.clear(); | ||
} | ||
} | ||
|
||
export const cache = new LocalStorageManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
import { FaExternalLinkAlt } from "react-icons/fa"; | ||
|
||
import Link from "next/link"; | ||
import { FC } from "react"; | ||
|
||
interface ExtensionButtonProps { | ||
url: string; | ||
} | ||
|
||
export const ExtensionButton: FC<ExtensionButtonProps> = ({ url }) => { | ||
return ( | ||
<Link | ||
href={url} | ||
target="_blank" | ||
className="rounded-full p-2 text-medium hover:bg-primary-bg hover:text-primary-default" | ||
> | ||
<FaExternalLinkAlt className="outline-none" size={20} /> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.