Skip to content

Conversation

@msynk
Copy link
Member

@msynk msynk commented Jul 19, 2025

closes #10536

Summary by CodeRabbit

  • New Features
    • Added two new options to the toggle button: preserve foreground color during hover/focus, and display icon only.
  • Style
    • Improved styling for toggle button sizing and icon alignment using CSS variables.
    • Introduced new style variants for fixed color and icon-only modes.
  • Documentation
    • Expanded and reorganized demo page with detailed examples covering all features, including new options, binding, templates, events, sizes, colors, styling, and RTL support.
  • Chores
    • Updated demo code samples and parameter documentation for clarity and completeness.

@msynk msynk requested review from Cyrus-Sushiant and ysmoradi July 19, 2025 09:37
@coderabbitai
Copy link

coderabbitai bot commented Jul 19, 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

Two new parameters, FixedColor and IconOnly, were introduced to the BitToggleButton component, with corresponding CSS classes and SCSS styles to support their functionality. The demo page and code samples were extensively reorganized and expanded to showcase these new features and other aspects of the component, including size, color, binding, templates, and RTL support.

Changes

Files/Paths Change Summary
BitToggleButton.razor.cs Added FixedColor and IconOnly parameters with class logic for new CSS classes reflecting their states.
BitToggleButton.scss Refactored to use CSS variables for sizing and spacing; added .bit-tgb-fxc and .bit-tgb-ntx classes for new features; centralized style control.
BitToggleButtonDemo.razor Major reorganization and expansion: added new demo sections for texts, icons, binding, templates, events, sizes, colors, fixed color, styling, and RTL. Updated and extended sample usages to cover all new and existing features.
BitToggleButtonDemo.razor.cs Added FixedColor and IconOnly to parameter documentation; renamed private fields for clarity.
BitToggleButtonDemo.razor.samples.cs Replaced and expanded code samples to demonstrate new features, more comprehensive usage, and customization scenarios.
BitToggleButtonDemo.razor.scss Updated class selectors for custom templates and classes; moved .custom-template to top-level and adjusted ::deep usage.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BitToggleButton
    participant CSS/SCSS

    User->>BitToggleButton: Set FixedColor or IconOnly parameters
    BitToggleButton->>BitToggleButton: RegisterCssClasses()
    BitToggleButton->>CSS/SCSS: Apply .bit-tgb-fxc or .bit-tgb-ntx classes
    CSS/SCSS-->>BitToggleButton: Style button per parameters
    User->>BitToggleButton: Interact (hover, focus, click)
    BitToggleButton->>CSS/SCSS: Maintain fixed color or icon-only style as needed
Loading

Poem

🐇
Two toggles hop into view—
FixedColor keeps its shade so true,
IconOnly shines with style,
Demos grow and stretch a mile!
With SCSS and samples neat,
This bunny’s work is quite a feat.
Toggle on, with flair anew!

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @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: 1

🧹 Nitpick comments (1)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor (1)

101-160: LGTM: Comprehensive size demonstration

The size section provides thorough coverage of all size variants combined with different button variants and content types. While comprehensive, consider if this level of detail might be overwhelming for users - perhaps a more concise version could be equally effective.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 486341a and 64e861a.

