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 Primary slot infrastructure and support to Checkbox #20617

Merged
merged 23 commits into from Nov 24, 2021

Conversation

behowell
Copy link
Contributor

Pull request checklist

Description of changes

@behowell behowell requested review from ecraig12345, khmakoto and a team November 15, 2021 20:58
@behowell behowell self-assigned this Nov 15, 2021
@behowell behowell requested a review from a team as a code owner November 15, 2021 20:58
@size-auditor
Copy link

size-auditor bot commented Nov 15, 2021

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 8b8e00f0d0bf82ee665f63bd33a2f314fc1e0e28 (build)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 15, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ea0bd7c:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 15, 2021

📊 Bundle size report

🤖 This report was generated against 8b8e00f0d0bf82ee665f63bd33a2f314fc1e0e28

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 15, 2021

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 853 894 5000
BaseButton mount 874 911 5000
Breadcrumb mount 2388 2374 1000
ButtonNext mount 543 546 5000
Checkbox mount 1398 1474 5000
CheckboxBase mount 1191 1181 5000
ChoiceGroup mount 4150 4175 5000
ComboBox mount 964 942 1000
CommandBar mount 8874 8950 1000
ContextualMenu mount 7474 7403 1000
DefaultButton mount 1061 1079 5000
DetailsRow mount 3416 3352 5000
DetailsRowFast mount 3357 3333 5000
DetailsRowNoStyles mount 3154 3211 5000
Dialog mount 2281 2299 1000
DocumentCardTitle mount 243 240 1000
Dropdown mount 2867 2872 5000
FluentProviderNext mount 3670 3652 5000
FluentProviderWithTheme mount 289 297 10
FluentProviderWithTheme virtual-rerender 194 196 10
FluentProviderWithTheme virtual-rerender-with-unmount 341 370 10
FocusTrapZone mount 1659 1631 5000
FocusZone mount 1741 1659 5000
IconButton mount 1628 1611 5000
Label mount 391 395 5000
Layer mount 2653 2651 5000
Link mount 517 523 5000
MakeStyles mount 1653 1653 50000
MenuButton mount 1362 1337 5000
MessageBar mount 1800 1815 5000
Nav mount 2926 2903 1000
OverflowSet mount 1050 1063 5000
Panel mount 2204 2224 1000
Persona mount 850 809 1000
Pivot mount 1350 1331 1000
PrimaryButton mount 1210 1192 5000
Rating mount 6634 6761 5000
SearchBox mount 1244 1236 5000
Shimmer mount 2322 2229 5000
Slider mount 1767 1775 5000
SpinButton mount 4364 4402 5000
Spinner mount 481 465 5000
SplitButton mount 2798 2776 5000
Stack mount 542 553 5000
StackWithIntrinsicChildren mount 1546 1524 5000
StackWithTextChildren mount 4086 4077 5000
SwatchColorPicker mount 9048 9067 5000
TagPicker mount 2336 2335 5000
TeachingBubble mount 11387 11323 5000
Text mount 466 467 5000
TextField mount 1292 1307 5000
ThemeProvider mount 1135 1119 5000
ThemeProvider virtual-rerender 614 627 5000
ThemeProvider virtual-rerender-with-unmount 1679 1680 5000
Toggle mount 805 829 5000
buttonNative mount 209 224 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
DropdownManyItemsPerf.default 627 579 1.08:1
ChatDuplicateMessagesPerf.default 276 257 1.07:1
AvatarMinimalPerf.default 181 171 1.06:1
FormMinimalPerf.default 363 345 1.05:1
CardMinimalPerf.default 491 473 1.04:1
CarouselMinimalPerf.default 414 399 1.04:1
FlexMinimalPerf.default 261 251 1.04:1
HeaderMinimalPerf.default 315 304 1.04:1
AnimationMinimalPerf.default 362 351 1.03:1
LayoutMinimalPerf.default 323 313 1.03:1
ListNestedPerf.default 486 470 1.03:1
LoaderMinimalPerf.default 597 579 1.03:1
RadioGroupMinimalPerf.default 394 382 1.03:1
AlertMinimalPerf.default 236 231 1.02:1
ButtonMinimalPerf.default 151 148 1.02:1
ChatWithPopoverPerf.default 331 325 1.02:1
DialogMinimalPerf.default 663 647 1.02:1
GridMinimalPerf.default 292 286 1.02:1
ListMinimalPerf.default 445 437 1.02:1
PopupMinimalPerf.default 516 507 1.02:1
RefMinimalPerf.default 213 208 1.02:1
ButtonSlotsPerf.default 478 471 1.01:1
ChatMinimalPerf.default 564 561 1.01:1
CheckboxMinimalPerf.default 2271 2243 1.01:1
InputMinimalPerf.default 1124 1111 1.01:1
ItemLayoutMinimalPerf.default 1026 1014 1.01:1
LabelMinimalPerf.default 326 322 1.01:1
MenuButtonMinimalPerf.default 1387 1374 1.01:1
PortalMinimalPerf.default 159 158 1.01:1
ReactionMinimalPerf.default 331 328 1.01:1
SplitButtonMinimalPerf.default 3654 3630 1.01:1
TableMinimalPerf.default 347 343 1.01:1
TextAreaMinimalPerf.default 422 417 1.01:1
TreeWith60ListItems.default 149 147 1.01:1
AttachmentMinimalPerf.default 134 134 1:1
AttachmentSlotsPerf.default 926 923 1:1
BoxMinimalPerf.default 298 299 1:1
ButtonOverridesMissPerf.default 1442 1442 1:1
DatepickerMinimalPerf.default 4756 4762 1:1
DividerMinimalPerf.default 312 311 1:1
HeaderSlotsPerf.default 636 637 1:1
ListWith60ListItems.default 562 563 1:1
MenuMinimalPerf.default 730 728 1:1
RosterPerf.default 1020 1015 1:1
ProviderMergeThemesPerf.default 1480 1477 1:1
ProviderMinimalPerf.default 968 972 1:1
SkeletonMinimalPerf.default 302 303 1:1
SliderMinimalPerf.default 1421 1419 1:1
StatusMinimalPerf.default 572 572 1:1
TableManyItemsPerf.default 1602 1599 1:1
TextMinimalPerf.default 294 294 1:1
ToolbarMinimalPerf.default 806 805 1:1
TreeMinimalPerf.default 674 675 1:1
AccordionMinimalPerf.default 139 140 0.99:1
DropdownMinimalPerf.default 2561 2582 0.99:1
EmbedMinimalPerf.default 3499 3527 0.99:1
IconMinimalPerf.default 530 533 0.99:1
CustomToolbarPrototype.default 3502 3525 0.99:1
TooltipMinimalPerf.default 879 885 0.99:1
VideoMinimalPerf.default 545 550 0.99:1
ImageMinimalPerf.default 319 326 0.98:1
ListCommonPerf.default 536 553 0.97:1
SegmentMinimalPerf.default 296 304 0.97:1

