-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: preview a pdf file in task's carousel (#145)
- Loading branch information
Showing
10 changed files
with
313 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.carousel-btn { | ||
@apply w-14 h-14 p-3 rounded-full bg-white/10 cursor-pointer hover:text-gray-400 text-white; | ||
@apply absolute top-1/2; | ||
|
||
&.left { | ||
@apply left-[30px]; | ||
} | ||
|
||
&.right { | ||
@apply right-[30px]; | ||
} | ||
} |
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,30 @@ | ||
'use client' | ||
|
||
import { Loading } from '@shared/ui' | ||
import { useState } from 'react' | ||
import { Document, Page } from 'react-pdf' | ||
import 'react-pdf/dist/Page/AnnotationLayer.css' | ||
import 'react-pdf/dist/Page/TextLayer.css' | ||
|
||
export default function PdfViewer({ src }: { src: string }) { | ||
const [loading, setLoading] = useState(true) | ||
const [numPages, setNumPages] = useState<number>() | ||
const [pageNumber, setPageNumber] = useState<number>(1) | ||
|
||
function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { | ||
setNumPages(numPages) | ||
setLoading(false) | ||
} | ||
|
||
return ( | ||
<div> | ||
<Loading enabled={loading} title="Parsing..." /> | ||
<Document file={src} onLoadSuccess={onDocumentLoadSuccess}> | ||
<Page width={800} pageNumber={pageNumber} /> | ||
</Document> | ||
<p> | ||
Page {pageNumber} of {numPages} | ||
</p> | ||
</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
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.