📒 Files selected for processing (6)
  • src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.razor.cs (2 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.scss (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.cs (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.samples.cs (4 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.scss (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build and test
🔇 Additional comments (27)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.scss (2)

8-12: LGTM! Good CSS organization improvement.

The refactoring to move the .custom-template selector outside the ::deep block is a good practice. This improves CSS specificity management and keeps styles that don't need to pierce component boundaries at the appropriate level.


14-68: CSS classes usage verified in demo markup
All custom selectors from the SCSS file—.custom-class, .custom-root, .custom-text, .custom-icon, and .custom-checked—are referenced in the Razor demos (e.g. in BitToggleButtonDemo.razor at lines 290 and 307–310). No missing usages were found, so styling will apply as expected.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.cs (3)

61-66: LGTM! Well-documented parameter addition.

The FixedColor parameter is properly defined with correct type, default value, and clear description explaining its purpose for preserving foreground color through hover and focus states.


75-80: LGTM! Clear parameter definition.

The IconOnly parameter is well-defined with appropriate documentation explaining its role in controlling icon-only rendering and styling adjustments.


391-392: LGTM! Improved field naming for clarity.

The renaming from example51Value/example52Value to twoWayBoundValue/onChangeValue significantly improves code readability by making the purpose of these fields self-evident.

src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.scss (4)

17-18: LGTM! Excellent CSS custom properties implementation.

The refactoring to use CSS custom properties (--bit-tgb-fontsize and --bit-tgb-icn-margin) is a great architectural improvement that enables dynamic styling and better maintainability.


23-23: LGTM! Good accessibility improvement.

Adding pointer-events: none to the disabled state prevents interaction and provides better accessibility behavior.


295-312: LGTM! Consistent size implementation using CSS variables.

The refactoring of size classes to define CSS custom properties instead of direct font-size values creates a consistent and flexible sizing system. The addition of --bit-tgb-ntx-pad and --bit-tgb-ntx-icn-size variables properly supports the new IconOnly feature.


318-326: LGTM! Well-implemented utility classes for new features.

The new utility classes properly implement the FixedColor and IconOnly features:

  • .bit-tgb-fxc preserves text color using the CSS variable
  • .bit-tgb-ntx adjusts padding and removes icon margin for icon-only buttons, with font-size using the icon size variable

The comment about positioning these classes at the end is also helpful for CSS specificity management.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor.samples.cs (4)

36-47: LGTM! Clear binding and event handling examples.

The examples properly demonstrate two-way binding with @bind-IsChecked and event handling with OnChange. The use of the renamed variables (twoWayBoundValue, onChangeValue) improves code clarity.


59-65: LGTM! Good custom template example.

The custom template example effectively demonstrates how to use complex content within the toggle button, including other Bit components like BitIcon and BitRollerLoading.


182-188: LGTM! Excellent demonstration of the new FixedColor feature.

The examples clearly showcase the FixedColor parameter functionality, showing both icon-only and text+icon scenarios. This helps users understand when and how to use this new feature.


275-286: LGTM! Comprehensive RTL support examples.

The RTL examples with Persian text demonstrate proper internationalization support and show how the toggle button behaves in right-to-left layouts.

src/BlazorUI/Bit.BlazorUI/Components/Buttons/ToggleButton/BitToggleButton.razor.cs (4)

48-52: LGTM! Properly implemented FixedColor parameter.

The parameter is correctly defined with appropriate XML documentation, [Parameter, ResetClassBuilder] attributes, and follows the established coding patterns in the component.


59-63: LGTM! Well-defined IconOnly parameter.

The parameter implementation is consistent with component standards and includes clear documentation explaining its purpose for icon-only rendering with style adjustments.


148-148: LGTM! Comprehensive condition for icon-only styling.

The condition correctly applies the bit-tgb-ntx class when either:

  1. There's no child content AND no text properties are set, OR
  2. The IconOnly parameter is explicitly true

This covers both automatic detection of icon-only scenarios and explicit user preference.


150-150: LGTM! Simple and correct FixedColor implementation.

The CSS class registration for FixedColor is straightforward and correctly applies the bit-tgb-fxc class when the parameter is true.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Buttons/ToggleButton/BitToggleButtonDemo.razor (10)

15-18: LGTM: Clean basic example

The basic example effectively demonstrates the simplest usage of BitToggleButton with minimal configuration.


20-34: LGTM: Comprehensive variant demonstration

The variant section effectively showcases all three variants (Fill, Outline, Text) in both enabled and disabled states, providing users with a complete understanding of the available options.


36-43: LGTM: Clear text configuration examples

The text examples clearly demonstrate the different ways to configure button text using both the Text parameter and OnText/OffText parameters.


61-81: LGTM: Comprehensive binding examples

The binding section effectively demonstrates all key binding scenarios: default checked state, two-way binding, and change event handling. The integration with a checkbox for two-way binding visualization is particularly helpful.


83-92: LGTM: Good template customization example

The template example effectively demonstrates the flexibility of custom content within BitToggleButton, showing how multiple components can be combined in a template.


94-99: LGTM: Clear event handling demonstration

The events example effectively demonstrates OnClick event handling with immediate visual feedback through the click counter.


162-267: LGTM: Excellent color variant coverage

The color section provides comprehensive coverage of all available color variants across different button variants. The special styling for background colors is well-implemented and helps users understand how these colors work in different contexts.


269-279: LGTM: Good demonstration of new FixedColor feature

The FixedColor section effectively demonstrates the new parameter's functionality in preserving foreground color during hover and focus states. The examples with both icon-only and icon+text combinations provide good coverage.


281-312: LGTM: Comprehensive styling demonstration

The styling section effectively demonstrates both component-level styling through Style/Class properties and granular styling through the Styles/Classes parameters. The examples provide practical guidance for customization scenarios.


314-330: LGTM: Effective RTL demonstration

The RTL section effectively demonstrates right-to-left support with authentic Arabic text across all three button variants. The consistent parameter ordering enhances readability.

@msynk msynk merged commit cd50327 into bitfoundation:develop Jul 19, 2025
3 checks passed
@msynk msynk deleted the 10536-blazorui-togglebutton-missing-features branch July 19, 2025 17:10
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 BitToggleButton is missing some important UI features

2 participants