-
Notifications
You must be signed in to change notification settings - Fork 584
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
looker 3d improvements #4226
looker 3d improvements #4226
Conversation
WalkthroughThe recent updates introduce enhancements to the 3D viewing experience in a React application, focusing on user interaction and interface improvements. Key features include toggling full-screen mode, updating help items, adjusting constants for UI elements, and modifying container positioning based on visibility. These changes aim to enrich the user's navigation and interaction within the 3D environment. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4226 +/- ##
===========================================
+ Coverage 27.99% 28.22% +0.22%
===========================================
Files 814 814
Lines 101640 101894 +254
Branches 1178 1215 +37
===========================================
+ Hits 28456 28761 +305
+ Misses 73184 73133 -51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 1
Review Status
Configuration used: .coderabbit.yaml
Files selected for processing (6)
- app/packages/looker-3d/src/action-bar/FullScreenToggler.tsx (1 hunks)
- app/packages/looker-3d/src/action-bar/ViewHelp.tsx (2 hunks)
- app/packages/looker-3d/src/action-bar/index.tsx (2 hunks)
- app/packages/looker-3d/src/constants.ts (1 hunks)
- app/packages/looker-3d/src/containers.ts (1 hunks)
- app/packages/looker-3d/src/fo3d/Leva.tsx (1 hunks)
Additional Context Used
Path-based Instructions (6)
app/packages/looker-3d/src/action-bar/FullScreenToggler.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/looker-3d/src/fo3d/Leva.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/looker-3d/src/action-bar/ViewHelp.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/looker-3d/src/constants.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/looker-3d/src/containers.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.app/packages/looker-3d/src/action-bar/index.tsx (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
Additional comments not posted (8)
app/packages/looker-3d/src/action-bar/FullScreenToggler.tsx (1)
22-26
: The use ofuseCallback
for definingtoggleFullScreen
anduseRecoilState
for managing the fullscreen state is correctly implemented.app/packages/looker-3d/src/fo3d/Leva.tsx (2)
11-11
: The use ofuseRecoilValue
to fetch theisSidebarVisible
state and its application in dynamically adjusting theLevaContainer
styling is well-implemented.
16-16
: Customizing the Leva panel's theme to align with the application's theme and font demonstrates attention to UI consistency and visual integration.app/packages/looker-3d/src/action-bar/ViewHelp.tsx (2)
18-19
: The addition of new items to theLOOKER3D_HELP_ITEMS
array related to toggling grid and full-screen mode is correctly implemented and enhances the help panel's comprehensiveness.
21-21
: TheViewHelp
component is well-structured and effectively uses theuseHelpPanel
hook to toggle the help panel, demonstrating good practices in event handling and component design.app/packages/looker-3d/src/constants.ts (1)
38-41
: The adjustments to the constants for panel order visibility, animations, and lights, including the introduction of new values, are well-thought-out and contribute to optimizing the application's layout and visual hierarchy.app/packages/looker-3d/src/containers.ts (1)
82-85
: The modification to theLevaContainer
styled component to conditionally set theright
CSS property based on theisSidebarVisible
prop is correctly implemented, enhancing the dynamic positioning and responsiveness of the Leva panel.app/packages/looker-3d/src/action-bar/index.tsx (1)
137-140
: The addition of theFullScreenToggler
component to theActionsBar
is correctly implemented, enhancing the ActionBar's functionality with a dedicated control for toggling full-screen mode.
const FullScreenIcon = ({ exit }: { exit: boolean }) => { | ||
const ref = useRef<HTMLDivElement>(); | ||
|
||
useEffect(() => { | ||
if (ref) { | ||
ref.current.innerHTML = ""; | ||
ref.current.appendChild(exit ? fullscreenExit : fullscreen); | ||
} | ||
}, [exit]); | ||
|
||
return <div style={{ display: "flex" }} ref={ref} />; |
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.
Refactor the FullScreenIcon
component to use conditional rendering instead of direct DOM manipulation for better alignment with React best practices.
- const FullScreenIcon = ({ exit }: { exit: boolean }) => {
- const ref = useRef<HTMLDivElement>();
-
- useEffect(() => {
- if (ref) {
- ref.current.innerHTML = "";
- ref.current.appendChild(exit ? fullscreenExit : fullscreen);
- }
- }, [exit]);
-
- return <div style={{ display: "flex" }} ref={ref} />;
- };
+ const FullScreenIcon = ({ exit }: { exit: boolean }) => (
+ <div style={{ display: "flex" }}>
+ {exit ? fullscreenExit : fullscreen}
+ </div>
+ );
This change eliminates the need for useRef
and useEffect
for DOM manipulation, leveraging React's declarative nature for UI updates.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const FullScreenIcon = ({ exit }: { exit: boolean }) => { | |
const ref = useRef<HTMLDivElement>(); | |
useEffect(() => { | |
if (ref) { | |
ref.current.innerHTML = ""; | |
ref.current.appendChild(exit ? fullscreenExit : fullscreen); | |
} | |
}, [exit]); | |
return <div style={{ display: "flex" }} ref={ref} />; | |
const FullScreenIcon = ({ exit }: { exit: boolean }) => ( | |
<div style={{ display: "flex" }}> | |
{exit ? fullscreenExit : fullscreen} | |
</div> | |
); |
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 doesn't work
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.
@sashankaryal, it seems there was an issue locating the icons.ts
file or extracting the implementation details of the fullscreen
and fullscreenExit
icons using the provided script. This could be due to a variety of reasons, such as the file not existing where expected or the icons being imported from an external library that isn't directly accessible in this manner.
Given this, I'd like to suggest a couple of alternative approaches to address the original concern with the FullScreenIcon
component:
-
Verify Icon Import Method: Ensure that the
fullscreen
andfullscreenExit
icons are imported correctly and can be rendered directly in JSX. If these icons are SVGs or React components, they should be able to be included directly within the JSX return statement without needing to manipulate the DOM. -
Alternative Rendering Strategy: If the icons are not directly renderable in JSX (for example, if they are SVG elements stored as strings or files), consider using a method to safely convert them into a format that can be rendered. This could involve using a library or utility function designed for this purpose.
-
Revisit Original Implementation: If direct DOM manipulation is indeed necessary due to the specific requirements or limitations of how these icons are implemented, it may be worth revisiting the original implementation. In such cases, ensuring that the manipulation is done as safely and efficiently as possible within the React component lifecycle is important.
Without direct access to the implementation details of the icons, these suggestions are based on common practices and potential scenarios. If you have more information about how these icons are implemented or if there's a specific error or issue encountered with the suggested refactor, please let me know, and I can provide further assistance.
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Inspect the implementation of the fullscreen and fullscreenExit icons.
fd "icons.ts" app/packages/looker/src --exec cat {}
Length of output: 53
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.
LGTM 🚀
What changes are proposed in this pull request?
Summary by CodeRabbit