Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

[WIP] feat: add compose(), caching, converting components to hooks #2229

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jan 13, 2020

DO NOT REVIEW
EARLY DRAFT


NOTICE

This PR covers too many things. We are going to rebase it, extract and discuss things before merging.

@DustyTheBot
Copy link
Collaborator

DustyTheBot commented Jan 17, 2020

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.
⚠️ 20 perf regressions detected

Perf comparison

Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🦄 Avatar.Fluent 0.13 0.39 0.33:1 2000 254
🦄 Button.Fluent 0.12 0.21 0.57:1 1000 116
🔧 Checkbox.Fluent 0.32 0.29 1.1:1 1000 322
🔧 Dialog.Fluent 0.36 0.19 1.89:1 5000 1787
🔧 Dropdown.Fluent 4.3 0.44 9.77:1 1000 4297
🔧 Icon.Fluent 0.1 0.03 3.33:1 5000 487
🦄 Image.Fluent 0.04 0.08 0.5:1 5000 204
🎯 Slider.Fluent 0.3 0.31 0.97:1 1000 303
🦄 Text.Fluent 0.05 0.16 0.31:1 5000 227
🦄 Tooltip.Fluent 0.41 18.29 0.02:1 5000 2064

🔧 Needs work     🎯 On target     🦄 Amazing

Potential regressions comparing to master

Scenario Current PR Ticks Baseline Ticks Ratio
Dropdown.Fluent 4297 3663 1.17:1
TextMinimalPerf.default 288 305 0.94:1
Text.Fluent 227 242 0.94:1
ChatDuplicateMessagesPerf.default 486 553 0.88:1
AttachmentSlotsPerf.default 3994 4639 0.86:1
DropdownMinimalPerf.default 3694 4694 0.79:1
ListCommonPerf.default 757 1160 0.65:1
LabelMinimalPerf.default 891 1769 0.5:1
Icon.Fluent 487 1300 0.37:1
StatusMinimalPerf.default 266 1129 0.24:1
IconMinimalPerf.default 273 1193 0.23:1
AvatarMinimalPerf.default 170 782 0.22:1
Checkbox.Fluent 322 1461 0.22:1
Avatar.Fluent 254 1331 0.19:1
SliderMinimalPerf.default 331 2067 0.16:1
Slider.Fluent 303 1861 0.16:1
CheckboxMinimalPerf.default 1141 7797 0.15:1
ButtonSlotsPerf.default 279 1933 0.14:1
ButtonMinimalPerf.default 151 1518 0.1:1
Button.Fluent 116 1289 0.09:1
Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
EmbedMinimalPerf.default 7206 0 Infinity:1
AnimationMinimalPerf.default 702 546 1.29:1
LayoutMinimalPerf.default 599 478 1.25:1
HeaderMinimalPerf.default 481 409 1.18:1
ItemLayoutMinimalPerf.default 1992 1730 1.15:1
PopupMinimalPerf.default 416 366 1.14:1
RefMinimalPerf.default 176 159 1.11:1
TextAreaMinimalPerf.default 3766 3379 1.11:1
ToolbarMinimalPerf.default 872 786 1.11:1
AccordionMinimalPerf.default 279 256 1.09:1
ReactionMinimalPerf.default 2899 2662 1.09:1
FlexMinimalPerf.default 364 336 1.08:1
MenuButtonMinimalPerf.default 1654 1535 1.08:1
TooltipMinimalPerf.default 2438 2252 1.08:1
HeaderSlotsPerf.default 1462 1384 1.06:1
CustomToolbarPrototype.default 4413 4182 1.06:1
SegmentMinimalPerf.default 1294 1232 1.05:1
TreeMinimalPerf.default 958 914 1.05:1
Tooltip.Fluent 2064 1975 1.05:1
AlertMinimalPerf.default 776 761 1.02:1
ChatWithPopoverPerf.default 580 570 1.02:1
InputMinimalPerf.default 1087 1063 1.02:1
MenuMinimalPerf.default 2019 1983 1.02:1
AttachmentMinimalPerf.default 1138 1134 1:1
TableMinimalPerf.default 703 706 1:1
DropdownManyItemsPerf.default 536 549 0.98:1
RadioGroupMinimalPerf.default 426 436 0.98:1
LoaderMinimalPerf.default 2439 2505 0.97:1
DividerMinimalPerf.default 942 978 0.96:1
HierarchicalTreeMinimalPerf.default 819 852 0.96:1
VideoMinimalPerf.default 794 829 0.96:1
DialogMinimalPerf.default 1838 1935 0.95:1
ProviderMinimalPerf.default 679 715 0.95:1
FormMinimalPerf.default 760 819 0.93:1
ProviderMergeThemesPerf.default 1295 1397 0.93:1
CarouselMinimalPerf.default 1849 2014 0.92:1
ChatMinimalPerf.default 1741 1900 0.92:1
GridMinimalPerf.default 844 915 0.92:1
PortalMinimalPerf.default 218 243 0.9:1
Dialog.Fluent 1787 2006 0.89:1
SplitButtonMinimalPerf.default 11343 14764 0.77:1
BoxMinimalPerf.default 224 312 0.72:1
ImageMinimalPerf.default 248 497 0.5:1
ListMinimalPerf.default 271 692 0.39:1
Image.Fluent 204 517 0.39:1

