Skip to content

Conversation

@dzearing
Copy link
Member

@dzearing dzearing commented May 5, 2020

This PR introduces a universal generalized ThemeProvider package. It currently does 2 things:

  • Provides css variables
  • Registers stylesheets defined in a theme.

See the README.md for usage.

Includes:

  • unit tests
  • basic storybook stories
  • api extractor
  • snapshots
  • documentation
Microsoft Reviewers: Open in CodeFlow

@size-auditor
Copy link

size-auditor bot commented May 5, 2020

Asset size changes

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

Baseline commit: ce5c014aa4c23951afe4d1ca5e45ddb711e2f0fc (build)

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.

Left some comments about build-related stuff.

Also from the lockfile it looks like there might be some dependency version mismatches.

@msft-github-bot
Copy link
Contributor

msft-github-bot commented May 5, 2020

Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Iterations Status
BaseButton 716 726 5000
Checkbox 1502 1381 5000
CheckboxBase 1163 1173 5000
ChoiceGroup 4508 4471 5000
ComboBox 828 847 1000
CommandBar 7130 6855 1000
ContextualMenu 14596 14909 1000
DefaultButton 1019 944 5000
DetailsRow 3115 3115 5000
DetailsRow (fast icons) 3202 3205 5000
DetailsRow without styles 2999 3015 5000
Dialog 1350 1336 1000
DocumentCardTitle with truncation 1568 1556 1000
Dropdown 2109 2135 5000
FocusZone 1466 1517 5000
IconButton 1517 1514 5000
Label 276 279 5000
Link 405 404 5000
MenuButton 1300 1259 5000
Nav 2788 2853 1000
Panel 1310 1267 1000
Persona 771 746 1000
Pivot 1190 1210 1000
PrimaryButton 1079 1081 5000
SearchBox 1122 1134 5000
Slider 1381 1352 5000
Spinner 360 358 5000
SplitButton 2834 2824 5000
Stack 413 421 5000
Stack with Intrinsic children 1006 1008 5000
Stack with Text children 3729 3707 5000
TagPicker 2499 2459 5000
Text 343 339 5000
TextField 1252 1239 5000
Toggle 796 794 5000
button 54 55 5000

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🎯 Avatar.Fluent 0.45 0.45 1:1 2000 894
🦄 Button.Fluent 0.09 0.17 0.53:1 5000 472
🔧 Checkbox.Fluent 0.6 0.31 1.94:1 1000 598
🔧 Dialog.Fluent 0.32 0.18 1.78:1 5000 1615
🔧 Dropdown.Fluent 3.13 0.4 7.82:1 1000 3134
🔧 Icon.Fluent 0.13 0.04 3.25:1 5000 654
🦄 Image.Fluent 0.06 0.09 0.67:1 5000 323
🔧 Slider.Fluent 1.33 0.34 3.91:1 1000 1333
🔧 Text.Fluent 0.06 0.02 3:1 5000 312
🦄 Tooltip.Fluent 0.08 19.29 0:1 5000 424

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AttachmentMinimalPerf.default 149 128 1.16:1
ButtonMinimalPerf.default 159 150 1.06:1
RefMinimalPerf.default 202 191 1.06:1
TreeWith60ListItems.default 217 204 1.06:1
ListWith60ListItems.default 1076 1029 1.05:1
Icon.Fluent 654 625 1.05:1
CardMinimalPerf.default 494 473 1.04:1
ChatWithPopoverPerf.default 535 514 1.04:1
CarouselMinimalPerf.default 425 413 1.03:1
ChatMinimalPerf.default 569 551 1.03:1
FormMinimalPerf.default 692 673 1.03:1
ListMinimalPerf.default 421 409 1.03:1
ProviderMinimalPerf.default 654 638 1.03:1
Avatar.Fluent 894 866 1.03:1
AnimationMinimalPerf.default 571 562 1.02:1
BoxMinimalPerf.default 287 280 1.02:1
DropdownMinimalPerf.default 3154 3099 1.02:1
EmbedMinimalPerf.default 1917 1881 1.02:1
GridMinimalPerf.default 601 592 1.02:1
InputMinimalPerf.default 919 899 1.02:1
ItemLayoutMinimalPerf.default 1511 1475 1.02:1
LoaderMinimalPerf.default 715 699 1.02:1
ProviderMergeThemesPerf.default 1602 1576 1.02:1
RadioGroupMinimalPerf.default 509 498 1.02:1
ReactionMinimalPerf.default 1746 1720 1.02:1
SegmentMinimalPerf.default 843 823 1.02:1
SliderMinimalPerf.default 1328 1306 1.02:1
SplitButtonMinimalPerf.default 3177 3105 1.02:1
TextMinimalPerf.default 306 299 1.02:1
TooltipMinimalPerf.default 674 663 1.02:1
Slider.Fluent 1333 1308 1.02:1
AvatarMinimalPerf.default 468 465 1.01:1
CheckboxMinimalPerf.default 2780 2761 1.01:1
DropdownManyItemsPerf.default 1259 1242 1.01:1
HeaderSlotsPerf.default 1311 1300 1.01:1
ImageMinimalPerf.default 315 312 1.01:1
ListNestedPerf.default 800 790 1.01:1
MenuButtonMinimalPerf.default 1435 1422 1.01:1
Text.Fluent 312 308 1.01:1
HeaderMinimalPerf.default 431 430 1:1
PopupMinimalPerf.default 236 235 1:1
IconMinimalPerf.default 602 602 1:1
TreeMinimalPerf.default 1106 1109 1:1
Checkbox.Fluent 598 601 1:1
Dialog.Fluent 1615 1623 1:1
Dropdown.Fluent 3134 3131 1:1
AlertMinimalPerf.default 270 274 0.99:1
ButtonSlotsPerf.default 545 549 0.99:1
DialogMinimalPerf.default 1581 1597 0.99:1
DividerMinimalPerf.default 304 308 0.99:1
StatusMinimalPerf.default 593 596 0.99:1
TableMinimalPerf.default 344 346 0.99:1
Button.Fluent 472 478 0.99:1
Image.Fluent 323 326 0.99:1
Tooltip.Fluent 424 429 0.99:1
AttachmentSlotsPerf.default 1021 1046 0.98:1
FlexMinimalPerf.default 262 266 0.98:1
PortalMinimalPerf.default 281 286 0.98:1
TextAreaMinimalPerf.default 410 417 0.98:1
CustomToolbarPrototype.default 3397 3453 0.98:1
VideoMinimalPerf.default 541 553 0.98:1
HierarchicalTreeMinimalPerf.default 882 906 0.97:1
ListCommonPerf.default 869 893 0.97:1
MenuMinimalPerf.default 1669 1727 0.97:1
ChatDuplicateMessagesPerf.default 370 387 0.96:1
LabelMinimalPerf.default 352 366 0.96:1
LayoutMinimalPerf.default 483 501 0.96:1
ToolbarMinimalPerf.default 727 757 0.96:1
AccordionMinimalPerf.default 125 135 0.93: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 nits.

dzearing and others added 4 commits May 7, 2020 12:14
Co-authored-by: Makoto Morimoto <Humberto.Morimoto@microsoft.com>
Co-authored-by: Makoto Morimoto <Humberto.Morimoto@microsoft.com>
@dzearing dzearing merged commit 156c760 into microsoft:master May 8, 2020
@dzearing dzearing deleted the feat/react-theme-provider branch May 8, 2020 15:28
const parentTheme = useTheme();

// Merge the theme only when parent theme or props theme mutates.
const fullTheme = React.useMemo<ThemePrepared>(() => mergeThemes(parentTheme, theme), [parentTheme, theme]);
Copy link
Member

Choose a reason for hiding this comment

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

As theme is a prop it can be inline object: <ThemeProvider theme={{ foo: 'bar' }} />. It means that all consumers will receive updates on each render as fullTheme is passed to React context.

Comment on lines +26 to +27
{ theme, style, className, ...rest }: React.PropsWithChildren<ThemeProviderProps>,
ref: React.Ref<HTMLDivElement>,
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to specify these types obviously

@msft-github-bot
Copy link
Contributor

🎉@fluentui/react-theme-provider@v0.1.1 has been released which incorporates this pull request.:tada:

Handy links:

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.

7 participants