Skip to content

Conversation

tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 27, 2025

Previously, the CSS was included programmatically in the document, which is not the best way to add CSS in the storybook
context. In this case, the CSS was added each time the story was rendered, so the CSS definition was added multiple
times

The stories now use external CSS and use imports to include them. This removes the duplicated includes in the DOM and
makes the thing easier to understand by using standard practices.

Notice that the Scrollbars story is still using the former way of including custom CSS.
It is not functional and requires additional work. So, it will be updated later.

Summary by CodeRabbit

  • Style
    • Updated popup menu styling by shifting from inline definitions to external CSS.
    • Introduced a consolidated stylesheet for popup menus, enhancing visual consistency and maintainability.

Previously, the CSS was included programmatically in the document, which is not the best way to add CSS in the storybook
context. In this case, the CSS was added each time the story was rendered, so the CSS definition was added multiple
times

The stories now use external CSS and use imports to include them. This removes the duplicated includes in the DOM and
makes the thing easier to understand by using standard practices.

Notice that the Scrollbars story is still using the former way of including custom CSS.
It is not functional and requires additional work. So, it will be updated later.
@tbouffard tbouffard added the refactor Code refactoring label Feb 27, 2025
Copy link

coderabbitai bot commented Feb 27, 2025

Walkthrough

The changes remove inline CSS definitions and the dynamic creation of a <style> element from two story files. Instead of embedding style rules directly within the TypeScript files, external CSS files are now imported. A new CSS file dedicated to the popup menu styling has been added, and an existing stylesheet has been updated to import these new styles, ensuring that style definitions are centralized and maintained outside the story components.

Changes

File(s) Summary
packages/html/stories/MenuStyle.stories.ts
packages/html/stories/ShowRegion.stories.ts
Removed inline CSS templates and dynamic <style> element creation; replaced with import statements for external CSS files (menu-style.css for the menu and show-region.css for region styles)
packages/html/stories/css/menu-style.css New CSS file added, defining styling for the popup menu including box shadow, borders, font settings, and hover effects
packages/html/stories/css/show-region.css Updated to include an import of menu-style.css so that popup menu styles are integrated

Sequence Diagram(s)

sequenceDiagram
    participant Story as Story File
    participant Browser as Browser
    participant CSS as External CSS File

    Story->>Browser: Load component with style imports
    Browser->>CSS: Request and fetch external stylesheet(s)
    CSS-->>Browser: Return styling rules
    Browser-->>Story: Render component with applied styles
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 82feca0 and e453d4f.

📒 Files selected for processing (4)
  • packages/html/stories/MenuStyle.stories.ts (1 hunks)
  • packages/html/stories/ShowRegion.stories.ts (1 hunks)
  • packages/html/stories/css/menu-style.css (1 hunks)
  • packages/html/stories/css/show-region.css (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/html/stories/css/show-region.css
  • packages/html/stories/MenuStyle.stories.ts
  • packages/html/stories/css/menu-style.css
🔇 Additional comments (1)
packages/html/stories/ShowRegion.stories.ts (1)

47-48: Good approach replacing inline CSS with external stylesheet.

This change correctly implements the PR objective of moving from programmatically included CSS to external files. Importing the styles from an external CSS file avoids duplicate style injections when the story re-renders and improves maintainability by properly separating concerns.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

Copy link

@tbouffard tbouffard marked this pull request as ready for review February 27, 2025 18:28
@tbouffard tbouffard merged commit 890bff4 into main Feb 28, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/story_improve_custom_css_loading branch February 28, 2025 14:14
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