Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Mar 18, 2025

This facilitates maintenance and enables errors to be detected earlier.
Also

  • add a Storybook argument to disable Graph.htmlLabels to show its impact on wrapping and rendering of HTML markup
  • display a description at the top of the Graph to help understand what the story is doing.

Summary by CodeRabbit

  • New Features
    • Introduced a control to toggle HTML labels in graphs, enabling users to choose between HTML-rendered labels and plain text.
    • Enhanced label presentation with improved formatting, including bold text support and better word-wrapping for clearer visualization.

This facilitates maintenance and enables errors to be detected earlier.
Also
  - add a Storybook argument to disable `Graph.htmlLabels` to show its impact on wrapping and rendering of HTML markup
  - display a description at the top of the Graph to help understand what the story is doing.
@tbouffard tbouffard added the refactor Code refactoring label Mar 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

This change updates the Storybook story for graph labels by introducing a new boolean argument, useHtmlLabels, to control the rendering of HTML labels. The Template function’s signature has been modified to explicitly type its arguments as a Record<string, string>. A new div element is created using createMainDiv to include additional descriptive content. Furthermore, the logic for applying HTML labels is updated to conditionally use the provided argument, with enhancements to the edge’s content and style properties.

Changes

File Path Description
packages/html/stories/Wrapping.stories.ts - Added new boolean argument useHtmlLabels (default true) in argTypes and args
- Updated Template signature to use Record<string, string>
- Created a new div via createMainDiv with example description
- Modified the edge value to include <b>bold text</b> and set fontColor to black

Sequence Diagram(s)

sequenceDiagram
    participant S as Storybook
    participant T as Template Function
    participant M as createMainDiv
    participant G as Graph Renderer

    S->>T: Call Template({ ..., useHtmlLabels })
    T->>M: Create main div with description and instructions
    M-->>T: Return div element
    T->>G: Configure graph\n- Set HTML labels using Boolean(args.useHtmlLabels)\n- Update edge with HTML content and style
    G-->>T: Graph configured
    T-->>S: Return populated div for rendering
Loading

Possibly related PRs

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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.
    • 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.

@sonarqubecloud
Copy link

@tbouffard tbouffard marked this pull request as ready for review March 18, 2025 18:15
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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0739244 and fd7e8d0.

📒 Files selected for processing (1)
  • packages/html/stories/Wrapping.stories.ts (2 hunks)
🔇 Additional comments (10)
packages/html/stories/Wrapping.stories.ts (10)

20-20: Import addition looks good.

Adding the createMainDiv import makes sense as it's used to create the descriptive container for the story.


26-29: Good addition of useHtmlLabels control.

Adding this boolean argument allows users to toggle HTML labels support in the story, which aligns with the PR objectives.


33-33: Default argument value is consistent.

Setting the default to true maintains the existing behavior while allowing it to be toggled off.


38-44: Great addition of descriptive content.

The addition of explanatory text at the top of the story helps users understand its purpose and how to use the controls. This improves the documentation aspect of the story.


47-47: Correct DOM structure update.

Appending the container to the new div maintains the proper hierarchy with the added description.


53-53: Dynamic HTML labels configuration implemented correctly.

Using the argument value to control the HTML labels feature works correctly, though the Boolean() conversion could be avoided with proper typing in the function signature.


82-84: Good example of HTML markup in edge label.

Adding the bold text element to the edge label provides a clear demonstration of HTML formatting in labels, which aligns with the story's purpose.


86-89: Style properties properly defined.

Explicitly setting the fontColor to 'black' ensures consistent rendering across different themes or environments.


91-91: TypeScript non-null assertion used appropriately.

The non-null assertion operator (!) is used correctly here since the geometry object should always exist after edge insertion.


94-94: Return value properly updated.

Returning the main div instead of just the container ensures the descriptive content is included in the story output.

@tbouffard tbouffard merged commit 15c50d0 into main Mar 19, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/story_wrapping_migrate_to_ts branch March 19, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant