Skip to content
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

Add Classes/Styles parameters in the BitMessageBox (#9637) #9638

Conversation

Cyrus-Sushiant
Copy link
Member

@Cyrus-Sushiant Cyrus-Sushiant commented Jan 9, 2025

This closes #9637

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced BitMessageBox component with advanced customization options
    • Added support for custom CSS classes and styles for message box elements
  • Improvements

    • Introduced flexible styling capabilities for message box root, content, header, body, and footer
    • Enabled custom button styling for close and OK buttons
  • Documentation

    • Updated demo pages with comprehensive examples of new styling options
    • Added detailed documentation for custom styling techniques

Copy link

coderabbitai bot commented Jan 9, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces enhanced customization capabilities for the BitMessageBox component by adding Classes and Styles properties. These new properties allow developers to apply custom CSS classes and inline styles to various elements of the message box, including the root, content, header, title, spacer, body, footer, and buttons. A new BitMessageBoxClassStyles class has been created to support this functionality, and a demo page has been updated to showcase the new styling options.

Changes

File Change Summary
...MessageBox/BitMessageBox.razor Added dynamic style and class bindings to component elements
...MessageBox/BitMessageBox.razor.cs Introduced Classes and Styles properties with [Parameter] attribute
...MessageBox/BitMessageBoxClassStyles.cs New class for managing custom styles and classes for message box elements
...MessageBoxDemo.razor Added new example demonstrating style and class customization
...MessageBoxDemo.razor.cs Added new parameters and component sub-classes for styling
...MessageBoxDemo.razor.scss Added custom CSS classes for message box styling

Assessment against linked issues

Objective Addressed Explanation
Add Classes/Styles parameters to BitMessageBox
Allow custom classes for different message box elements
Enable inline style customization

Poem

🐰 A message box so sleek and bright,
With styles that dance in pure delight!
Classes and hues, now set with ease,
Customization that's sure to please!
Hop along, design without a care! 🎨

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. (Beta)
  • @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

@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 (8)
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor (1)

3-4: Consider using consistent string interpolation for class bindings.

While the implementation is correct, consider using string interpolation consistently for class bindings. For example:

-<div style="@Styles?.Root" class="bit-msb @Classes?.Root">
+<div style="@Styles?.Root" class="@($"bit-msb {Classes?.Root}")">

This pattern would be more consistent with how class concatenation is typically handled in Blazor components.

Also applies to: 5-6, 8-9, 13-13, 23-23, 27-31

src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs (1)

3-49: LGTM! Well-structured styling class with comprehensive documentation.

The BitMessageBoxClassStyles class provides a clean and well-documented structure for styling customization. Consider for future enhancement:

  • Consider adding an interface (e.g., IBitMessageBoxClassStyles) to allow for different styling implementations or mocking in tests
  • This would enhance testability and allow for future styling strategy implementations
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor (2)

41-59: Consider enhancing the style examples for better maintainability.

While the examples effectively demonstrate both styling approaches, consider these improvements:

  1. Move the gradient background style to a CSS class for better maintainability:
-Styles="@(new() { Root = "background: linear-gradient(180deg, #222444, transparent) #000", OkButton = new() { Root = "border-radius:1rem" } })"
+Classes="@(new() { Root = "gradient-background", OkButton = new() { Root = "rounded-button" } })"
  1. Add comments explaining the styling approaches and their use cases
  2. Consider showing an example combining both Classes and Styles for more complex scenarios

43-43: Fix typo in the example description.

-<div>Customize the appearance of BitActionButton using styles and CSS classes.</div>
+<div>Customize the appearance of BitMessageBox using styles and CSS classes.</div>
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs (1)

68-72: Consider using CSS variables for better maintainability

The inline styles could be moved to CSS variables for better reusability and maintainability.

-    Styles=""@(new() { Root = ""background: linear-gradient(180deg, #222444, transparent) #000"", OkButton = new() { Root = ""border-radius:1rem"" } })"" />
+    Styles=""@(new() { Root = ""background: var(--bit-messagebox-gradient)"", OkButton = new() { Root = ""border-radius:var(--bit-button-radius)"" } })"" />
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss (3)

2-4: Consider using CSS variables for theme colors

Move color values to CSS variables for better theme customization.

-        background: linear-gradient(180deg, #3e0f0f, transparent) #000;
+        background: linear-gradient(180deg, var(--bit-messagebox-gradient-start), transparent) var(--bit-messagebox-background);

6-13: Optimize button styles with CSS variables

Consider using CSS variables for colors and common values.

     .custom-msg-btn {
-        color: #fff;
+        color: var(--bit-button-text-color);
         font-weight: bold;
         border-radius: 1rem;
-        border-color: #8f0101;
+        border-color: var(--bit-button-border-color);
         transition: background-color 1s;
-        background: linear-gradient(90deg, #d10000, transparent) #8f0101;
+        background: linear-gradient(90deg, var(--bit-button-gradient-start), transparent) var(--bit-button-background);
     }

15-20: DRY: Reduce duplicate properties in hover state

Only include properties that actually change in the hover state.

     .custom-msg-btn:hover {
-        color: #fff;
-        font-weight: bold;
-        border-color: #8f0101;
-        background-color: #8f0101;
+        background-color: var(--bit-button-hover-background);
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4dd1bc0 and 2c8d7d2.

📒 Files selected for processing (7)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs (2 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBoxClassStyles.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs (3 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.scss (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (5)
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs (1)

12-15: LGTM! Well-structured parameter additions.

The new Classes and Styles parameters are well-documented and follow consistent naming conventions with existing parameters. The nullable type is appropriate for optional styling properties.

Also applies to: 27-30

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.samples.cs (1)

74-78: LGTM! Good demonstration of class-based styling

The example effectively demonstrates the new Classes property with custom CSS classes, providing a clear pattern for users to follow.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs (3)

14-22: LGTM! Well-documented Classes parameter

The Classes parameter is properly documented with type, default value, and helpful link to detailed styles documentation.


38-45: LGTM! Well-documented Styles parameter

The Styles parameter mirrors the Classes parameter with consistent documentation structure.


55-132: Comprehensive documentation of style customization options

The componentSubClasses documentation thoroughly covers all customizable elements of the BitMessageBox. Good job including links to related button styling documentation.

@msynk msynk merged commit 0bd3ed2 into bitfoundation:develop Jan 9, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Classes/Styles parameters in the BitMessageBox component
2 participants