documentcloud-frontend
documentcloud-frontend copied to clipboard
Refactor Viewer
This isn't fully where I want it to be, but wanted to get it up for visibilty. Additional things, like notes improvements, can be follow-ups.
Goals are cleaning up code, consolidating redundancies, extracting pure functions, and increased test coverage.
Changes include:
- Adding
ViewerContextthat makes it easier to set and access data for variety of sub-components - Removes props passing in favor of having components access
ViewerContextdirectly - Renaming
*Paneinto*Layer - Consolidating read-only
NotesPanewithAnnotationsPaneto deduplicate rendering logic - Consolidating
TextandTextPage - Loading the PDF in the
ViewerContext, instead of the conditionally-renderedPDF - Keeping
viewerdirectory as flat as possible. Toolbars are now alongside their layers, e.g.AnnotationLayerandAnnotationToolbarare siblings. - Refactors stateless functions into tested utility functions in
lib/utils/viewer - Adds
src/lib/components/viewer/README.mdwith a high-level overview of how it works (yay documentation)
Still to do:
- Move
zoomandscalestate intoViewerContextand mode-conversion logic intosrc/lib/utils/viewer.ts ViewerContext.activeNoteis probably redundant and can be removed. Whether itβs open or not is state local to that note, navigation is handled through link to the #hash, and we can update a note to be open if its hash is in$page.url- Consolidate
afterNavigateandonHashChangeintoViewerContextfromsrc/routes/(app)/documents/[id]-[slug]/+page.svelteandsrc/routes/embed/documents/[id]-[slug]/+page.svelte - Try to consolidate PDF rendering between
PDFPage.svelteandNote.svelteβthere's a duplication of logic there. The render functions could also be made pure and assume it's operating on acanvasnode that's passed as an argument.
Coverage Report
| Status | Category | Percentage | Covered / Total |
|---|---|---|---|
| π΅ | Lines | 23.65% | 7454 / 31514 |
| π΅ | Statements | 23.65% | 7454 / 31514 |
| π΅ | Functions | 41.14% | 151 / 367 |
| π΅ | Branches | 60.66% | 418 / 689 |
File Coverage
Deploy Preview for documentcloud-frontend ready!
| Name | Link |
|---|---|
| Latest commit | 2e51a01ec87c1996d9f15528a91ff4f0ed1e6dc8 |
| Latest deploy log | https://app.netlify.com/sites/documentcloud-frontend/deploys/67190d728d0c130008f8de2c |
| Deploy Preview | https://deploy-preview-777.muckcloud.com |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
Lighthouse |
1 paths audited Performance: 39 Accessibility: 79 Best Practices: 92 SEO: 85 PWA: - View the detailed breakdown and full score reports |
To edit notification comments on pull requests, go to your Netlify site configuration.
