Skip to content
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

[CU-86b06xn8q] feat(uploader): enhanced file preview with react-file-viewer #246

Conversation

amjedidiah
Copy link
Collaborator

@amjedidiah amjedidiah commented Nov 5, 2024

Screenshot 2024-11-05 at 08 48 29

  • Added support for previewing multiple file types (PDF, DOCX, XLSX, etc.)
  • Implemented react-file-viewer for better file preview capabilities
  • Maintained fallback to FileIcon component when preview fails

OTHER CHANGES

  • Resolved React version mismatch (16.14.0 -> 18.2.0) to fix hook errors in Storybook
  • Added VSCode workspace folder to .gitignore

BREAKING CHANGE: New dependency react-file-viewer is required

- Added support for previewing multiple file types (PDF, DOCX, XLSX, etc.)
- Implemented `react-file-viewer` for better file preview capabilities
- Maintained fallback to FileIcon component when preview fails

OTHER CHANGES
- Resolved React version mismatch (16.14.0 -> 18.2.0) to fix hook errors in Storybook
- Added VSCode workspace folder to `.gitignore`

BREAKING CHANGE: New dependency `react-file-viewer` is required
- Added hover effect with background color change and shadow elevation
- Implemented cursor pointer for clickable file previews
- Added active state for click feedback
- Enhanced dark mode hover states
- Maintained consistent hover behaviour across mini and full preview modes
- Added modal-based DOCX preview to prevent interference between multiple previews
- Created FileWithId interface and shared type definitions
- Fixed file ID generation and management
- Added proper cleanup for object URLs
- Ensured consistent key generation for previews

BREAKING CHANGE: File state type is now FileWithId[] instead of File[]
- Replaced DOCX-specific preview with universal file preview component
- Added modal preview support for all file types
- Fixed file name truncation in preview cards
@amjedidiah amjedidiah changed the title feat(uploader): enhanced file preview with react-file-viewer [CU-86b06xn8q] feat(uploader): enhanced file preview with react-file-viewer Nov 5, 2024
src/UpupUploader.tsx Outdated Show resolved Hide resolved
src/components/FilePreview.tsx Outdated Show resolved Hide resolved
src/components/UpupUploader/Preview.tsx Outdated Show resolved Hide resolved
- swapped  and  for uuid
- removed duplicated returned error element
@MedAmine1212 MedAmine1212 self-requested a review November 26, 2024 19:34
Comment on lines 36 to 40
const objectUrl = useMemo(() => {
const url = URL.createObjectURL(file)
objectUrls.current.push(url)
return url
}, [file])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could lead the url being added multiple times -> memory leaks if the useMemo is triggered multiple times (can happen alot with javascript.)

make sure the URL isn't already in the list before adding it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MedAmine1212, done

@amjedidiah amjedidiah merged commit e9a36c1 into DevinoSolutions:master Nov 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants