-
Notifications
You must be signed in to change notification settings - Fork 25
Allow to open viewer in a separate window #548
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: main
Are you sure you want to change the base?
Allow to open viewer in a separate window #548
Conversation
|
@Anna15170221 can you test this one and write your suggestions? from me: it seems a lot of code was copy pasted from a different component, we shouldn't copy-paste the code, we need to extract it and reuse it.. that way we will keep the code maintanable.
|
|
ihomp
left a comment
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.
It seems there is a lot of copy-pasted code that needs to be extracted and reused.
|
@pandablue0809 http://localhost:3000/en/nft/00083A9836EC5BC756007990B29DBFC81F45460ED8B8583A6442C30600000069 - I tested on this one |
|
@ihomp Slava, popups scrolling for fixed objects - what do you mean here? |
|
@ihomp |
@pandablue0809 chenaged css for the search block, so the search block on other pages can appear over some popuup windows like choosinga. token or when signing transactions, or when scrolling on a pages, some elemnts can be under the bar or over the bar.. it's dangerous to change such parameters without proper testing on different pages with different scenarious |
@Anna15170221 can you test again please |
…-separate-window-on-nft-page
…-separate-window-on-nft-page
|
@ihomp |
|
@pandablue0809 |
|
@Anna15170221 @ihomp |
|
@pandablue0809 @ihomp |
ihomp
left a comment
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.
There are a lot of copy-pasted functions and code.
You can not copy-paste the same function within the same app, they need to be extracted as functions and reused.
…-separate-window-on-nft-page
|
@ihomp |
ihomp
left a comment
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.
Please check how you used styles in the other pages you did:
/pages/nft-collection
/pages/objects
/pages/services/account-settings
Please use it here in the same way.
|
@ihomp |
|
@Anna15170221 can you please test again, please |
|
@ihomp for me looks ok. |
| )} | ||
| {videoUrl && defaultTab === 'video' && ( | ||
| <> | ||
| {loadingImage(nft)} |
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.
why nft is deleted?
|
There are many things affected by this PR: We need to test:
We need to make sure we need to make sure we have proper loading states
We need to make sure we show errors for failing loading images @Anna15170221 @pandablue0809, please send me some examples where you've tested, so I can check too. |
|
@ihomp What I've noticed that in the "full screen mode" which Riku is trying to implement, when we open the video in the full screen, we show it in the bad quality. I haven't found the nft with failed to load error. |
|
The code is still not optimized.... I see that you reuse the same CSS file in the NFTpreview... That wouldn't be nessary if you reused components and functions instead of css classes.. For example: loading image - you have just copy pasted my code to your file, and then reused the css in it.. You shouldn't copy and paste code; instead, extract my code as a function and reuse it on both my page and your new page. If files will have some shared CSS (which is not the part of the same components) then you should name the css file differently, like nftView.css or similiar.. importing NFTfullViewer css (css for another page) into the NftPreview - doesn't look right.. also css modules can extend one another.. |
components/NftPreview.js
Outdated
| const modelUrl = nftUrl(nft, 'model') | ||
| const viewerUrl = nftUrl(nft, 'viewer') | ||
| const urls = extractNftUrls(nft) | ||
| const { image: imageUrl, video: videoUrl, audio: audioUrl, model: modelUrl, viewer: viewerUrl } = urls |
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.
why , name it right away as it will be used.
Instead of reassigning teh variables, just update teh function
components/NftPreview.js
Outdated
| } | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [imageUrl, videoUrl]) | ||
| }, [imageUrl, videoUrl, nft.metadata]) |
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.
any comments?
components/NftPreview.js
Outdated
|
|
||
| return ( | ||
| <> | ||
| <div className={nftFullScreenViewer}> |
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.
If you want to reuse the same classes, your rather name the file differently
First of all, you should export components taht are reused, not classes
ihomp
left a comment
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.
JS/CSS code sharing is not optimised
| image={{ file: imageUrl }} | ||
| /> | ||
| <SearchBlock searchPlaceholderText={t('enter-nft-id', { ns: 'nft' })} tab="nft" /> | ||
| <div style={isHidden ? { position: 'relative', zIndex: 0 } : {}}> |
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.
Thats looks like a hack.. why is it this way?
…ps://github.com/pandablue0809/bithomp-frontend-react into feat/520/allow-open-separate-window-on-nft-page
|
@ihomp |
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.
Pull request overview
This PR implements a fullscreen viewer feature for NFTs, allowing users to view NFT content in a dedicated fullscreen mode. The changes refactor existing NFT preview functionality into reusable components and introduce new UI components for fullscreen viewing.
Key Changes:
- Extracted NFT content rendering logic into reusable components and utility functions
- Added a new fullscreen viewer component with mobile-responsive design
- Created a custom hook (
useNftContent) to manage NFT content state and logic
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/nft.js | Added utility functions for NFT content handling (panorama detection, model attributes processing, URL extraction, rendering helpers) |
| styles/components/nftPreview.module.scss | New stylesheet for NFT preview component with shared styles from NftViewer.scss |
| styles/components/nftFullScreenViewer.module.scss | New stylesheet for fullscreen viewer with responsive mobile design |
| styles/components/NftViewer.scss | New shared SCSS mixin for common NFT viewer styles |
| pages/nft/[[...id]].js | Added state management for hiding content when fullscreen is active |
| hooks/useNftContent.js | New custom hook centralizing NFT content state management and URL extraction |
| components/NftPreview.js | Refactored to use new hook and components, added fullscreen button |
| components/NftFullScreenViewer.js | New fullscreen viewer component with tab navigation and download functionality |
| components/Nft/NftContentRenderer.js | New shared component for rendering NFT media content (images, videos, 3D models) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const useNftContent = (nft, imageStyleOptions = {}) => { | ||
| const { t } = useTranslation() | ||
| const [contentTab, setContentTab] = useState('image') | ||
| const [loaded, setLoaded] = useState(true) |
Copilot
AI
Dec 4, 2025
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.
The initial value of loaded should be false instead of true. Setting it to true initially prevents loading indicators from showing when content is actually loading, which creates a confusing user experience.
| const [loaded, setLoaded] = useState(true) | |
| const [loaded, setLoaded] = useState(false) |
| style={(() => { | ||
| if (classNamePrefix === 'fv-fullscreen') { | ||
| return { | ||
| imageRendering: imageStyle.imageRendering, | ||
| filter: imageStyle.filter, | ||
| display: loaded ? 'inline-block' : 'none' | ||
| } | ||
| } | ||
| return { | ||
| ...imageStyle, | ||
| display: loaded ? 'inline-block' : 'none' | ||
| } | ||
| })()} |
Copilot
AI
Dec 4, 2025
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.
The inline IIFE for computing styles is complex and reduces readability. Extract this logic into a named function or compute the style object before the return statement to improve code clarity.



Issue
Make possible to open the integrated viewer in a separate window (/nft page).