-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Refactor Avatar to remove mergeProps #19449
Conversation
…vatar-unmergeprops
…atar-unmergeprops
📊 Bundle size report
Unchanged fixtures
|
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 439ce8b:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 3df6452369ad5b6a9c83b58556208db710accb03 (build) |
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 910 | 921 | 5000 | |
BaseButton | mount | 894 | 887 | 5000 | |
Breadcrumb | mount | 2671 | 2634 | 1000 | |
ButtonNext | mount | 468 | 474 | 5000 | |
Checkbox | mount | 1572 | 1512 | 5000 | |
CheckboxBase | mount | 1276 | 1290 | 5000 | |
ChoiceGroup | mount | 4753 | 4725 | 5000 | |
ComboBox | mount | 1009 | 1013 | 1000 | |
CommandBar | mount | 10309 | 10267 | 1000 | |
ContextualMenu | mount | 6662 | 6452 | 1000 | |
DefaultButton | mount | 1137 | 1131 | 5000 | |
DetailsRow | mount | 3705 | 3795 | 5000 | |
DetailsRowFast | mount | 3770 | 3694 | 5000 | |
DetailsRowNoStyles | mount | 3626 | 3565 | 5000 | |
Dialog | mount | 2447 | 2453 | 1000 | |
DocumentCardTitle | mount | 142 | 140 | 1000 | |
Dropdown | mount | 3241 | 3235 | 5000 | |
FluentProviderNext | mount | 7541 | 7561 | 5000 | |
FluentProviderWithTheme | mount | 367 | 349 | 10 | |
FluentProviderWithTheme | virtual-rerender | 100 | 114 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 485 | 487 | 10 | |
FocusTrapZone | mount | 1770 | 1814 | 5000 | |
FocusZone | mount | 1802 | 1789 | 5000 | |
IconButton | mount | 1753 | 1741 | 5000 | |
Label | mount | 335 | 333 | 5000 | |
Layer | mount | 2958 | 2970 | 5000 | |
Link | mount | 481 | 476 | 5000 | |
MakeStyles | mount | 1862 | 1853 | 50000 | |
MenuButton | mount | 1476 | 1502 | 5000 | |
MessageBar | mount | 2021 | 2031 | 5000 | |
Nav | mount | 3293 | 3344 | 1000 | |
OverflowSet | mount | 1098 | 1105 | 5000 | |
Panel | mount | 2356 | 2365 | 1000 | |
Persona | mount | 831 | 843 | 1000 | |
Pivot | mount | 1449 | 1416 | 1000 | |
PrimaryButton | mount | 1274 | 1274 | 5000 | |
Rating | mount | 7795 | 7649 | 5000 | |
SearchBox | mount | 1304 | 1353 | 5000 | |
Shimmer | mount | 2580 | 2578 | 5000 | |
Slider | mount | 1982 | 1938 | 5000 | |
SpinButton | mount | 5078 | 5032 | 5000 | |
Spinner | mount | 426 | 421 | 5000 | |
SplitButton | mount | 3210 | 3230 | 5000 | |
Stack | mount | 502 | 519 | 5000 | |
StackWithIntrinsicChildren | mount | 1671 | 1670 | 5000 | |
StackWithTextChildren | mount | 4692 | 4672 | 5000 | |
SwatchColorPicker | mount | 10554 | 10518 | 5000 | |
Tabs | mount | 1450 | 1413 | 1000 | |
TagPicker | mount | 2657 | 2703 | 5000 | |
TeachingBubble | mount | 13369 | 13400 | 5000 | |
Text | mount | 421 | 441 | 5000 | |
TextField | mount | 1373 | 1378 | 5000 | |
ThemeProvider | mount | 1179 | 1182 | 5000 | |
ThemeProvider | virtual-rerender | 616 | 605 | 5000 | |
ThemeProvider | virtual-rerender-with-unmount | 1909 | 1894 | 5000 | |
Toggle | mount | 803 | 791 | 5000 | |
buttonNative | mount | 121 | 109 | 5000 |
Perf Analysis (@fluentui/react-northstar
)
Perf tests with no regressions
Scenario | Current PR Ticks | Baseline Ticks | Ratio |
---|---|---|---|
AttachmentMinimalPerf.default | 169 | 148 | 1.14:1 |
RefMinimalPerf.default | 263 | 237 | 1.11:1 |
FlexMinimalPerf.default | 312 | 289 | 1.08:1 |
SkeletonMinimalPerf.default | 378 | 350 | 1.08:1 |
ButtonMinimalPerf.default | 181 | 169 | 1.07:1 |
AnimationMinimalPerf.default | 428 | 402 | 1.06:1 |
VideoMinimalPerf.default | 655 | 622 | 1.05:1 |
AvatarMinimalPerf.default | 200 | 192 | 1.04:1 |
ButtonSlotsPerf.default | 564 | 543 | 1.04:1 |
StatusMinimalPerf.default | 695 | 671 | 1.04:1 |
CarouselMinimalPerf.default | 477 | 464 | 1.03:1 |
GridMinimalPerf.default | 342 | 332 | 1.03:1 |
ListCommonPerf.default | 647 | 626 | 1.03:1 |
ListNestedPerf.default | 559 | 544 | 1.03:1 |
ListWith60ListItems.default | 654 | 638 | 1.03:1 |
LoaderMinimalPerf.default | 727 | 708 | 1.03:1 |
RadioGroupMinimalPerf.default | 450 | 438 | 1.03:1 |
SegmentMinimalPerf.default | 349 | 339 | 1.03:1 |
ChatMinimalPerf.default | 667 | 651 | 1.02:1 |
DialogMinimalPerf.default | 764 | 752 | 1.02:1 |
ItemLayoutMinimalPerf.default | 1248 | 1219 | 1.02:1 |
ProviderMinimalPerf.default | 1136 | 1109 | 1.02:1 |
AlertMinimalPerf.default | 274 | 272 | 1.01:1 |
BoxMinimalPerf.default | 348 | 344 | 1.01:1 |
ChatDuplicateMessagesPerf.default | 301 | 297 | 1.01:1 |
DividerMinimalPerf.default | 374 | 372 | 1.01:1 |
EmbedMinimalPerf.default | 4340 | 4291 | 1.01:1 |
HeaderMinimalPerf.default | 353 | 351 | 1.01:1 |
LayoutMinimalPerf.default | 375 | 372 | 1.01:1 |
MenuButtonMinimalPerf.default | 1655 | 1638 | 1.01:1 |
PortalMinimalPerf.default | 182 | 181 | 1.01:1 |
SliderMinimalPerf.default | 1727 | 1702 | 1.01:1 |
SplitButtonMinimalPerf.default | 4296 | 4245 | 1.01:1 |
TableManyItemsPerf.default | 1889 | 1872 | 1.01:1 |
DatepickerMinimalPerf.default | 5481 | 5503 | 1:1 |
DropdownMinimalPerf.default | 3279 | 3285 | 1:1 |
HeaderSlotsPerf.default | 754 | 753 | 1:1 |
ListMinimalPerf.default | 512 | 510 | 1:1 |
MenuMinimalPerf.default | 842 | 844 | 1:1 |
PopupMinimalPerf.default | 589 | 590 | 1:1 |
TableMinimalPerf.default | 394 | 394 | 1:1 |
CustomToolbarPrototype.default | 4137 | 4143 | 1:1 |
TooltipMinimalPerf.default | 1015 | 1016 | 1:1 |
AttachmentSlotsPerf.default | 1081 | 1093 | 0.99:1 |
CardMinimalPerf.default | 546 | 550 | 0.99:1 |
CheckboxMinimalPerf.default | 2757 | 2786 | 0.99:1 |
ImageMinimalPerf.default | 372 | 375 | 0.99:1 |
InputMinimalPerf.default | 1316 | 1333 | 0.99:1 |
RosterPerf.default | 1185 | 1200 | 0.99:1 |
TextMinimalPerf.default | 352 | 354 | 0.99:1 |
TextAreaMinimalPerf.default | 497 | 502 | 0.99:1 |
TreeMinimalPerf.default | 796 | 806 | 0.99:1 |
FormMinimalPerf.default | 389 | 398 | 0.98:1 |
IconMinimalPerf.default | 614 | 629 | 0.98:1 |
TreeWith60ListItems.default | 188 | 191 | 0.98:1 |
ChatWithPopoverPerf.default | 375 | 387 | 0.97:1 |
ProviderMergeThemesPerf.default | 1731 | 1791 | 0.97:1 |
ToolbarMinimalPerf.default | 938 | 971 | 0.97:1 |
ButtonOverridesMissPerf.default | 1746 | 1814 | 0.96:1 |
DropdownManyItemsPerf.default | 673 | 700 | 0.96:1 |
LabelMinimalPerf.default | 385 | 400 | 0.96:1 |
AccordionMinimalPerf.default | 146 | 155 | 0.94:1 |
ReactionMinimalPerf.default | 385 | 417 | 0.92:1 |
/** | ||
* The Avatar's image. | ||
* Can either be the URL of the image, or the props of the img tag | ||
*/ | ||
image?: string | ObjectShorthandProps<React.ImgHTMLAttributes<HTMLImageElement>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@behowell this is done to exclude other types from ShorthandProps
are img
does not have children, correct?
* Badge to show the avatar's presence status. | ||
* Can either be a string indicating the status ("busy", "away", etc.), or a PresenceBadgeProps object. | ||
*/ | ||
badge?: PresenceBadgeStatus | ObjectShorthandProps<PresenceBadgeProps>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
badge?: PresenceBadgeStatus | ObjectShorthandProps<PresenceBadgeProps>; | |
badge?: PresenceBadgeStatus | ShorthandProps<PresenceBadgeProps>; |
@behowell I can understand the case with image
, but can you please clarify why we should not use ShorthandProps
there? With ObjectShorthandProps
it will be impossible to pass JSX elements:
<Avatar badge={<span />} />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ComponentProps
type actually exposes the props as ShorthandProps<ObjectShorthandProps>
root: Omit<IntrinsicShorthandProps<'div'>, 'color'>; | ||
icon?: IntrinsicShorthandProps<'span'>; | ||
root: ObjectShorthandProps<React.HTMLAttributes<HTMLElement>>; | ||
icon?: ObjectShorthandProps<React.HTMLAttributes<HTMLElement>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this mean that IntrinsicShorthandProps
type does not work as it should?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's not working as it should, the unions completely break the Avatar when using PresenceBadgeProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please an issue for this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had something like this happen with SplitButton
yesterday. I can try and pull this branch and do what I did there to see if it works or just try to make the change later to not block this PR.
// 'colorful' should have been replaced with a color name by useAvatar, but if not default to darkRed | ||
const color = state.color === 'colorful' ? 'darkRed' : state.color; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we just remove this logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now that this should be ensured in the useAvatar
hook so there is no need for this anymore.
* Initial work removing mergeProps from Avatar * Refactor Avatar to remove mergeProps * Update from latest changes to resolveShorthand * Pull the slot names out into a separate array * Remove null from badge and image types * Move badge size and default icon to helper functions * Fix up comments * More refactoring * More refactoring * Change files * Move logic to resolve 'colorful' back to useAvatar * Fix badge size * Remove unnecessary Partial * Update for latest changes to root-as-slot and IntrinsicShorthandProps * Change files * Fix badge typings * Change files * fix tests * change interfaces to types * Change files * update md * revert react-utilities changes * update md * use undefined instaed of boolean for image * fix ver tests * make image typings scripts Co-authored-by: Lingfan Gao <[email protected]>
* Fix Avatar stories after microsoft#19449 * Change files
Pull request checklist
$ yarn change
Description of changes
Refactor
AvatarProps
,AvatarState
, etc., and updateuseAvatar
andrenderAvatar
to use the new approach described in RFC #18642