-
Notifications
You must be signed in to change notification settings - Fork 60
Feat: Add paper preview modal on eye icon click #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
e915c2b
1ae7e52
4c1ff08
82fdbec
db5c42d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { type IPaper } from "@/interface"; | ||
| import Image from "next/image"; | ||
| import { Eye, Download, Check } from "lucide-react"; | ||
|
|
@@ -23,6 +24,8 @@ interface CardProps { | |
| } | ||
|
|
||
| const Card = ({ paper, onSelect, isSelected }: CardProps) => { | ||
| const [previewOpen, setPreviewOpen] = React.useState(false); | ||
|
|
||
| const handleDownload = async (paper: IPaper) => { | ||
| await downloadFile(getSecureUrl(paper.file_url), generateFileName(paper)); | ||
| }; | ||
|
|
@@ -34,77 +37,110 @@ const Card = ({ paper, onSelect, isSelected }: CardProps) => { | |
| const paperLink = `/paper/${paper._id}`; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "overflow-hidden rounded-sm border-2 border-[#734DFF] bg-[#FFFFFF] font-play transition-all duration-150 hover:bg-[#EFEAFF] dark:border-[#36266D] dark:bg-[#171720] hover:dark:bg-[#262635]", | ||
| isSelected && "bg-white", | ||
| )} | ||
| > | ||
| <Link href={paperLink} target="_blank" rel="noopener noreferrer"> | ||
| <Image | ||
| src={paper.thumbnail_url} | ||
| alt={paper.subject} | ||
| width={320} | ||
| height={180} | ||
| className="w-full object-cover p-4 pb-3 md:h-[250px]" | ||
| /> | ||
|
|
||
| <div className="justify-center"> | ||
| <div className="flex flex-row items-center justify-between px-4 pb-2"> | ||
| <div className="text-md font-play font-medium"> | ||
| {extractBracketContent(paper.subject)} | ||
| </div> | ||
| <div className="flex gap-2"> | ||
| <Link href={paperLink} target="_blank" rel="noopener noreferrer"> | ||
| <Eye size={22} /> | ||
| </Link> | ||
| <Download | ||
| size={20} | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| void handleDownload(paper); | ||
| }} | ||
| className="cursor-pointer" | ||
| /> | ||
| <> | ||
| <div | ||
| className={cn( | ||
| "overflow-hidden rounded-sm border-2 border-[#734DFF] bg-[#FFFFFF] font-play transition-all duration-150 hover:bg-[#EFEAFF] dark:border-[#36266D] dark:bg-[#171720] hover:dark:bg-[#262635]", | ||
| isSelected && "bg-white", | ||
| )} | ||
| > | ||
|
|
||
| <Image | ||
| src={paper.thumbnail_url} | ||
| alt={paper.subject} | ||
| width={320} | ||
| height={180} | ||
| className="w-full object-cover p-4 pb-3 md:h-[250px]" | ||
| /> | ||
|
|
||
| <div className="justify-center"> | ||
| <div className="flex flex-row items-center justify-between px-4 pb-2"> | ||
| <div className="text-md font-play font-medium"> | ||
| {extractBracketContent(paper.subject)} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="h-[1px] w-full bg-[#734DFF] dark:bg-[#36266D]" /> | ||
| <div className="h-[1px] w-full bg-[#734DFF] dark:bg-[#36266D]" /> | ||
|
|
||
| <div className="space-y-2 p-4"> | ||
| <div className="font-play text-lg font-semibold"> | ||
| {extractWithoutBracketContent(paper.subject)} | ||
| </div> | ||
| <div className="flex flex-wrap gap-2"> | ||
| <Capsule>{paper.exam}</Capsule> | ||
| <Capsule>{paper.slot}</Capsule> | ||
| <Capsule>{paper.year}</Capsule> | ||
| <Capsule>{paper.semester}</Capsule> | ||
| <div className="space-y-2 p-4"> | ||
| <div className="font-play text-lg font-semibold"> | ||
| {extractWithoutBracketContent(paper.subject)} | ||
| </div> | ||
| <div className="flex flex-wrap gap-2"> | ||
| <Capsule>{paper.exam}</Capsule> | ||
| <Capsule>{paper.slot}</Capsule> | ||
| <Capsule>{paper.year}</Capsule> | ||
| <Capsule>{paper.semester}</Capsule> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </Link> | ||
|
|
||
| <div className="flex items-center justify-between gap-2 px-4 pb-4 font-play"> | ||
| <div className="flex items-center gap-2"> | ||
| <input | ||
| checked={isSelected} | ||
| onChange={handleCheckboxChange} | ||
| className="h-5 w-5 accent-[#7480FF]" | ||
| type="checkbox" | ||
|
|
||
|
|
||
| <div className="flex justify-end gap-2 px-4 pb-2"> | ||
| <Eye | ||
| size={22} | ||
| className="cursor-pointer" | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| setPreviewOpen(true); | ||
| }} | ||
| /> | ||
|
|
||
| <Download | ||
| size={20} | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| void handleDownload(paper); | ||
| }} | ||
| className="cursor-pointer" | ||
| /> | ||
| <p>Select</p> | ||
| </div> | ||
| {paper.answer_key_included && ( | ||
| <div className="flex items-center gap-2 font-normal text-[#7480FF]"> | ||
| <Check color="#7480FF" /> | ||
| Answer Key | ||
|
|
||
| <div className="flex items-center justify-between gap-2 px-4 pb-4 font-play"> | ||
| <div className="flex items-center gap-2"> | ||
| <input | ||
| checked={isSelected} | ||
| onChange={handleCheckboxChange} | ||
| className="h-5 w-5 accent-[#7480FF]" | ||
| type="checkbox" | ||
| /> | ||
| <p>Select</p> | ||
| </div> | ||
| )} | ||
|
|
||
| {paper.answer_key_included && ( | ||
| <div className="flex items-center gap-2 font-normal text-[#7480FF]"> | ||
| <Check color="#7480FF" /> | ||
| Answer Key | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {previewOpen && ( | ||
| <div | ||
| className="fixed inset-0 z-50 flex items-center justify-center bg-black/80" | ||
| onClick={() => setPreviewOpen(false)} | ||
| > | ||
| <div | ||
| className="relative w-[95%] max-w-5xl h-[90vh] rounded-lg bg-white p-2 dark:bg-[#171720]" | ||
| onClick={(e) => e.stopPropagation()} | ||
| > | ||
| <button | ||
| className="absolute right-3 top-3 z-10 text-xl" | ||
| onClick={() => setPreviewOpen(false)} | ||
| > | ||
| ✕ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use react lucide icon |
||
| </button> | ||
| <iframe | ||
| src={`${getSecureUrl(paper.file_url)}#toolbar=0`} | ||
| className="w-full h-full rounded-md" | ||
| /> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Card; | ||
| export default Card; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ export default function ShareButton() { | |
| const paperPath = origin + pathname; | ||
| return ( | ||
| <Dialog> | ||
| <DialogTrigger asChild> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why tho ? |
||
| <DialogTrigger> | ||
| <Button className="aspect-square h-10 w-10 p-0"> | ||
| <FaShare /> | ||
| </Button> | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idt the sidebar needs this change, this affects ux , pls check this once and revert it, if it's not needed. Screen.Recording.2026-04-15.101415.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add this back