Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BitSpinButton features to BitNumberField (#9973) #10214

Conversation

Cyrus-Sushiant
Copy link
Member

@Cyrus-Sushiant Cyrus-Sushiant commented Mar 9, 2025

This closes #9973

Summary by CodeRabbit

  • New Features

    • Enhanced the numeric input component with configurable options for input visibility, read-only mode, and customizable increment/decrement button titles.
    • Introduced multiple interaction modes (Compact, Inline, Spread) for a more flexible user experience.
  • Style & UI Improvements

    • Refined styling and layout for improved alignment, accessibility, and a consistent look.
  • Demo Enhancements

    • Updated demo content with new examples showcasing varied label positions, modes, and styling customization options.

Copy link

coderabbitai bot commented Mar 9, 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

This update refactors the BitNumberField component and its demo to enhance configurability and styling. In the component, conditional rendering has been introduced to allow for a hidden or visible input based on a new property, while new parameters (like DecrementTitle, IncrementTitle, IsInputReadOnly, and Mode) provide additional configuration options. CSS styles have been updated with renamed and new classes. In the demos, example sections have been reorganized, legacy parameters removed, and new examples added. A related SpinButton demo now accepts a nullable Label value.

Changes

File(s) Change Summary
src/.../NumberField/BitNumberField.razor
src/.../NumberField/BitNumberField.razor.cs
src/.../NumberField/BitNumberFieldClassStyles.cs
Updated component logic: refactored input rendering (hidden/visible based on HideInput), added new parameters (DecrementTitle, IncrementTitle, IsInputReadOnly, Mode), and renamed properties from InputWrapper to InputContainer. Conditional class and event handling updates are included.
src/.../NumberField/BitNumberField.scss Renamed CSS classes (e.g., .bit-nfl-wrp to .bit-nfl-cnt), introduced new classes for layout (e.g., .bit-nfl-ltp, .bit-nfl-lbt, etc.), and adjusted flexbox properties, pseudo-elements, and overall styling.
src/.../NumberField/BitNumberFieldDemo.razor
src/.../NumberField/BitNumberFieldDemo.razor.cs
src/.../NumberField/BitNumberFieldDemo.razor.samples.cs
Reorganized demo content: added a new SubEnums parameter, updated example sections (e.g., adding "Inline", "Spread", and "Compact" modes), removed legacy parameters (InlineLabel, ShowButtons), and provided comprehensive code samples highlighting new configurations.
src/.../SpinButton/BitSpinButtonDemo.razor.cs Changed the Label parameter type from string to nullable string? and updated its default value from an empty string to null, enhancing type flexibility.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant U as User
    participant BNF as BitNumberField
    participant H as HiddenInput
    participant V as VisibleInput
    participant IB as IncrementButton
    participant DB as DecrementButton

    U->>BNF: Render component
    alt HideInput enabled
       BNF->>H: Render hidden input with attributes
    else HideInput disabled
       BNF->>V: Render visible input with focus & change events
       U->>V: Focus on input
       V->>BNF: Trigger input change event
    end
    alt Spin button mode active
       U->>BNF: Click Increment
       BNF->>IB: Process pointer event
       U->>BNF: Click Decrement
       BNF->>DB: Process pointer event
    end

Poem

Oh, I’m a rabbit, hopping through code,
New inputs and buttons lighten my abode.
Hidden or shown, the numbers do sing,
With compact or spread modes, they joyfully spring.
nibble on bugs, my whiskers all a-twirl,
Updated with magic—hop, skip, and swirl!
🐰💻✨


🪧 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.
  • @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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fbca734 and fccc1fc.

📒 Files selected for processing (8)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.razor (5 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.razor.cs (6 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.scss (9 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberFieldClassStyles.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor (8 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor.cs (5 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor.samples.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/SpinButton/BitSpinButtonDemo.razor.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (47)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberFieldClassStyles.cs (1)

65-68: Good property rename for consistency!

The change from InputWrapper to InputContainer improves consistency in terminology throughout the component. The documentation has been appropriately updated to reflect this change.

src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.scss (15)

9-9: Good addition of consistent spacing

Adding column gap at the component level ensures consistent spacing between elements.


20-25: Appropriate class name update

The class has been renamed from .bit-nfl-wrp to .bit-nfl-cnt to match the property rename in the C# class. This maintains consistency between the code and styles.


49-51: Appropriate class name update in error state

Updated the class reference from .bit-nfl-wrp to .bit-nfl-cnt in the invalid state styling.


54-56: Appropriate class name update in focused state

Updated the class reference from .bit-nfl-wrp::after to .bit-nfl-cnt::after for the focus state styling.


68-76: Well-structured label position classes

The new classes for label positioning (.bit-nfl-ltp, .bit-nfl-lbt) use descriptive naming and appropriate flex properties to control layout.


78-84: Well-structured label position classes for inline layouts

The new classes for horizontal label positioning (.bit-nfl-lst, .bit-nfl-led) use consistent naming patterns and appropriate flex properties.


110-119: Appropriate container styling

The class renamed from .bit-nfl-wrp to .bit-nfl-cnt maintains all necessary styling properties for the container.


144-146: Good addition of text centering class

The .bit-nfl-cin class for center-aligned input text supports the new layout options.


154-167: Comprehensive button styles

Updated to include styles for spin buttons (.bit-nfl-sbn), maintaining consistency with existing button styling while extending for new modes.


179-181: Fixed height for upper button

Setting a specific height percentage ensures consistent button sizing in the stacked layout.


184-187: Fixed height for lower button

Setting a specific height percentage ensures consistent button sizing in the stacked layout.


189-191: Good side button styling

The specific width for side buttons (.bit-nfl-sbn) ensures consistent sizing across different modes.


210-213: Good icon sizing for spin buttons

The .bit-nfl-sbi class provides appropriate sizing for the spin button icons.


215-222: Appropriate class name update in pseudo-element

Updated the class reference from .bit-nfl-wrp::after to .bit-nfl-cnt::after for the focus indicator.


252-259: Appropriate class name update in required state

Updated the class reference from .bit-nfl-wrp::before to .bit-nfl-cnt::before for the required indicator.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/SpinButton/BitSpinButtonDemo.razor.cs (1)

123-126: Good enhancement for Label parameter

Making the Label parameter nullable (string? with default value null) improves flexibility by allowing explicit absence of a label, rather than just an empty string.

src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.razor (7)

41-43: Property name update and HideInput integration

  1. Updated style and class attributes to use InputContainer instead of InputWrapper
  2. Added conditional class for hidden input support

These changes properly reflect the updated property names and provide visual support for the hidden input mode.


59-78: Well-implemented Spread mode decrement button

The decrement button in Spread mode is correctly implemented with:

  • Proper event handlers for pointer interactions
  • Accessibility attributes (aria-label, title)
  • Appropriate styling classes
  • Disabled state handling

This provides a good user experience with screen reader support.


80-104: Hidden input implementation

When HideInput is true, a hidden input is rendered with all necessary attributes and ARIA properties, maintaining form functionality while hiding the visual input element.


105-139: Visible input implementation

When HideInput is false, a fully functional visible input is rendered with:

  • Event handlers for focus, blur, key presses and value changes
  • Conditional styling for different modes
  • All necessary accessibility attributes

This provides a complete and accessible number input experience.


141-182: Enhanced Compact mode with accessibility improvements

Added title attributes to buttons for tooltips, improving accessibility for users who hover over controls before interacting with them.


183-220: Well-implemented Inline mode

The new Inline mode places increment and decrement buttons side by side with:

  • Proper event handlers
  • Accessibility attributes
  • Consistent styling classes
  • Appropriate icon handling

This provides another layout option that might be preferable for certain UIs.


221-240: Well-implemented Spread mode increment button

The increment button in Spread mode complements the earlier decrement button, maintaining consistency in implementation and behavior.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor.samples.cs (1)

1-244: Comprehensive demos showcasing BitNumberField capabilities

This new file provides an excellent range of examples that thoroughly demonstrate the BitNumberField component's features. The examples are well-organized, progressing from basic usage to more advanced configurations, and include all the new features like different spin button modes and the HideInput functionality.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor (6)

14-14: Added SubEnums property to DemoPage component

Good addition to display the BitLabelPosition and BitSpinButtonMode enumerations in the demo documentation.


36-42: Updated label position demonstrations

The examples now clearly show all label position options (Top, Start, End, Bottom) with consistent naming.


61-80: Added examples for different SpinButton modes

These examples effectively demonstrate the new Mode property with various configurations (Compact, Inline, Spread) along with custom icon combinations.


143-154: Added HideInput demo section

Good addition showing how to hide the input field while still allowing value changes through spin buttons. This clearly demonstrates the new HideInput feature.


193-222: Enhanced styling examples

The expanded styling section provides comprehensive examples of custom styling through both direct styles and CSS classes, which is helpful for users who need to customize the component's appearance.


224-224: Updated RTL section numbering

Correctly updated the RTL section ID to maintain sequential ordering after adding new sections.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/NumberField/BitNumberFieldDemo.razor.cs (6)

65-71: Added DecrementTitle parameter documentation

Good addition that provides tooltips for the decrement button, enhancing usability and accessibility.


80-85: Added HideInput parameter documentation

Clearly explains the purpose of the new HideInput property for scenarios where only the spin buttons are needed.


115-120: Added IncrementTitle parameter documentation

Matches the DecrementTitle parameter for balanced functionality, providing tooltips for the increment button.


130-139: Added IsInputReadOnly parameter and updated LabelPosition documentation

The IsInputReadOnly property allows greater control over input behavior, and the LabelPosition parameter properly replaces the previous InlineLabel boolean with a more flexible enum.


159-166: Added Mode parameter documentation

Clearly describes the new Mode parameter for controlling spin button rendering, with a helpful link to the enum documentation.


478-478: Added hideInputValue field

Good addition of the backing field for the HideInput example.

src/BlazorUI/Bit.BlazorUI/Components/Inputs/NumberField/BitNumberField.razor.cs (10)

18-18: Added _inputMode field with smart initialization

Good implementation that sets the input mode based on the value type, improving numerical input handling on mobile devices.

Also applies to: 41-41


90-93: Added DecrementTitle parameter

Good addition for improving usability with tooltip on hover for the decrement button.


100-103: Added HideInput parameter

This parameter enables more flexible UI configurations where only the spin buttons are needed.


108-108: Updated IconAriaLabel to be nullable

Good change for better null handling of the aria label.


125-128: Added IncrementTitle parameter

Complements the DecrementTitle parameter for consistent UX on both buttons.


130-133: Added IsInputReadOnly parameter

Useful addition that allows the input to be visible but read-only, enhancing component flexibility.


135-139: Replaced InlineLabel with LabelPosition enum parameter

Good enhancement that provides more flexibility for label positioning beyond just inline/not-inline.


144-144: Updated Label to be nullable

Improves null handling for the label property.


165-168: Added Mode parameter

Important addition that enables different spin button rendering modes (Compact, Inline, Spread).


264-270: Updated RegisterCssClasses method for LabelPosition

Good implementation that applies the appropriate CSS classes based on the LabelPosition enum value.

@msynk msynk merged commit d949ec4 into bitfoundation:develop Mar 12, 2025
3 checks passed
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.

Add BitSpinButton features to BitNumberField
2 participants