-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/f 35 pdf preview implementation #14
Feature/f 35 pdf preview implementation #14
Conversation
@@ -1,3 +1,8 @@ | |||
@tailwind base; | |||
@tailwind components; | |||
@tailwind utilities; | |||
|
|||
/* PdfViewer.css */ | |||
canvas.react-pdf__Page__canvas { |
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.
we need to use css here to add padding between pages
Yeah I think it's okay, I'm not even sure how you're supposed to respect this rule in a functional component |
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.
Overall great job! Take a look at my comments, just smal code styling issues I found. Also few things to add here:
- Can you please add the download PDF Functionality?
- Can you think how we can get the documents from this endpoint
https://static.hungermapdata.org/insight-reports/latest/country.json
and display them in the previewer? - add border to the navbar and the color could be like light gray in light mode and dark grey in dark mode.
But overall quality and functionality is great! Good job!
src/components/Pdf/PdfViewer.tsx
Outdated
const handleScroll = () => { | ||
const pages = document.querySelectorAll('.react-pdf__Page'); | ||
let currentPage = pageNumber; | ||
|
||
pages.forEach((page, index) => { | ||
const rect = page.getBoundingClientRect(); | ||
const pageTop = rect.top; | ||
const pageBottom = rect.bottom; | ||
const viewportMidpoint = window.innerHeight / 2; | ||
|
||
if (pageTop < viewportMidpoint && pageBottom > viewportMidpoint) { | ||
currentPage = index + 1; | ||
} | ||
}); | ||
|
||
setPageNumber(currentPage); | ||
}; |
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.
This function should be exported to an operations file in operations/pdf-previewer/PdfPreviewerOperations.ts
src/components/Pdf/PdfViewer.tsx
Outdated
const [selectionText, setSelectionText] = useState<string | null>(null); | ||
const [tooltipPosition, setTooltipPosition] = useState<{ top: number; left: number } | null>(null); | ||
|
||
const handleScroll = () => { |
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.
precise naming handleDocumentScroll
+ return type of the function is missing
src/components/Pdf/PdfViewer.tsx
Outdated
function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { | ||
setTotalPages(numPages); | ||
window.addEventListener('scroll', handleScroll); | ||
} |
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.
you should not use arrow function declaration and function declaration in the same file. Chose one of both approaches and be consistent
src/components/Pdf/PdfViewer.tsx
Outdated
function onSelectStart() { | ||
setSelectionText(null); | ||
} |
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.
same here
src/components/Pdf/PdfViewer.tsx
Outdated
window.addEventListener('scroll', handleScroll); | ||
} | ||
|
||
function onSelectStart() { |
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.
return type of the function is missing
src/components/Pdf/PdfViewer.tsx
Outdated
setSelectionText(null); | ||
} | ||
|
||
function onSelectEnd() { |
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.
same here + return type
@@ -26,7 +28,7 @@ module.exports = { | |||
light: { | |||
colors: { | |||
primary: { DEFAULT: '#157DBC', foreground: '#F5F5F5' }, | |||
secondary: '#EEEEEE', | |||
secondary: '#666666', |
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.
this corresponds to our secondary color used in figma designs
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.
Great Job!
@Tschonti please approve if it is ok that I add
"react/jsx-no-bind": "off"
to our linter config. I think we need it for defining functions inside components likehandleScroll
(seePdfViewer.tsx
).