Add new Icon parameter to BitSnackBar (#12172)#12173
Add new Icon parameter to BitSnackBar (#12172)#12173msynk merged 1 commit intobitfoundation:developfrom
Conversation
WalkthroughThe changes introduce support for customizable dismiss icons in BitSnackBar by adding a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Pull request overview
Adds support for customizing BitSnackBar’s dismiss icon via BitIconInfo, enabling external icon libraries (e.g., FontAwesome / Bootstrap Icons) while keeping DismissIconName for built-in Fluent UI icons.
Changes:
- Introduces
DismissIcon: BitIconInfo?toBitSnackBarand renders the effective icon viaBitIconInfo.From(...)(icon takes precedence over icon name). - Adds bUnit coverage for CSS-class icons and helper constructors (
Css,Fa,Bi), plus precedence behavior. - Updates the SnackBar demo/docs to include “External Icons” examples and documents
BitIconInfo.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cs | Adds new DismissIcon parameter to the component API. |
| src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor | Uses BitIconInfo.From(DismissIcon, DismissIconName ?? "Cancel") to render the dismiss icon consistently. |
| src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Notifications/SnackBar/BitSnackBarTests.cs | Adds tests for external icon CSS classes, helper methods, and precedence over DismissIconName. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.samples.cs | Adds/renumbers demo code samples for external dismiss icons. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cs | Documents DismissIcon parameter and adds BitIconInfo sub-class docs + demo backing fields/methods. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor | Adds an “External Icons” demo section showcasing DismissIcon usage. |
.../Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor
Show resolved
Hide resolved
...UI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.samples.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor (1)
124-136: Move external stylesheet<link>tags to<HeadContent>instead of inline body markup.At lines 124 and 135, the FontAwesome and Bootstrap Icons stylesheets should be wrapped in
<HeadContent>(which renders via the configuredHeadOutletin App.razor) rather than placed inline in the component body. This follows Blazor's recommended pattern for page-specific head elements and ensures proper stylesheet lifecycle management.♻️ Suggested refactor
+<HeadContent> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" /> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" /> +</HeadContent> + <DemoExample Title="External Icons" RazorCode="@example5RazorCode" CsharpCode="@example5CsharpCode" Id="example5"> <div> Use icons from external libraries like FontAwesome and Bootstrap Icons with the <b>DismissIcon</b> parameter. </div> @@ - <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" /> @@ - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor` around lines 124 - 136, The two external <link> stylesheet tags currently inline near the BitSnackBar examples (the FontAwesome link before the BitSnackBar with `@ref`="dismissIconFaRef" and the Bootstrap Icons link after the BitSnackBar with `@ref`="dismissIconCssRef") must be moved into a <HeadContent> block instead of the component body; wrap each <link rel="stylesheet" .../> inside <HeadContent>...</HeadContent> in BitSnackBarDemo.razor, remove the inline copies from the markup next to BitSnackBar/BitButton, and keep the BitSnackBar refs and handlers (dismissIconFaRef, dismissIconCssRef, OpenDismissIconFa, OpenDismissIconCss) unchanged so only the stylesheet tags move to the head-managed section.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor`:
- Around line 124-136: The two external <link> stylesheet tags currently inline
near the BitSnackBar examples (the FontAwesome link before the BitSnackBar with
`@ref`="dismissIconFaRef" and the Bootstrap Icons link after the BitSnackBar with
`@ref`="dismissIconCssRef") must be moved into a <HeadContent> block instead of
the component body; wrap each <link rel="stylesheet" .../> inside
<HeadContent>...</HeadContent> in BitSnackBarDemo.razor, remove the inline
copies from the markup next to BitSnackBar/BitButton, and keep the BitSnackBar
refs and handlers (dismissIconFaRef, dismissIconCssRef, OpenDismissIconFa,
OpenDismissIconCss) unchanged so only the stylesheet tags move to the
head-managed section.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: edbb6742-e0ac-498c-b9a9-4672def1adb5
📒 Files selected for processing (6)
src/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razorsrc/BlazorUI/Bit.BlazorUI/Components/Notifications/SnackBar/BitSnackBar.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.cssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Notifications/SnackBar/BitSnackBarDemo.razor.samples.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Notifications/SnackBar/BitSnackBarTests.cs
closes #12172
Summary by CodeRabbit
New Features
DismissIconparameter to customize the dismiss button icon using FontAwesome, Bootstrap Icons, or CSS classes.Documentation
Tests