Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Aug 5, 2025

Link issues

fixes #6546

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Implement a new Toolbar component suite and enhance button lists by adding item templates, border color control, and refined styling

New Features:

  • Add Toolbar component suite (Toolbar, ToolbarItem, ToolbarSeparator, ToolbarSpace, ToolbarButtonGroup) with styles, demo samples, menu entry, localization, and documentation inclusion
  • Enable custom item templates in RadioList and CheckboxList
  • Add ShowButtonBorderColor parameter to RadioList and CheckboxList

Enhancements:

  • Update SCSS for RadioList and CheckboxList to hide adjacent borders and refine disabled/active styles
  • Adjust class builders to conditionally apply borders and background colors based on ShowButtonBorderColor
  • Clarify description for ShowBorder parameter

Documentation:

  • Import Toolbar styles in main components SCSS
  • Add Toolbar to menu and localization resources

Tests:

  • Add bindActive assertion in ButtonTest

@bb-auto bb-auto bot added the enhancement New feature or request label Aug 5, 2025
@bb-auto bb-auto bot added this to the 9.9.0 milestone Aug 5, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 5, 2025

Reviewer's Guide

Implements a new Toolbar UI component (with subcomponents, styling and samples), enhances CheckboxList/RadioList to support custom item templates and optional border coloring with updated styles for seamless button groups, and adds a test assertion to validate two-way binding.

Class diagram for enhanced CheckboxList and RadioList components

classDiagram
    class CheckboxList {
        +bool IsButton
        +bool ShowButtonBorderColor
        +string? CheckboxItemClass
        +bool ShowBorder
        -string? GetButtonItemClassString(SelectedItem item)
    }
    class RadioList {
        +bool ShowButtonBorderColor
        -string? GetButtonItemClassString(SelectedItem item)
    }
Loading

File-Level Changes

Change Details Files
Introduce Toolbar component with subcomponents and integrate into samples, menus and styles
  • Add Toolbar.razor, Toolbar.razor.cs and Toolbar.razor.scss
  • Implement ToolbarItem, ToolbarButtonGroup, ToolbarSeparator and ToolbarSpace components
  • Register Toolbar in MenusLocalizerExtensions and import scss in components.scss
  • Add server sample Toolbars.razor and Toolbars.razor.cs
src/BootstrapBlazor/Components/Toolbar/Toolbar.razor
src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.cs
src/BootstrapBlazor/Components/Toolbar/Toolbar.razor.scss
src/BootstrapBlazor/Components/Toolbar/ToolbarItem.razor
src/BootstrapBlazor/Components/Toolbar/ToolbarItem.razor.cs
src/BootstrapBlazor/Components/Toolbar/ToolbarButtonGroup.razor
src/BootstrapBlazor/Components/Toolbar/ToolbarButtonGroup.razor.cs
src/BootstrapBlazor/Components/Toolbar/ToolbarSeparator.razor
src/BootstrapBlazor/Components/Toolbar/ToolbarSeparator.razor.cs
src/BootstrapBlazor/Components/Toolbar/ToolbarSpace.razor
src/BootstrapBlazor/Components/Toolbar/ToolbarSpace.razor.cs
src/BootstrapBlazor/wwwroot/scss/components.scss
src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs
src/BootstrapBlazor.Server/Components/Samples/Toolbars.razor
src/BootstrapBlazor.Server/Components/Samples/Toolbars.razor.cs
Enhance CheckboxList and RadioList to support custom item templates and optional border coloring with updated styling
  • Add ShowButtonBorderColor parameter and conditional border classes in GetButtonItemClassString
  • Wrap item.Text rendering with ItemTemplate fallback
  • Update scss for transparent borders between buttons and remove redundant styles
src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor
src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.cs
src/BootstrapBlazor/Components/Checkbox/CheckboxList.razor.scss
src/BootstrapBlazor/Components/Radio/RadioList.razor
src/BootstrapBlazor/Components/Radio/RadioList.razor.cs
src/BootstrapBlazor/Components/Radio/RadioList.razor.scss
Add assertion for bindActive in ButtonTest
  • Assert bindActive is true after toggle to validate two-way binding
test/UnitTest/Components/ButtonTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6546 Add a Toolbar component to the project.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Aug 5, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/Toolbars.razor.cs:13` </location>
<code_context>
+/// </summary>
+public partial class Toolbars
+{
+    private readonly List<SelectedItem> _items1 = [];
+    private string _item1 = "1,2";
+
</code_context>

<issue_to_address>
Consider extracting repeated item list creation into a helper method and replacing switch expressions with dictionaries to centralize data and icon mappings.

```csharp
// 1. Extract the repeated item list into a helper
private static List<SelectedItem> CreateDefaultItems() => new()
{
    new("1", "Text1"),
    new("2", "Text2"),
    new("3", "Text3")
};

private readonly List<SelectedItem> _items1 = CreateDefaultItems();
private readonly List<SelectedItem> _items2 = CreateDefaultItems();
private readonly List<SelectedItem> _items3 = CreateDefaultItems();

// 2. Replace switch‐expressions with dictionaries
private static readonly Dictionary<string, string> _alignIcons = new()
{
    ["1"] = "fa-solid fa-align-left",
    ["2"] = "fa-solid fa-align-center",
    ["3"] = "fa-solid fa-align-right"
};

private static readonly Dictionary<string, string> _formatIcons = new()
{
    ["1"] = "fa-solid fa-bold",
    ["2"] = "fa-solid fa-italic",
    ["3"] = "fa-solid fa-font"
};

private static string GetIconByItem(string v)    => _alignIcons[v];
private static string GetRadioIconByItem(string v) => _formatIcons[v];
```

- OnInitialized can now be removed since lists are built at declaration.
- This keeps behavior identical while centralizing both the data and icon mappings.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0b6c36e) to head (663f5a5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #6547      +/-   ##
===========================================
+ Coverage   99.93%   100.00%   +0.06%     
===========================================
  Files         715       721       +6     
  Lines       31471     31519      +48     
  Branches     4444      4449       +5     
===========================================
+ Hits        31451     31519      +68     
+ Misses         15         0      -15     
+ Partials        5         0       -5     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang merged commit 33e2aee into main Aug 5, 2025
7 checks passed
@ArgoZhang ArgoZhang deleted the feat-toolbar branch August 5, 2025 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Toolbar): add Toolbar component

2 participants