Add new Icon parameters to BitSwiper (#12225)#12226
Conversation
WalkthroughThe BitSwiper component now supports customizable navigation icons through new parameters. Users can configure icons using either built-in Fluent UI icon names ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor (1)
90-90: Add SRI integrity hashes to external CDN stylesheets, or self-host these assets.Lines 90 and 110 load Font Awesome and Bootstrap Icons from external CDNs without
integrityandcrossoriginattributes. This is a security risk if the CDN is compromised.Options:
- Compute and add SHA-384 integrity hashes using:
curl -s <URL> | openssl dgst -sha384 -binary | openssl base64 -Athen prefix withsha384-- Self-host these CSS files locally
Also apply the same update to the code samples in
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor.cs(lines 249 and 264).🤖 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/Lists/Swiper/BitSwiperDemo.razor` at line 90, The external CDN CSS links in BitSwiperDemo.razor (Font Awesome and Bootstrap Icons) and the corresponding code samples in BitSwiperDemo.razor.cs must include Subresource Integrity and crossorigin attributes or be replaced with locally hosted files; compute each SHA-384 hash with the provided command (curl ... | openssl dgst -sha384 -binary | openssl base64 -A) and add integrity="sha384-<hash>" and crossorigin="anonymous" to the <link> tags, or update the hrefs to point to local copies and remove CDN usage—make the same change in the string literals or markup snippets in BitSwiperDemo.razor.cs so the demo code matches the actual markup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor`:
- Around line 20-21: The fallback logic for icon names in BitSwiper.razor
currently uses the null-coalescing operator (NextIconName ?? "ChevronRight" and
PrevIconName ?? "ChevronRight bit-ico-r180") which doesn't handle empty or
whitespace strings; update the code that builds nextIcon and prevIcon (where
BitIconInfo.From is called) to use a check like
string.IsNullOrWhiteSpace(NextIconName) /
string.IsNullOrWhiteSpace(PrevIconName) and supply the default names only when
the provided name is null/empty/whitespace so empty strings don't bypass the
fallback.
---
Nitpick comments:
In
`@src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor`:
- Line 90: The external CDN CSS links in BitSwiperDemo.razor (Font Awesome and
Bootstrap Icons) and the corresponding code samples in BitSwiperDemo.razor.cs
must include Subresource Integrity and crossorigin attributes or be replaced
with locally hosted files; compute each SHA-384 hash with the provided command
(curl ... | openssl dgst -sha384 -binary | openssl base64 -A) and add
integrity="sha384-<hash>" and crossorigin="anonymous" to the <link> tags, or
update the hrefs to point to local copies and remove CDN usage—make the same
change in the string literals or markup snippets in BitSwiperDemo.razor.cs so
the demo code matches the actual markup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 917e2deb-f265-4e28-8d29-e0764a32ac88
📒 Files selected for processing (6)
src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razorsrc/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor.cssrc/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scsssrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razorsrc/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor.cssrc/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Swiper/BitSwiperTests.cs
There was a problem hiding this comment.
Pull request overview
Adds customizable navigation icons to BitSwiper to support external icon libraries (via BitIconInfo) alongside built-in Fluent UI icon names, and updates the demo/tests accordingly.
Changes:
- Added
NextIcon/PrevIcon(BitIconInfo?) andNextIconName/PrevIconName(string?) parameters toBitSwiperwith defined precedence. - Updated
BitSwiperrendering to resolve icons viaBitIconInfo.From(...)and removed the old CSS-based mirroring approach. - Extended the demo page and added test coverage for icon customization and precedence.
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/Lists/Swiper/BitSwiper.razor.cs | Introduces new icon parameters for next/prev navigation. |
| src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.razor | Uses BitIconInfo.From to render resolved icon classes for nav buttons. |
| src/BlazorUI/Bit.BlazorUI/Components/Lists/Swiper/BitSwiper.scss | Removes the old bit-swp-lbi mirroring rule (rotation now handled via classes). |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor.cs | Documents new parameters, adds BitIconInfo subclass docs, and adds an external-icons sample snippet. |
| src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Lists/Swiper/BitSwiperDemo.razor | Adds an “External Icons” demo section and wires subclasses into DemoPage. |
| src/BlazorUI/Tests/Bit.BlazorUI.Tests/Components/Lists/Swiper/BitSwiperTests.cs | Adds tests for default icon behavior, custom icon rendering, and precedence rules. |
closes #12225
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests