Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 26, 2025

CellRenderer now provides 2 protected methods for deciding how to create the overlay shape and for configuring it (usually to configure the DOM node linked to the shape).

The overlay story has been modified to demonstrate how to use the new customization capabilities.
It is now also written in TypeScript for ease of maintenance.

Also improve JSDoc of CellMarker and CellTracker.

Notes

Closes #28

PR_696_custom_overlays.webm

Tasks

  • add GIF or video about the new Story
  • integrate review feedback

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced an interactive overlay demonstration with refined visual effects, animated styling, intuitive toggling, and responsive tooltips.
    • Added a new Storybook story for overlays, showcasing user interactions and custom configurations.
  • Refactor

    • Streamlined overlay creation and configuration to support smoother and more consistent user interactions.
  • Documentation

    • Enhanced user guidance with updated descriptions detailing overlay behaviors and interaction cues.
    • Improved clarity and consistency in comments and documentation across various components.

CellRenderer` now provides 2 protected methods for deciding how to create the overlay shape and for configuring it (usually to configure the DOM node linked to the shape).

The overlay story has been modified to demonstrate how to use the new customization capabilities.
It is now also written in TypeScript for ease of maintenance.
@tbouffard tbouffard added the enhancement New feature or request label Feb 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

This pull request introduces refactorings and documentation updates across multiple modules. In the core view components, the constructor in the cell marker class is renamed and its documentation improved. The overlay creation logic in the cell renderer is refactored by extracting shape creation and configuration into separate methods, with enhanced JSDoc comments. The cell tracker’s comments are also updated for clarity. Additionally, the Storybook configuration for overlays is reworked by removing the old JavaScript version and introducing a new TypeScript version along with a dedicated CSS file for custom overlay styling.

Changes

File(s) Change Summary
packages/core/.../CellMarker.ts Renamed constructor from mxCellMarker to CellMarker, updated event reference (mxEvent.MARKInternalEvent.MARK), and enhanced documentation with @default annotations and {@link} references.
packages/core/.../CellRenderer.ts Refactored createCellOverlays method; added createOverlayShape and configureOverlayShape methods to modularize overlay creation and configuration; improved JSDoc comments.
packages/core/.../CellTracker.ts Updated documentation and code comments to correctly reference CellTracker and clarify event handling, with no changes to underlying functionality.
packages/html/stories/Overlays.stories.js Removed the old Storybook configuration file for overlays.
packages/html/stories/Overlays.stories.ts Added a new TypeScript Storybook story file for overlays, featuring a Template function, custom renderer, event handling for clicks/double-clicks, and integrated configuration for interactive overlays.
packages/html/stories/css/overlays.css Introduced a new CSS file defining custom overlay styles, including a root variable, styling for SVG ellipses, and keyframe animations (pulse effect).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Graph
    participant Renderer
    participant Overlay

    User->>Graph: Click event on cell
    Graph->>Renderer: Invoke createCellOverlays()
    alt Overlay exists
        Renderer->>Graph: Add existing overlay
    else No overlay exists
        Renderer->>Renderer: Call createOverlayShape()
        Renderer->>Renderer: Call configureOverlayShape()
        Renderer->>Graph: Add new overlay to cell
    end
    User->>Graph: Double-click event on cell
    Graph->>Graph: Display alert with cell information
Loading

Suggested labels

documentation


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0f4088 and d9f3023.

📒 Files selected for processing (1)
  • packages/html/stories/Overlays.stories.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/html/stories/Overlays.stories.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (macos-14)
  • GitHub Check: build
  • GitHub Check: build (ubuntu-22.04)

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>, please review it.
    • 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 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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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

CodeRabbit Configuration 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/schema.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.

@tbouffard tbouffard marked this pull request as ready for review February 26, 2025 16:09
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 (2)
packages/html/stories/css/overlays.css (1)

11-22: Animation implementation is clean but comments are inconsistent with values.

The pulse animation is well-defined, but there's a mismatch between the comments and the actual values used for opacity.

    0% {
        fill-opacity: 100%;
-        /* 80% opacity */
+        /* 100% opacity */
        filter: drop-shadow(0 0 0 rgba(0, 0, 0, .8));
    }
    100% {
        fill-opacity: 90%;
-        /* 100% opacity */
+        /* 90% opacity */
        filter: drop-shadow(0 0 .5rem rgba(0, 0, 0, 1));
    }
packages/html/stories/Overlays.stories.ts (1)

116-123: Consider adding more randomness options for overlays.

The current implementation only randomizes alignment, but you could also randomize other properties like size, color, or animation parameters to showcase more customization possibilities.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0182e55 and c0f4088.

📒 Files selected for processing (6)
  • packages/core/src/view/cell/CellMarker.ts (12 hunks)
  • packages/core/src/view/cell/CellRenderer.ts (3 hunks)
  • packages/core/src/view/cell/CellTracker.ts (3 hunks)
  • packages/html/stories/Overlays.stories.js (0 hunks)
  • packages/html/stories/Overlays.stories.ts (1 hunks)
  • packages/html/stories/css/overlays.css (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/html/stories/Overlays.stories.js
✅ Files skipped from review due to trivial changes (1)
  • packages/core/src/view/cell/CellTracker.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-2022)
🔇 Additional comments (14)
packages/html/stories/css/overlays.css (2)

1-3: Effective use of CSS variables for theming.

The CSS variable for the ellipse color is well-defined and follows best practices by using the root scope.


5-9: Good implementation of the overlay styling.

The overlay class selector is appropriately targeting ellipse elements and effectively applies the CSS variable for consistent styling.

packages/core/src/view/cell/CellMarker.ts (4)

44-56: Documentation improvements follow best practices.

The updated code example and event documentation enhance readability and maintainability.


66-83: Property documentation enhanced with @default annotations.

Adding default annotations improves developer experience by making default values explicit in the documentation.


101-109: Improved property documentation with consistent syntax.

The use of consistent {@link CellState} syntax for property documentation improves clarity.


113-120: Comprehensive constructor documentation.

The detailed parameter descriptions in the constructor documentation greatly improve usability and understanding of the class.

packages/core/src/view/cell/CellRenderer.ts (3)

469-482: Good refactoring of overlay creation logic.

The code has been refactored to improve readability and maintainability by extracting the overlay shape creation and configuration into separate methods. The early continue pattern helps reduce nesting and improve code flow.


492-503: Well-designed extraction of shape creation logic.

The new createOverlayShape method effectively encapsulates the logic for creating overlay shapes, enabling subclasses to customize the shape creation process. The JSDoc is comprehensive and includes the @since tag to indicate when this method was introduced.


557-575: Excellent design for the configureOverlayShape method.

This method provides a clean extension point for customizing overlay shapes. The detailed JSDoc explains the purpose and default implementation clearly. The method effectively separates the configuration concerns from the creation logic.

packages/html/stories/Overlays.stories.ts (5)

18-38: Well-organized imports with clear documentation.

The imports are logically grouped and include the necessary types and components. The comment about CSS requirement is helpful for understanding dependencies.


72-96: Excellent example of extending the CellRenderer.

The CustomCellRenderer class demonstrates how to use the newly added protected methods to customize overlay shapes. The implementation is clean and shows multiple customization approaches:

  1. Creating different shape types based on a counter
  2. Adding CSS classes to the DOM node
  3. Storing additional data attributes

This serves as a good reference for users wanting to implement custom overlays.


98-114: Good pattern for renderer customization.

The CustomGraph class effectively overrides the factory method to use the custom renderer, demonstrating a clean way to extend the Graph class without modifying its core functionality.


125-154: Well-implemented event handling for overlays.

The click event handler for toggling overlays is well-structured and demonstrates both adding and removing overlays. The use of random positioning shows flexibility in overlay placement.


169-209: Good demonstration of graph setup with various cell types.

The batch update pattern is properly used, and the demo includes both vertices and edges with different shapes, providing a comprehensive example of overlay usage.

@tbouffard tbouffard marked this pull request as draft February 27, 2025 08:57
@tbouffard tbouffard marked this pull request as ready for review February 27, 2025 13:07
@sonarqubecloud
Copy link

@tbouffard tbouffard merged commit c0b8436 into main Feb 28, 2025
7 checks passed
@tbouffard tbouffard deleted the feat/28-support_custom_overlay_shapes branch February 28, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have the possibility to change the shape of an overlay

1 participant