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

chore: refactor Flex to be functional component [v0] #12078

Merged
merged 7 commits into from
Mar 2, 2020

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Feb 26, 2020

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ yarn change

BREAKING CHANGES

This PR converts Flex & FlexItem components to be functional. As in all other cases it contains a breaking change with restricted props set that will be passed to styles functions.

Prop sets

Flex
column
debug
fill
gap
hAlign
inline
padding
space
vAlign
wrap
FlexItem
align
grow
flexDirection
push
shrink
size
Microsoft Reviewers: Open in CodeFlow

@size-auditor
Copy link

size-auditor bot commented Feb 26, 2020

Asset size changes

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

Baseline commit: 3d5fba42e42c72fe33dd2ce54cdda2e1cd940835 (build)

@msft-github-bot
Copy link
Contributor

msft-github-bot commented Feb 26, 2020

Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Status
BaseButton 739 765
BaseButton (experiments) 945 922
DefaultButton 977 981
DefaultButton (experiments) 1942 1828
DetailsRow 3361 3249
DetailsRow (fast icons) 3268 3394
DetailsRow without styles 3080 3172
DocumentCardTitle with truncation 1558 1507
MenuButton 1309 1343
MenuButton (experiments) 3467 3382
PrimaryButton 1090 1139
PrimaryButton (experiments) 1983 2005
SplitButton 2746 2768
SplitButton (experiments) 6870 6882
Stack 480 463
Stack with Intrinsic children 1116 1070
Stack with Text children 4184 4189
Text 361 353
Toggle 823 816
Toggle (experiments) 2122 2262
button 62 69

Perf Analysis (Fluent)

⚠️ 1 potential perf regressions detected

Potential regressions comparing to master

Scenario Current PR Ticks Baseline Ticks Ratio Regression Analysis
FlexMinimalPerf.default 272 480 0.57:1 analysis
Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🔧 Avatar.Fluent 0.52 0.49 1.06:1 2000 1041
🦄 Button.Fluent 0.15 0.24 0.63:1 1000 146
🔧 Checkbox.Fluent 0.89 0.4 2.23:1 1000 886
🔧 Dialog.Fluent 0.39 0.23 1.7:1 5000 1944
🔧 Dropdown.Fluent 3.88 0.54 7.19:1 1000 3882
🔧 Icon.Fluent 0.18 0.05 3.6:1 5000 906
🎯 Image.Fluent 0.07 0.1 0.7:1 5000 348
🔧 Slider.Fluent 1.54 0.41 3.76:1 1000 1536
🔧 Text.Fluent 0.08 0.02 4:1 5000 396
🦄 Tooltip.Fluent 0.13 16.1 0.01:1 5000 636

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
BoxMinimalPerf.default 350 315 1.11:1
DropdownManyItemsPerf.default 380 347 1.1:1
Image.Fluent 348 320 1.09:1
IconMinimalPerf.default 439 406 1.08:1
RadioGroupMinimalPerf.default 618 574 1.08:1
TableMinimalPerf.default 803 746 1.08:1
TextMinimalPerf.default 397 369 1.08:1
StatusMinimalPerf.default 350 328 1.07:1
TreeWith60ListItems.default 273 256 1.07:1
LoaderMinimalPerf.default 1069 1010 1.06:1
TooltipMinimalPerf.default 916 864 1.06:1
Tooltip.Fluent 636 602 1.06:1
EmbedMinimalPerf.default 6466 6142 1.05:1
HeaderMinimalPerf.default 620 593 1.05:1
PopupMinimalPerf.default 439 420 1.05:1
AnimationMinimalPerf.default 714 689 1.04:1
HeaderSlotsPerf.default 1895 1827 1.04:1
ListNestedPerf.default 966 925 1.04:1
MenuMinimalPerf.default 2169 2092 1.04:1
MenuButtonMinimalPerf.default 2023 1948 1.04:1
AttachmentSlotsPerf.default 3696 3595 1.03:1
CarouselMinimalPerf.default 2095 2025 1.03:1
ChatWithPopoverPerf.default 647 631 1.03:1
DividerMinimalPerf.default 1101 1074 1.03:1
HierarchicalTreeMinimalPerf.default 1157 1126 1.03:1
ListCommonPerf.default 1046 1017 1.03:1
ToolbarMinimalPerf.default 1191 1151 1.03:1
Dropdown.Fluent 3882 3785 1.03:1
AccordionMinimalPerf.default 270 265 1.02:1
FormMinimalPerf.default 1028 1009 1.02:1
Icon.Fluent 906 884 1.02:1
ButtonSlotsPerf.default 732 722 1.01:1
CheckboxMinimalPerf.default 4095 4072 1.01:1
ProviderMinimalPerf.default 671 663 1.01:1
Text.Fluent 396 391 1.01:1
AvatarMinimalPerf.default 568 566 1:1
DialogMinimalPerf.default 1872 1866 1:1
DropdownMinimalPerf.default 3833 3847 1:1
LayoutMinimalPerf.default 739 738 1:1
ProviderMergeThemesPerf.default 1283 1279 1:1
SliderMinimalPerf.default 1557 1551 1:1
ChatDuplicateMessagesPerf.default 407 411 0.99:1
PortalMinimalPerf.default 309 313 0.99:1
CustomToolbarPrototype.default 3812 3862 0.99:1
TreeMinimalPerf.default 1249 1259 0.99:1
AttachmentMinimalPerf.default 946 964 0.98:1
ButtonMinimalPerf.default 156 159 0.98:1
LabelMinimalPerf.default 374 383 0.98:1
ListMinimalPerf.default 438 448 0.98:1
ListWith60ListItems.default 181 184 0.98:1
ReactionMinimalPerf.default 2523 2565 0.98:1
RefMinimalPerf.default 205 210 0.98:1
SplitButtonMinimalPerf.default 12936 13188 0.98:1
VideoMinimalPerf.default 939 960 0.98:1
Avatar.Fluent 1041 1058 0.98:1
Checkbox.Fluent 886 908 0.98:1
Dialog.Fluent 1944 1984 0.98:1
Slider.Fluent 1536 1569 0.98:1
TextAreaMinimalPerf.default 3164 3256 0.97:1
GridMinimalPerf.default 920 960 0.96:1
ItemLayoutMinimalPerf.default 2180 2273 0.96:1
SegmentMinimalPerf.default 1165 1217 0.96:1
ChatMinimalPerf.default 556 588 0.95:1
InputMinimalPerf.default 1018 1072 0.95:1
AlertMinimalPerf.default 579 618 0.94:1
ImageMinimalPerf.default 325 347 0.94:1
Button.Fluent 146 161 0.91:1

