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

looker 3d improvements #4226

Merged
merged 3 commits into from
Apr 5, 2024
Merged

Conversation

sashankaryal
Copy link
Contributor

@sashankaryal sashankaryal commented Apr 3, 2024

What changes are proposed in this pull request?

  1. Add more items in help panel
  2. Move leva panel to top right

Summary by CodeRabbit

  • New Features
    • Introduced a Full-Screen toggle functionality in the 3D viewer.
    • Updated the Help section with new items related to toggling grid and full-screen mode.
    • Adjusted UI elements and constants for better visibility and user interaction.
  • Refactor
    • Enhanced sidebar visibility control in the 3D viewer application.
  • Chores
    • Improved internal state management for UI components.

@sashankaryal sashankaryal self-assigned this Apr 3, 2024
Copy link
Contributor

coderabbitai bot commented Apr 3, 2024

Walkthrough

The 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

Files Summary
.../FullScreenToggler.tsx, .../ViewHelp.tsx, .../index.tsx Enhanced UI interaction with the introduction of full-screen toggling and updated help items.
.../constants.ts Adjusted values and introduced new constants for UI element ordering.
.../containers.ts, .../fo3d/Leva.tsx Improved container positioning with dynamic CSS based on sidebar visibility, incorporating state management.

🐰✨
In a world of 3D, so vast and free,
A rabbit hopped, with changes, a spree.
Full-screen toggles and help items anew,
Constants adjusted, a UI view.
With every hop, an improvement made,
In the land of code, where magic's displayed.
🌟🐾

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 5.17241% with 55 lines in your changes are missing coverage. Please review.

Project coverage is 28.22%. Comparing base (0502123) to head (4e57db0).
Report is 16 commits behind head on develop.

Files Patch % Lines
...ges/looker-3d/src/action-bar/FullScreenToggler.tsx 0.00% 39 Missing ⚠️
app/packages/looker-3d/src/action-bar/index.tsx 0.00% 5 Missing ⚠️
app/packages/looker-3d/src/action-bar/ViewHelp.tsx 0.00% 4 Missing ⚠️
app/packages/looker-3d/src/fo3d/Leva.tsx 0.00% 4 Missing ⚠️
app/packages/looker-3d/src/containers.ts 0.00% 3 Missing ⚠️
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     
Flag Coverage Δ
app 15.74% <5.17%> (+0.17%) ⬆️
python 99.24% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between e7d2a9a and 4e57db0.
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 of useCallback for defining toggleFullScreen and useRecoilState for managing the fullscreen state is correctly implemented.

app/packages/looker-3d/src/fo3d/Leva.tsx (2)

11-11: The use of useRecoilValue to fetch the isSidebarVisible state and its application in dynamically adjusting the LevaContainer 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 the LOOKER3D_HELP_ITEMS array related to toggling grid and full-screen mode is correctly implemented and enhances the help panel's comprehensiveness.


21-21: The ViewHelp component is well-structured and effectively uses the useHelpPanel 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 the LevaContainer styled component to conditionally set the right CSS property based on the isSidebarVisible 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 the FullScreenToggler component to the ActionsBar is correctly implemented, enhancing the ActionBar's functionality with a dedicated control for toggling full-screen mode.

Comment on lines +8 to +18
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} />;
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 3, 2024

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.

Suggested change
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>
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this doesn't work

Copy link
Contributor

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:

  1. Verify Icon Import Method: Ensure that the fullscreen and fullscreenExit 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.

  2. 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.

  3. 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

Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@sashankaryal sashankaryal merged commit 6b7468a into develop Apr 5, 2024
14 checks passed
@sashankaryal sashankaryal deleted the refactor/looker-3d-improvements branch April 5, 2024 16:42
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.

2 participants