Copy link
Contributor

@bsunderhus bsunderhus left a comment

Choose a reason for hiding this comment

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

LGTM my only problem is with the early generalization being introduced into react-utilities, and the fact that the names of those methods are too generic for such a specific use case, this might cause a lot of confusion

@@ -68,13 +68,8 @@ export type CheckboxSlots = {
/**
* Checkbox Props
*/
export type CheckboxProps = Omit<ComponentProps<CheckboxSlots>, 'defaultChecked'> &
export type CheckboxProps = Omit<ComponentProps<CheckboxSlots, 'input'>, 'size' | 'checked' | 'defaultChecked'> &
Copy link
Member

Choose a reason for hiding this comment

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

I think for consistency with other fields and to eliminate the native prop overlap issue, we should consider renaming size to fieldSize. That's what I have in Input and plan to do in other input components for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be a good idea, but that's out of scope of this PR. Could you make a PR that makes the change for all input components?

Copy link
Member

Choose a reason for hiding this comment

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

Made an issue for now, #20733

Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Bunch of minor comments but it looks good overall.


export const renderCheckbox = (state: CheckboxState) => {
const { slots, slotProps } = getSlots<CheckboxSlots>(state, checkboxShorthandProps);
const { slots, slotProps } = getSlots<CheckboxSlots>(state, ['root', 'indicator', 'input']);
Copy link
Member

Choose a reason for hiding this comment

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

Mainly just curious, what was the reasoning for removing the checkboxShorthandProps const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only used in one place; it seems unnecessary. Unless it's worthwhile to export it publicly?

Copy link
Member

Choose a reason for hiding this comment

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

I guess I was mainly thinking it could make things a little more self-documenting? Definitely doesn't need to be exported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems straightforward that the argument to the getSlots function is the name of the slots, at least to me.

packages/react-conformance/src/defaultErrorMessages.tsx Outdated Show resolved Hide resolved
packages/react-conformance/src/defaultErrorMessages.tsx Outdated Show resolved Hide resolved
@behowell
Copy link
Contributor Author

@bsunderhus @layershifter @ecraig12345 I've replied to your comments and updated the PR. Could you take another look and sign off if it looks ok? Thanks.

@ecraig12345 ecraig12345 added this to In progress in CXE Redmond - @microsoft/cxe-red via automation Nov 23, 2021
@ecraig12345 ecraig12345 added this to In progress in !!! OLD DO NOT USE!!! v9.0.0 via automation Nov 23, 2021
@behowell behowell merged commit 99adff5 into microsoft:master Nov 24, 2021
23 checks passed
CXE Redmond - @microsoft/cxe-red automation moved this from In progress to Done Nov 24, 2021
!!! OLD DO NOT USE!!! v9.0.0 automation moved this from In progress to Done Nov 24, 2021
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
)

Add support for the primary slot described in RFC [RFC: Customizing application of native element props and ref](https://github.com/microsoft/fluentui/blob/master/rfcs/convergence/native-element-props.md) (microsoft#18983)
*  Add `getPartitionedNativeProps` helper function to make sure the right props go to the right slots
*  Update conformance tests to support primarySlot
*  Update utility types
*  Change Checkbox's primary slot to `input`, and other misc cleanup for Checkbox
@behowell behowell deleted the checkbox-primary-slot branch July 25, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Project: Implement primary slot in Checkbox
7 participants