@ecraig12345 ecraig12345 added the Fluent UI react-northstar (v0) Work related to Fluent UI V0 label Feb 26, 2020
children: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),

align: PropTypes.oneOf(['auto', 'start', 'end', 'center', 'baseline', 'stretch']),
size: PropTypes.oneOfType([PropTypes.oneOf(['size.half', 'size.quarter', 'size.small', 'size.medium', 'size.large']), PropTypes.string]),
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously was incorrect 💣

…OfficeDev/office-ui-fabric-react into chore/flex-to-fc

� Conflicts:
�	packages/fluentui/CHANGELOG.md
@layershifter layershifter reopened this Feb 27, 2020
@layershifter layershifter changed the title chore: refactor Flex to be functional component [v0] [WIP] chore: refactor Flex to be functional component [v0] Feb 27, 2020
static defaultProps = {
as: 'div'
};
const content = React.Children.map(children, child => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's refactor this with adding FlexContextProvider

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, can we do this thing separately? I want to make a small showcase from it

children: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),

align: PropTypes.oneOf(['auto', 'start', 'end', 'center', 'baseline', 'stretch']),
size: PropTypes.oneOfType([PropTypes.oneOf(['size.half', 'size.quarter', 'size.small', 'size.medium', 'size.large']), PropTypes.string]),
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit worried that this can be any css value (px or %) which may cause problems with the caching... :(

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's see the feedback. I agree there that it can be a real issue, but:

  • I don't think that it's used enough frequently
  • size manages flexBasis, may be in this case we should manage it via design prop...
  • we can disable caching for FlexItem

@layershifter layershifter merged commit d95f49e into master Mar 2, 2020
@layershifter layershifter deleted the chore/flex-to-fc branch March 2, 2020 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fluent UI react-northstar (v0) Work related to Fluent UI V0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants