Skip to content

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Apr 4, 2025

Adding the buttons to the document persisted them when displaying another story.
This was incorrectly done in the HtmlLabel and ScrollBars stories.
Also improve the rendering of the buttons in these stories, and display a description of what they demonstrate.

Summary by CodeRabbit

  • Refactor
    • Improved the layout of interactive examples by grouping control buttons into dedicated sections.
    • Enhanced descriptive text within the demos to provide clearer context and a more consistent user experience.

Adding the buttons to the document persisted them when displaying another story.
This was incorrectly done in the HtmlLabel and ScrollBars stories.
Also improve the rendering of the buttons in these stories, and display a description of what they demonstrate.
@tbouffard tbouffard added the bug Something isn't working label Apr 4, 2025
Copy link

coderabbitai bot commented Apr 4, 2025

Walkthrough

This pull request refactors two Storybook example files by updating their import statements and restructuring the Template functions. In both HtmlLabel.stories.js and Scrollbars.stories.js, the use of the createMainDiv function has been added to create a dedicated container with descriptive text. Additionally, the creation and styling of button elements have been refactored: buttons are now created within their own div instead of being directly appended to the document body. Finally, both Template functions now return the newly created div rather than the original container.

Changes

File(s) Change Summary
packages/html/stories/HtmlLabel.stories.js,
packages/html/stories/Scrollbars.stories.js
- Removed initial block comments describing the examples.
- Updated import statements to include createMainDiv alongside createGraphContainer.
- In the Template functions, a new main div is created using createMainDiv with descriptive text which is then appended to the container.
- Refactored button creation by introducing a separate div to hold the buttons (Undo/Redo or Zoom In/Out) with adjusted styling, and updated the return value to the new div.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant T as Template Function
    participant MDR as createMainDiv()
    participant C as GraphContainer
    participant BD as ButtonDiv

    U->>T: Call Template()
    T->>MDR: Create main div with descriptive text
    MDR-->>T: Return mainDiv
    T->>C: Append mainDiv to container
    T->>BD: Create button container div
    T->>BD: Append styled buttons (Undo/Redo or Zoom In/Out)
    T->>mainDiv: Append button container to mainDiv
    T-->>U: Return mainDiv
Loading

Possibly related PRs

Suggested labels

refactor


📜 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 3c87c30 and a9dad87.

📒 Files selected for processing (2)
  • packages/html/stories/HtmlLabel.stories.js (3 hunks)
  • packages/html/stories/Scrollbars.stories.js (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/html/stories/HtmlLabel.stories.js (1)
packages/html/stories/shared/configure.js (4)
  • createMainDiv (53-63)
  • container (28-28)
  • createGraphContainer (27-37)
  • createGraphContainer (27-37)
🔇 Additional comments (10)
packages/html/stories/HtmlLabel.stories.js (5)

39-39: Good update to the import statement.

Adding createMainDiv import is essential for the refactoring, allowing content to be created with proper structure and description.


54-57: Great addition of descriptive content.

The addition of createMainDiv with a descriptive text enhances the story by explaining its purpose and functionality to users. This provides valuable context about both HTML labels and the undo/redo manager functionality being demonstrated.


59-59: Correct restructuring of DOM hierarchy.

Appending the container to the div instead of using it directly aligns with the goal of containing all elements within a single parent component.


189-197: Fixed button persistence issue.

Creating a dedicated buttons div and appending it to the container rather than the document body properly addresses the core issue where buttons were persisting between stories. This ensures proper cleanup when navigating between stories.


203-203: Appropriate return value modification.

Returning the main div instead of the container ensures that the entire component structure (including buttons) is properly handled in the component lifecycle.

packages/html/stories/Scrollbars.stories.js (5)

47-47: Good update to the import statement.

Adding createMainDiv import is essential for implementing the same structural improvements as in the HtmlLabel story.


112-114: Excellent addition of descriptive content.

Using createMainDiv with descriptive text improves the story by explaining the purpose of the scrollable table example to users.


116-116: Correct restructuring of DOM hierarchy.

Appending the container to the div correctly implements the container pattern consistent with the HtmlLabel story.


562-570: Fixed button persistence issue.

Creating a dedicated buttons div and appending it to the main container properly fixes the issue where zoom buttons were persisting between stories. The consistent styling with margin-top and button spacing enhances the UI.


576-576: Appropriate return value modification.

Returning the main div ensures proper component lifecycle management, allowing the entire structure (including buttons) to be properly cleaned up when switching between stories.

✨ 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 plan to trigger planning for file edits and PR creation.
  • @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.

Copy link

sonarqubecloud bot commented Apr 4, 2025

@tbouffard tbouffard marked this pull request as ready for review April 4, 2025 19:13
@tbouffard tbouffard merged commit 8e5b511 into main Apr 5, 2025
7 checks passed
@tbouffard tbouffard deleted the fix/stories_add_buttons_to_container branch April 5, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant