Skip to content

Add BitMessageBox component (#9624)#9629

Merged
msynk merged 5 commits intobitfoundation:developfrom
msynk:9624-blazorui-extras-messagebox
Jan 8, 2025
Merged

Add BitMessageBox component (#9624)#9629
msynk merged 5 commits intobitfoundation:developfrom
msynk:9624-blazorui-extras-messagebox

Conversation

@msynk
Copy link
Member

@msynk msynk commented Jan 6, 2025

closes #9624

Summary by CodeRabbit

  • New Features

    • Introduced BitMessageBox component for displaying message boxes in Blazor applications
    • Added customizable message box with title, body, and configurable buttons
    • Implemented responsive styling for message box component
  • Documentation

    • Added demo page for MessageBox component
    • Updated navigation to include MessageBox in Extras section
  • Styles

    • Created new SCSS styles for MessageBox component
    • Added responsive design for different screen sizes

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 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 a new BitMessageBox component to the Blazor UI library. This component is a versatile message display mechanism that can be used standalone or within modals. It provides a structured layout with a header, body, and footer, allowing customization of title, content, and button text. The implementation includes a Razor component, a corresponding code-behind file, and accompanying SCSS styles. A demo page is also created to showcase the component's usage, and navigation items are updated to provide easy access to the new component.

Changes

File Change Summary
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor New Blazor component with structured layout for message box
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs New partial class with customizable parameters and event handling
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.scss New stylesheet defining layout and responsive styles for message box
src/BlazorUI/Bit.BlazorUI.Extras/Styles/components.scss Added import for new MessageBox styles
src/BlazorUI/Demo/Client/...MessageBoxDemo.razor New demo page showcasing MessageBox component usage
src/BlazorUI/Demo/Client/...MessageBoxDemo.razor.cs Supporting code-behind for demo page with example implementations
src/BlazorUI/Demo/Client/...ComponentsSection.razor Added navigation link for MessageBox component
src/BlazorUI/Demo/Client/...MainLayout.razor.NavItems.cs Added MessageBox to navigation items

Assessment against linked issues

Objective Addressed Explanation
Add MessageBox component to BlazorUI

Poem

🐰 A message box hops into view,
With style and grace, both sleek and new,
Bits of wisdom, neatly displayed,
A UI component, expertly made!
Blazor rejoices, the rabbit's delight! 🎉


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: 2

🧹 Nitpick comments (7)
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor (2)

10-13: Consider adding an accessible label for the close button.
Currently, the close button relies solely on an icon. For improved accessibility, you could add an "aria-label" or incorporate text that screen readers can interpret.

 <BitButton OnClick="CloseModal"
            IconName="ChromeClose"
+           AriaLabel="Close message box"
            Color="BitColor.Tertiary"
            Variant="BitVariant.Text" />

21-23: Consider enabling localization for the Ok button text.
Hardcoding "Ok" is fine for demos, but in production scenarios, provide a localization key so that users can translate it.

src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs (2)

20-20: Use EventCallback instead of Action for improved async support in Blazor.
Action? works for synchronous callbacks, but switching to EventCallback or EventCallback<T> could future-proof for asynchronous operations.

-[Parameter] public Action? OnClose { get; set; }
+[Parameter] public EventCallback OnClose { get; set; }

29-32: Rename method to better reflect component context.
The method name CloseModal might be confusing if this component is also used outside of a modal context. Consider using something like CloseMessageBox.

-private void CloseModal()
+private void CloseMessageBox()
 {
     OnClose?.Invoke();
 }
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor (1)

19-26: Confirm modal usage in more complex scenarios.
Demonstrating usage inside a basic modal is helpful. Consider adding a more complex scenario, such as passing dynamic content to the message box or handling asynchronous confirm/cancel flows.

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

38-42: Consider raising an event instead of calling StateHasChanged directly.

While directly calling StateHasChanged() is a simple approach for re-rendering, for more complex scenarios it may be beneficial to raise a local UI event or use an event callback, providing consumers with better control over execution flow.

src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.scss (1)

5-13: Consider adding a fallback for max-height.

While using $bit-env-height-available is good for modern browsers, consider adding a fallback value for better browser compatibility.

 .bit-msb {
     padding: spacing(2);
     min-width: spacing(40);
-    max-height: $bit-env-height-available;
+    max-height: $bit-env-height-available;
+    max-height: 100vh; /* Fallback for older browsers */

     @include lt-md {
         min-width: unset;
     }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d7b7c4 and 53f3d31.

📒 Files selected for processing (10)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor.cs (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.scss (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Styles/components.scss (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/MessageBox/BitMessageBoxDemo.razor.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Home/ComponentsSection.razor (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/LoadingComponent.razor (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor.NavItems.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/compilerconfig.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (17)
src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.razor (1)

1-2: Namespace selection looks consistent.
Declaring the component under Bit.BlazorUI aligns with the rest of the codebase and maintains a clean, predictable namespace structure.

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

1-2: Great addition of a dedicated demo page.
Having a distinct route makes it easier for consumers to understand and try the component.

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

1-4: Namespace and class structure look good.

Well-structured partial class declaration. The file naming convention aligns well with the component name "BitMessageBoxDemo".


5-35: Parameter definitions are comprehensive and well-organized.

The list of parameters covers essential fields like Body, OkText, OnClose, and Title. The usage of List<ComponentParameter> provides clarity and expandability for future parameters.


44-55: Usage of BitModalService is well-integrated.

The ShowMessageBox() method demonstrates a clear approach to instantiating and displaying the BitMessageBox via the modal service. Adopting dictionary-based parameters is a flexible way to parameterize the message box.


59-62: Clean demonstration code snippet.

This snippet shows a straightforward usage example of BitMessageBox without additional overhead, making it easy for newcomers to replicate.


64-68: Modal usage example is appropriate.

Embedding BitMessageBox within <BitModal> exemplifies a typical scenario. This snippet is concise and effectively highlights how the component can be reused in modals.


69-74: Complementary C# snippet is coherent.

Mirroring the code-behind side, this snippet ensures clarity for developers who want to replicate the same approach in their own components.


76-78: Method invocation snippet is straightforward.

It cleanly demonstrates how a single button click triggers the ShowMessageBox() method.


79-91: C# snippet effectively captures the modal pattern.

The snippet parallels the code used in the class, helping users understand how to integrate the message box with the modal service in a real-world scenario.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor.NavItems.cs (1)

156-156: New navigation entry is consistent with existing structure.

This addition to the "Extras" section seamlessly follows the established pattern, making the MessageBox easy to discover in the nav menu.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Home/ComponentsSection.razor (1)

256-258: Link addition properly showcases the new component.

The “MessageBox” link in the “Extras” section clearly directs users to the demo page, maintaining the consistent style of the existing links.

src/BlazorUI/Bit.BlazorUI.Extras/Styles/components.scss (1)

5-5: Import statement correctly references the new MessageBox styles.

This line ensures that the BitMessageBox component’s SCSS is bundled appropriately with other component styles, preserving visual consistency.

src/BlazorUI/Bit.BlazorUI.Extras/Components/MessageBox/BitMessageBox.scss (3)

1-3: LGTM! Imports are well-organized.

The imports follow a logical order and include all necessary dependencies for styling.


15-35: LGTM! Container and header styles are well-structured.

The flex layouts are appropriately used with consistent spacing and proper box model settings.


50-58: LGTM! Footer styles are well-implemented.

The footer styling properly implements centering and maintains consistency with other sections.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/compilerconfig.json (1)

74-79: LGTM! Configuration entry is consistent.

The new configuration entry for BitMessageBoxDemo follows the established pattern and maintains consistency with other demo components.

@msynk msynk merged commit 4dd1bc0 into bitfoundation:develop Jan 8, 2025
@msynk msynk deleted the 9624-blazorui-extras-messagebox branch January 8, 2025 08:50
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.

The BlazorUI is missing a MessageBox component

3 participants