Skip to content

react-divider: use simplified prop merging#19960

Merged
bsunderhus merged 2 commits intomicrosoft:masterfrom
bsunderhus:react-divider-prop-merging-migration
Sep 24, 2021
Merged

react-divider: use simplified prop merging#19960
bsunderhus merged 2 commits intomicrosoft:masterfrom
bsunderhus:react-divider-prop-merging-migration

Conversation

@bsunderhus
Copy link
Contributor

Pull request checklist

Description of changes

Use simple prop merging as described in #19678

@bsunderhus bsunderhus requested review from a team September 24, 2021 12:41
@bsunderhus bsunderhus self-assigned this Sep 24, 2021
@bsunderhus bsunderhus enabled auto-merge (squash) September 24, 2021 12:46
@fabricteam
Copy link
Collaborator

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-divider
Divider
15.032 kB
5.463 kB
15.428 kB
5.595 kB
-396 B
-132 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
164.716 kB
46.962 kB
react-components
react-components: FluentProvider & webLightTheme
35.77 kB
11.405 kB
🤖 This report was generated against f1f30260e73cd4dd503ae4b765aa2927536db7ca

@codesandbox-ci
Copy link

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 85bec56:

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

@size-auditor
Copy link

size-auditor bot commented Sep 24, 2021

Asset size changes

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

Baseline commit: 1e9745be86f2425bc81f55ab85daee751aac297d (build)

@fabricteam
Copy link
Collaborator

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 905 931 5000
BaseButton mount 911 916 5000
Breadcrumb mount 2653 2669 1000
ButtonNext mount 447 452 5000
Checkbox mount 1497 1526 5000
CheckboxBase mount 1279 1315 5000
ChoiceGroup mount 4863 4846 5000
ComboBox mount 1110 1018 1000
CommandBar mount 10343 10366 1000
ContextualMenu mount 6611 6621 1000
DefaultButton mount 1137 1133 5000
DetailsRow mount 3814 3780 5000
DetailsRowFast mount 3866 3809 5000
DetailsRowNoStyles mount 3534 3506 5000
Dialog mount 2446 2481 1000
DocumentCardTitle mount 133 152 1000
Dropdown mount 3353 3255 5000
FluentProviderNext mount 7410 7418 5000
FluentProviderWithTheme mount 350 378 10
FluentProviderWithTheme virtual-rerender 101 95 10
FluentProviderWithTheme virtual-rerender-with-unmount 501 502 10
FocusTrapZone mount 1891 1853 5000
FocusZone mount 1832 1803 5000
IconButton mount 1779 1737 5000
Label mount 350 345 5000
Layer mount 3045 3005 5000
Link mount 475 471 5000
MakeStyles mount 1862 1891 50000
MenuButton mount 1518 1492 5000
MessageBar mount 2059 2028 5000
Nav mount 3358 3439 1000
OverflowSet mount 1141 1136 5000
Panel mount 1387 2347 1000
Persona mount 886 841 1000
Pivot mount 1419 1479 1000
PrimaryButton mount 1297 1273 5000
Rating mount 7698 7761 5000
SearchBox mount 1316 1347 5000
Shimmer mount 2629 2604 5000
Slider mount 1965 2019 5000
SpinButton mount 5041 5009 5000
Spinner mount 417 429 5000
SplitButton mount 3187 3208 5000
Stack mount 510 520 5000
StackWithIntrinsicChildren mount 1726 1738 5000
StackWithTextChildren mount 4670 4674 5000
SwatchColorPicker mount 10620 10454 5000
Tabs mount 1465 1430 1000
TagPicker mount 2700 2673 5000
TeachingBubble mount 13491 13423 5000
Text mount 419 420 5000
TextField mount 1411 1431 5000
ThemeProvider mount 1241 1214 5000
ThemeProvider virtual-rerender 605 623 5000
ThemeProvider virtual-rerender-with-unmount 1921 1902 5000
Toggle mount 857 806 5000
buttonNative mount 118 118 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ButtonMinimalPerf.default 183 164 1.12:1
ChatMinimalPerf.default 706 651 1.08:1
HeaderMinimalPerf.default 385 357 1.08:1
ListNestedPerf.default 578 539 1.07:1
TextMinimalPerf.default 362 339 1.07:1
AvatarMinimalPerf.default 196 185 1.06:1
GridMinimalPerf.default 358 337 1.06:1
RefMinimalPerf.default 248 235 1.06:1
DialogMinimalPerf.default 793 758 1.05:1
LayoutMinimalPerf.default 383 366 1.05:1
SegmentMinimalPerf.default 365 346 1.05:1
SkeletonMinimalPerf.default 366 350 1.05:1
AttachmentMinimalPerf.default 168 161 1.04:1
FormMinimalPerf.default 400 385 1.04:1
HeaderSlotsPerf.default 785 753 1.04:1
ListWith60ListItems.default 672 648 1.04:1
TextAreaMinimalPerf.default 509 491 1.04:1
ToolbarMinimalPerf.default 967 929 1.04:1
AnimationMinimalPerf.default 416 402 1.03:1
RadioGroupMinimalPerf.default 454 440 1.03:1
ReactionMinimalPerf.default 385 373 1.03:1
TableManyItemsPerf.default 1949 1892 1.03:1
ButtonSlotsPerf.default 579 566 1.02:1
CarouselMinimalPerf.default 481 471 1.02:1
ChatDuplicateMessagesPerf.default 313 306 1.02:1
DropdownMinimalPerf.default 3265 3188 1.02:1
LoaderMinimalPerf.default 720 706 1.02:1
SliderMinimalPerf.default 1748 1708 1.02:1
StatusMinimalPerf.default 696 683 1.02:1
IconMinimalPerf.default 633 622 1.02:1
TooltipMinimalPerf.default 1054 1029 1.02:1
TreeMinimalPerf.default 804 790 1.02:1
AccordionMinimalPerf.default 165 163 1.01:1
AttachmentSlotsPerf.default 1096 1089 1.01:1
DropdownManyItemsPerf.default 691 685 1.01:1
MenuButtonMinimalPerf.default 1674 1660 1.01:1
SplitButtonMinimalPerf.default 4294 4232 1.01:1
TableMinimalPerf.default 419 414 1.01:1
VideoMinimalPerf.default 645 638 1.01:1
ButtonOverridesMissPerf.default 1803 1809 1:1
DatepickerMinimalPerf.default 5579 5570 1:1
EmbedMinimalPerf.default 4313 4296 1:1
InputMinimalPerf.default 1331 1331 1:1
ItemLayoutMinimalPerf.default 1230 1236 1:1
ListMinimalPerf.default 513 512 1:1
RosterPerf.default 1194 1194 1:1
ProviderMinimalPerf.default 1127 1127 1:1
CustomToolbarPrototype.default 4158 4173 1:1
AlertMinimalPerf.default 282 286 0.99:1
BoxMinimalPerf.default 363 366 0.99:1
ListCommonPerf.default 626 630 0.99:1
MenuMinimalPerf.default 853 861 0.99:1
ProviderMergeThemesPerf.default 1752 1774 0.99:1
ChatWithPopoverPerf.default 377 385 0.98:1
PortalMinimalPerf.default 187 191 0.98:1
CardMinimalPerf.default 549 564 0.97:1
CheckboxMinimalPerf.default 2745 2823 0.97:1
DividerMinimalPerf.default 370 380 0.97:1
ImageMinimalPerf.default 367 378 0.97:1
LabelMinimalPerf.default 381 393 0.97:1
PopupMinimalPerf.default 599 616 0.97:1
TreeWith60ListItems.default 194 199 0.97:1
FlexMinimalPerf.default 286 300 0.95:1

