Skip to content

feat(web): support close infobox with button [VIZ-1674] #1617

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

airslice
Copy link
Contributor

@airslice airslice commented May 23, 2025

Overview

Added a close button on infobox UI, close infobox when click it.

What I've done

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features
    • Added a close button to the Infobox, allowing users to dismiss it easily.
  • Style
    • Improved Infobox layout with better content padding and scrolling.
  • Chores
    • Updated Tailwind CSS configuration to streamline file scanning for styles.

@airslice airslice requested a review from mkumbobeaty as a code owner May 23, 2025 10:26
Copy link

netlify bot commented May 23, 2025

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit f8e3925
🔍 Latest deploy log https://app.netlify.com/projects/reearth-web/deploys/68304d6b0742c600082df96e
😎 Deploy Preview https://deploy-preview-1617--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

coderabbitai bot commented May 23, 2025

Walkthrough

The changes introduce a close button to the Infobox component, enabling users to close the infobox via a new optional callback. The Crust component now provides this callback to Infobox, clearing the selected map layer when invoked. Additionally, the Tailwind CSS configuration consolidates content scanning patterns for the Crust feature directory.

Changes

File(s) Change Summary
web/src/beta/features/Visualizer/Crust/Infobox/index.tsx Added optional onCloseInfobox prop, introduced CloseButton component, restructured layout for content and close button.
web/src/beta/features/Visualizer/Crust/index.tsx Added handleCloseInfobox callback to clear layer selection, passed it to Infobox as onCloseInfobox prop.
web/tailwind.config.js Consolidated two Tailwind content globs into a single broader pattern for Crust feature files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Infobox
    participant Crust
    participant MapRef

    User->>Infobox: Click CloseButton
    Infobox->>Crust: onCloseInfobox callback
    Crust->>MapRef: layers.select(undefined)
    MapRef-->>Crust: Layer selection cleared
    Crust-->>Infobox: Infobox closes
Loading

Poem

A button appears, a gentle close,
Infobox now can quietly doze.
With Crust in charge, the layers clear,
Tailwind’s paths are simpler here.
Click and gone, the box takes flight—
Hopping forward, code feels light! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@github-actions github-actions bot requested a review from m-abe-dev May 23, 2025 10:27
@github-actions github-actions bot added the web label May 23, 2025
@airslice airslice changed the title feat(web): support close infobox with button feat(web): support close infobox with button [VIZ-1674] May 23, 2025
Copy link

@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: 0

🧹 Nitpick comments (1)
web/src/beta/features/Visualizer/Crust/Infobox/index.tsx (1)

242-255: Consider conditional rendering for better UX.

The close button currently renders even when onCloseInfobox is undefined, which could be confusing for users. Consider conditionally rendering the button.

const CloseButton: FC<{
  onClick?: () => void;
}> = ({ onClick }) => {
+  if (!onClick) return null;
+  
  return (
    <div className="tw-px-3 tw-pt-3 tw-flex tw-justify-end tw-text-black">
      <div
        className="tw-cursor-pointer tw-w-5 tw-h-5 tw-flex tw-items-center tw-justify-center"
        onClick={onClick}
      >
        <Icon icon="close" />
      </div>
    </div>
  );
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98480b4 and f8e3925.

📒 Files selected for processing (3)
  • web/src/beta/features/Visualizer/Crust/Infobox/index.tsx (5 hunks)
  • web/src/beta/features/Visualizer/Crust/index.tsx (3 hunks)
  • web/tailwind.config.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: ci-server / ci-server-lint
  • GitHub Check: ci-server / ci-server-test
  • GitHub Check: ci-web / ci
  • GitHub Check: Redirect rules - reearth-web
  • GitHub Check: Header rules - reearth-web
  • GitHub Check: Pages changed - reearth-web
🔇 Additional comments (9)
web/src/beta/features/Visualizer/Crust/index.tsx (3)

15-15: LGTM! Proper import for the new callback.

The addition of useCallback to the React imports is necessary for the memoized close handler.


309-311: Well-implemented close handler with proper memoization.

The handleCloseInfobox callback correctly:

  • Uses useCallback for performance optimization
  • Has appropriate dependency on mapRef
  • Clears layer selection by calling select(undefined), which effectively closes the infobox

384-384: Properly connects the close handler to the Infobox component.

The onCloseInfobox prop correctly passes the memoized callback to enable the close button functionality.

web/tailwind.config.js (1)

9-9: Good consolidation of content patterns.

Simplifying the glob patterns to "./src/beta/features/Visualizer/Crust/**/*.{ts,tsx}" effectively covers all files in the Crust directory while reducing configuration complexity.

web/src/beta/features/Visualizer/Crust/Infobox/index.tsx (5)

4-4: LGTM! Required import for the close button icon.

The Icon import is necessary for rendering the close button.


69-69: Well-typed optional prop for close functionality.

The optional onCloseInfobox?: () => void prop is correctly typed and allows the component to work with or without close functionality.


175-199: Excellent layout restructuring with proper separation of concerns.

The new structure effectively separates:

  • Wrapper: Handles positioning and overall container styling
  • CloseButton: Provides close functionality
  • Content: Manages padding and scrolling behavior

This improves maintainability and allows for better control over the infobox layout.


209-220: Good refactoring of wrapper styles.

Removing padding and overflow from the Wrapper and delegating these concerns to the Content component creates a cleaner separation of responsibilities.


222-236: Well-implemented content container with proper scrolling.

The Content component correctly:

  • Maintains the original padding logic
  • Handles overflow with auto scrolling
  • Preserves min/max height constraints
  • Uses appropriate flexbox layout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant