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

[dev-v5] Add checkbox component #3223

Merged

Conversation

AClerbois
Copy link
Contributor

@AClerbois AClerbois commented Jan 21, 2025

[dev-v5] Add checkbox component

A FluentCheckbox component enables a user to select or deselect an option. It's typically used to capture a boolean value.

To define the indeterminate state, you need to use the CheckState bindable property, which has three possible values: null, true and false.

{67D89301-BC8F-49EA-BBF7-EB4E14421A88}

Unit Tests

Updated

@AClerbois AClerbois changed the title Users/aclerbois/dev v5/fluentcheckbox [dev-v5] Add checkbox component Jan 22, 2025
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/fluentcheckbox branch 3 times, most recently from d4d01fc to a7bc5aa Compare January 22, 2025 17:14
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/fluentcheckbox branch from a3d905c to 7ffc94d Compare January 26, 2025 17:13
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/fluentcheckbox branch from 99c37b7 to b5aabc5 Compare February 7, 2025 09:58
Update CheckboxThreeStates and FluentCheckbox components

Updated CheckboxThreeStates.razor to include additional FluentCheckbox components and modify existing ones. Renamed variables and added new ones in the @code section. Modified OnInitializedAsync and SetCheckStateChangedAsync methods in FluentCheckbox.razor.cs to handle value changes more effectively.

WIP

Add unit testing
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/fluentcheckbox branch from 65e7787 to 24d438a Compare February 10, 2025 16:48
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/fluentcheckbox branch 2 times, most recently from 291c855 to 7152011 Compare February 10, 2025 17:29
AClerbois and others added 6 commits February 10, 2025 18:38
Updated FluentCheckbox.md to clarify indeterminate state usage, including `CheckState` property and `ShowIndeterminate` attribute. Changed error handling in FluentCheckbox.razor.cs to throw `ArgumentOutOfRangeException` for invalid boolean values. Simplified `SetCheckStateChangedAsync` method using null-coalescing operator.
Updated FluentCheckbox component:
- Added properties: CheckState (nullable bool), Shape (default: Square), Size (default: Medium)
- Removed and redefined properties: Shape, CheckState, Size
- Added TryParseValueFromString method throwing NotSupportedException
- Added InternalTryParseValueFromString method for parsing logic
- Updated SetCheckStateChangedAsync to remove equality check

Testing updates:
- Added FluentCheckbox_TryParseValueFromString test
- Refactored existing tests for readability and maintainability
- Removed unused test FluentCheckbox_ToTextInputAppearance
Replaced `cut.MarkupMatches` with `cut.Verify` in `FluentCheckboxTests.razor` to simplify assertions. Updated verified HTML files to include expected markup for various `FluentCheckbox` configurations, ensuring accurate comparisons in tests.
This commit removes the `StartTemplate` and `EndTemplate` parameters and their associated rendering logic from the `FluentCheckbox` component. Changes include:
- Deleting the `StartTemplate` and `EndTemplate` properties from `FluentCheckbox.razor.cs`.
- Removing the conditional rendering of `StartTemplate` and `EndTemplate` in `FluentCheckbox.razor`.
- Updating the closing tag of the `fluent-checkbox` element to be self-closing.
- Removing the test case `FluentCheckbox_StartEndTemplate` from `FluentCheckboxTests.razor`.
- Deleting the corresponding verification HTML for the removed test case in `FluentCheckboxTests.FluentCheckbox_StartEndTemplate.verified.razor.html`.
@dvoituron dvoituron marked this pull request as ready for review February 11, 2025 10:27
@dvoituron dvoituron requested a review from vnbaaij as a code owner February 11, 2025 10:27
dvoituron and others added 2 commits February 11, 2025 12:12
Replaced <fluent-label> with <label> in FluentCheckbox tests.
Added Blazor-specific attributes to <fluent-checkbox>.
Fixed rendering syntax in FluentCheckbox_LabelTemplate test.
@dvoituron dvoituron merged commit 417dd11 into microsoft:dev-v5 Feb 11, 2025
3 checks passed
@AClerbois AClerbois deleted the users/aclerbois/dev-v5/fluentcheckbox branch February 11, 2025 12:02
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.

2 participants