Copy link
Member

@khmakoto khmakoto left a comment

Choose a reason for hiding this comment

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

Approved with minor comments

@@ -1,48 +1,42 @@
import * as React from 'react';
import { ComponentPropsCompat, ShorthandPropsCompat } from '@fluentui/react-utilities';
import { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';
import type { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';

Comment on lines +4 to +5
root: IntrinsicShorthandProps<'div'>;
/**
Copy link
Member

Choose a reason for hiding this comment

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

nit: Add a new line here

Suggested change
root: IntrinsicShorthandProps<'div'>;
/**
root: IntrinsicShorthandProps<'div'>;
/**

export const dividerShorthandProps = ['wrapper', 'children'] as const;

const mergeProps = makeMergeProps<DividerState>({ deepMerge: dividerShorthandProps });
export const dividerShorthandProps: Array<keyof DividerSlots> = ['root', 'wrapper'];
Copy link
Member

Choose a reason for hiding this comment

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

This can be inlined in renderDivider now as it is the only place where it is used.

Comment on lines +19 to +41
return {
alignContent,
components: {
root: 'div',
wrapper: 'div',
},
inset,
root: getNativeElementProps('div', {
ref,
role: 'separator',
'aria-labelledby': props.children ? dividerId : undefined,
...props,
}),
vertical,
appearance,
wrapper: resolveShorthand(wrapper, {
required: true,
defaultProps: {
id: dividerId,
children: props.children,
},
}),
};
Copy link
Member

Choose a reason for hiding this comment

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

nit: We can order these so that props are passed in first, then we define components and finally we resolve slots.

Suggested change
return {
alignContent,
components: {
root: 'div',
wrapper: 'div',
},
inset,
root: getNativeElementProps('div', {
ref,
role: 'separator',
'aria-labelledby': props.children ? dividerId : undefined,
...props,
}),
vertical,
appearance,
wrapper: resolveShorthand(wrapper, {
required: true,
defaultProps: {
id: dividerId,
children: props.children,
},
}),
};
return {
alignContent,
appearance,
inset,
vertical,
components: {
root: 'div',
wrapper: 'div',
},
root: getNativeElementProps('div', {
ref,
role: 'separator',
'aria-labelledby': props.children ? dividerId : undefined,
...props,
}),
wrapper: resolveShorthand(wrapper, {
required: true,
defaultProps: {
id: dividerId,
children: props.children,
},
}),
};

@bsunderhus bsunderhus merged commit 0bba46b into microsoft:master Sep 24, 2021
@khmakoto
Copy link
Member

Woops, since like this auto-merged. @bsunderhus do you mind making a follow-up PR for the items I mentioned above?

@bsunderhus bsunderhus deleted the react-divider-prop-merging-migration branch September 29, 2021 07:46
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
* Updates divider to use new simplified slots

* Change files
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.

@fluentui/react-divider: use simplified prop merging

4 participants