Generated by 🚫 dangerJS

fluentToFabric <= 0.5 && '⚡',
fluentToFabric <= 0.7 && '🦄',
fluentToFabric <= 1 && '🎯',
'🔧',
Copy link
Member

Choose a reason for hiding this comment

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

Our "target" is 30% faster. The previous "on target' was displayed when a Fluent component was 30% faster than Fabric.

The 4 levels are fun, but it might make this harder to understand.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted 👍

overrideStyles?: boolean
}

const COMPOSE_CONFIG_PROP_NAME = '__unstable_config'
Copy link
Member

Choose a reason for hiding this comment

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

Should this go in the react-theming package? I thought that was where we were going to have compositional utilities.

We need a package which partners can easily use to compose components and provide a theme, with the least amount of other dependencies in it. This will allow a solid foundation to exist for building out an ecosystem of components.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that composition covers only styling aspects 🤔

@layershifter layershifter changed the title feat: add compose [WIP] feat: add compose(), caching, converting components to hooks Jan 24, 2020
<>
<Slider />
<Slider />
</>
Copy link
Member Author

Choose a reason for hiding this comment

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

Revert me plz

const renderIcon = () => {
return Icon.create(icon, {
// @ts-ignore
return ButtonIcon.create(icon, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Still not sure about the ButtonIcon component... Maybe in the end we can just combine once the styles for the Icon component + styles for the Button's icon slot and store that as a cache... I am worried that for more complicated component, creating variant for the component will mean creating new variants for each slot, and you may only need to change one style for them...

…dust-ui/react into feat/compose

� Conflicts:
�	packages/state/src/index.ts
…dust-ui/react into feat/compose

� Conflicts:
�	packages/accessibility/src/behaviors/index.ts
�	packages/react-bindings/src/hooks/useStyles.ts
�	packages/react-bindings/src/styles/getStyles.ts
�	packages/react-bindings/src/styles/resolveStylesAndClasses.tsx
�	packages/react-bindings/test/styles/resolveStylesAndClasses-test.ts
�	packages/react/src/components/Chat/ChatItem.tsx
�	packages/react/src/components/Chat/ChatMessage.tsx
�	packages/react/src/components/Checkbox/Checkbox.tsx
�	packages/react/src/components/Icon/Icon.tsx
�	packages/react/src/components/Label/Label.tsx
�	packages/react/src/components/Slider/Slider.tsx
�	packages/react/src/components/Status/Status.tsx
�	packages/react/src/components/Text/Text.tsx
�	packages/react/src/themes/teams/components/Checkbox/checkboxStyles.ts
�	packages/react/src/themes/teams/components/Icon/iconStyles.ts
�	packages/react/src/themes/teams/components/Label/labelStyles.ts
�	packages/react/src/themes/teams/components/Slider/sliderStyles.ts
�	packages/react/src/themes/teams/components/Text/textStyles.ts
�	packages/react/test/specs/components/Checkbox/Checkbox-test.tsx
�	packages/react/test/specs/components/Icon/Icon-test.tsx
�	packages/react/test/specs/components/Label/Label-test.tsx
�	packages/react/test/specs/components/Status/Status-test.tsx
�	packages/react/test/specs/components/Text/Text-test.tsx
�	packages/state/src/index.ts
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants