Skip to content

chore(react-components): Theme picker for storybook --docs mode - #20448

Merged
ling1726 merged 41 commits into
microsoft:masterfrom
ling1726:chore/storybook-doc-theme
Nov 5, 2021
Merged

chore(react-components): Theme picker for storybook --docs mode#20448
ling1726 merged 41 commits into
microsoft:masterfrom
ling1726:chore/storybook-doc-theme

Conversation

@ling1726

@ling1726 ling1726 commented Nov 2, 2021

Copy link
Copy Markdown
Contributor

Pull request checklist

Description of changes

Adds a theme picker to the docs page for react-component. Since this picker leverages the same global state as #20346 , the state is persisted even when switching pages in storybook.

This picker will still render for react-components without the --docs option, but since it uses storybook globals, will be in sync with the picker in the storybook toolbar

image

Latest iteration does not have the paint bucket icon below

Xz1z6eG1C8

Focus areas to test

(optional)

Chromatic stores published storybooks with commits, we can simply build
an azure function to keep the version -> commit mapping and integrate a
picker into the docs page
Adds the theme picker to the storybook toolbar for internal development.
The global types are exported since they will be used for the docs page.
Initialize a custom `FluentDocsContainer` and  FluentDocsHeader` to the
react-components storybook for future toolbar items like theme and
version picker.

This custom header is required since our future plans to build with
`--docs` will remove the native storybook toolbar
Comment thread packages/react-components/src/DocsComponents/FluentDocsContainer.stories.tsx Outdated
@fabricteam

fabricteam commented Nov 2, 2021

Copy link
Copy Markdown
Collaborator

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-accordion
Accordion (including children components)
56.753 kB
17.873 kB
react-avatar
Avatar
54.097 kB
15.331 kB
react-badge
Badge
22.394 kB
6.707 kB
react-badge
CounterBadge
24.773 kB
7.387 kB
react-badge
PresenceBadge
29.768 kB
8.517 kB
react-button
Button
24.651 kB
7.462 kB
react-button
CompoundButton
29.939 kB
8.418 kB
react-button
MenuButton
27.046 kB
8.227 kB
react-button
SplitButton
33.261 kB
9.328 kB
react-button
ToggleButton
33.78 kB
8.065 kB
react-card
Card - All
48.554 kB
14.433 kB
react-card
Card
43.974 kB
13.207 kB
react-card
CardFooter
7.418 kB
3.182 kB
react-card
CardHeader
8.778 kB
3.64 kB
react-card
CardPreview
7.682 kB
3.341 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
166.267 kB
47.598 kB
react-components
react-components: FluentProvider & webLightTheme
31.058 kB
10.346 kB
react-divider
Divider
14.828 kB
5.375 kB
react-image
Image
9.041 kB
3.734 kB
react-input
Input
13.83 kB
4.958 kB
react-label
Label
8.177 kB
3.445 kB
react-link
Link
10.883 kB
4.449 kB
react-make-styles
makeStaticStyles (runtime)
7.59 kB
3.322 kB
react-make-styles
makeStyles + mergeClasses (runtime)
22.238 kB
8.411 kB
react-make-styles
makeStyles + mergeClasses (build time)
2.561 kB
1.206 kB
react-menu
Menu (including children components)
103.644 kB
31.979 kB
react-menu
Menu (including selectable components)
106.032 kB
32.349 kB
react-popover
Popover
99.149 kB
30.108 kB
react-portal
Portal
6.621 kB
2.226 kB
react-positioning
usePopper
22.808 kB
7.935 kB
react-provider
FluentProvider
14.056 kB
5.267 kB
react-slider
RangedSlider
39.807 kB
11.454 kB
react-slider
Slider
33.204 kB
10.302 kB
react-switch
Switch
25.311 kB
8.143 kB
react-text
Text - Default
10.603 kB
4.172 kB
react-text
Text - Wrappers
13.899 kB
4.513 kB
react-theme
Teams: all themes
25.334 kB
6.012 kB
react-theme
Teams: Light theme
16.937 kB
4.948 kB
react-tooltip
Tooltip
43.871 kB
15.165 kB
react-utilities
SSRProvider
189 B
161 B
🤖 This report was generated against 77492e6095e4ed5e8e5c168d506cb035dc956323

@size-auditor

size-auditor Bot commented Nov 2, 2021

Copy link
Copy Markdown

Asset size changes

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

Baseline commit: 77492e6095e4ed5e8e5c168d506cb035dc956323 (build)

return useStorybookGlobals();
}

export function setGlobalTheme(themeId: string): void {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought that exporting this was clearner than using the storybook channels and messages directly in react-components. Open to push back for this

@ling1726
ling1726 marked this pull request as ready for review November 2, 2021 15:04
@ling1726
ling1726 requested review from a team as code owners November 2, 2021 15:04
@fabricteam

fabricteam commented Nov 2, 2021

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1002 958 5000
BaseButton mount 1010 1005 5000
Breadcrumb mount 2899 2703 1000
ButtonNext mount 557 619 5000
Checkbox mount 1635 1671 5000
CheckboxBase mount 1409 1364 5000
ChoiceGroup mount 5059 5160 5000
ComboBox mount 998 1006 1000
CommandBar mount 10327 10573 1000
ContextualMenu mount 6573 6476 1000
DefaultButton mount 1238 1215 5000
DetailsRow mount 4188 3990 5000
DetailsRowFast mount 4065 3942 5000
DetailsRowNoStyles mount 3815 3838 5000
Dialog mount 2690 2712 1000
DocumentCardTitle mount 181 179 1000
Dropdown mount 3355 3347 5000
FluentProviderNext mount 3743 3779 5000
FluentProviderWithTheme mount 228 223 10
FluentProviderWithTheme virtual-rerender 95 87 10
FluentProviderWithTheme virtual-rerender-with-unmount 258 263 10
FocusTrapZone mount 1837 1843 5000
FocusZone mount 1741 1784 5000
IconButton mount 1868 1890 5000
Label mount 356 351 5000
Layer mount 3056 3145 5000
Link mount 499 498 5000
MakeStyles mount 1755 1798 50000
MenuButton mount 1672 1639 5000
MessageBar mount 2043 2036 5000
Nav mount 3493 3504 1000
OverflowSet mount 1104 1143 5000
Panel mount 2605 2561 1000
Persona mount 889 896 1000
Pivot mount 1493 1472 1000
PrimaryButton mount 1399 1369 5000
Rating mount 8329 8320 5000
SearchBox mount 1458 1433 5000
Shimmer mount 2772 2747 5000
Slider mount 2055 2206 5000
SpinButton mount 5296 5346 5000
Spinner mount 448 434 5000
SplitButton mount 3316 3328 5000
Stack mount 537 544 5000
StackWithIntrinsicChildren mount 1800 1838 5000
StackWithTextChildren mount 5119 5063 5000
SwatchColorPicker mount 11019 11455 5000
TagPicker mount 2759 2820 5000
TeachingBubble mount 12941 13244 5000
Text mount 477 459 5000
TextField mount 1493 1471 5000
ThemeProvider mount 1178 1227 5000
ThemeProvider virtual-rerender 615 611 5000
ThemeProvider virtual-rerender-with-unmount 2009 2029 5000
Toggle mount 864 857 5000
buttonNative mount 149 125 5000

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ButtonMinimalPerf.default 207 188 1.1:1
ChatDuplicateMessagesPerf.default 337 311 1.08:1
IconMinimalPerf.default 705 653 1.08:1
ListNestedPerf.default 636 602 1.06:1
HeaderSlotsPerf.default 843 800 1.05:1
ListMinimalPerf.default 564 539 1.05:1
PortalMinimalPerf.default 181 173 1.05:1
RadioGroupMinimalPerf.default 498 476 1.05:1
ReactionMinimalPerf.default 434 412 1.05:1
SegmentMinimalPerf.default 378 361 1.05:1
VideoMinimalPerf.default 696 663 1.05:1
AccordionMinimalPerf.default 171 164 1.04:1
AlertMinimalPerf.default 313 300 1.04:1
AttachmentMinimalPerf.default 185 178 1.04:1
AttachmentSlotsPerf.default 1159 1112 1.04:1
FlexMinimalPerf.default 302 291 1.04:1
FormMinimalPerf.default 473 453 1.04:1
ImageMinimalPerf.default 420 405 1.04:1
RefMinimalPerf.default 245 236 1.04:1
StatusMinimalPerf.default 770 741 1.04:1
BoxMinimalPerf.default 386 374 1.03:1
LabelMinimalPerf.default 418 405 1.03:1
LayoutMinimalPerf.default 403 391 1.03:1
ListWith60ListItems.default 706 687 1.03:1
LoaderMinimalPerf.default 738 717 1.03:1
CustomToolbarPrototype.default 4330 4222 1.03:1
ToolbarMinimalPerf.default 1036 1004 1.03:1
AnimationMinimalPerf.default 440 431 1.02:1
CardMinimalPerf.default 601 591 1.02:1
CarouselMinimalPerf.default 513 502 1.02:1
DatepickerMinimalPerf.default 5847 5731 1.02:1
DropdownManyItemsPerf.default 743 730 1.02:1
EmbedMinimalPerf.default 4501 4397 1.02:1
HeaderMinimalPerf.default 408 401 1.02:1
ItemLayoutMinimalPerf.default 1304 1281 1.02:1
PopupMinimalPerf.default 607 595 1.02:1
SplitButtonMinimalPerf.default 4658 4548 1.02:1
TableManyItemsPerf.default 2057 2018 1.02:1
TextAreaMinimalPerf.default 590 577 1.02:1
ChatMinimalPerf.default 692 684 1.01:1
CheckboxMinimalPerf.default 2815 2798 1.01:1
DialogMinimalPerf.default 800 796 1.01:1
DividerMinimalPerf.default 389 387 1.01:1
DropdownMinimalPerf.default 3223 3185 1.01:1
GridMinimalPerf.default 362 360 1.01:1
InputMinimalPerf.default 1388 1376 1.01:1
MenuMinimalPerf.default 888 877 1.01:1
ProviderMergeThemesPerf.default 1715 1696 1.01:1
SkeletonMinimalPerf.default 388 384 1.01:1
SliderMinimalPerf.default 1764 1750 1.01:1
TableMinimalPerf.default 422 418 1.01:1
TreeMinimalPerf.default 859 852 1.01:1
AvatarMinimalPerf.default 201 201 1:1
ButtonOverridesMissPerf.default 1865 1871 1:1
MenuButtonMinimalPerf.default 1771 1778 1:1
TooltipMinimalPerf.default 1129 1125 1:1
ButtonSlotsPerf.default 590 603 0.98:1
ProviderMinimalPerf.default 1177 1196 0.98:1
TextMinimalPerf.default 357 366 0.98:1
ChatWithPopoverPerf.default 401 414 0.97:1
ListCommonPerf.default 695 724 0.96:1
TreeWith60ListItems.default 191 200 0.96:1
RosterPerf.default 1274 1390 0.92:1

@codesandbox-ci

codesandbox-ci Bot commented Nov 2, 2021

Copy link
Copy Markdown

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 94c5687:

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

Comment thread packages/react-components/src/DocsComponents/FluentDocsHeader.stories.tsx Outdated
Comment thread packages/react-storybook-addon/src/hooks.ts Outdated
@Hotell Hotell removed their assignment Nov 4, 2021
@ling1726

ling1726 commented Nov 5, 2021

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

Comment thread packages/react-components/src/DocsComponents/ThemePicker.stories.tsx Outdated
@ling1726
ling1726 requested a review from a team as a code owner November 5, 2021 12:31
@ling1726
ling1726 merged commit 452cf09 into microsoft:master Nov 5, 2021
mlp73 pushed a commit to mlp73/fluentui that referenced this pull request Jan 17, 2022
…crosoft#20448)

* experiment(storybook): Version picker

Chromatic stores published storybooks with commits, we can simply build
an azure function to keep the version -> commit mapping and integrate a
picker into the docs page

* Change files

* use fluent menu

* cleanup

* add network fetch

* use addon

* remove old

* update deps

* update stypes

* update md

* remove export

* chore(storybook): Add theme picker to storybook toolbar

Adds the theme picker to the storybook toolbar for internal development.
The global types are exported since they will be used for the docs page.

* remove unnecessary changes

* update change

* chore(storybook): Add custom DocsContainer to react-components storybook

Initialize a custom `FluentDocsContainer` and  FluentDocsHeader` to the
react-components storybook for future toolbar items like theme and
version picker.

This custom header is required since our future plans to build with
`--docs` will remove the native storybook toolbar

* Change files

* add docstring

* remove font family style

* init theme picker

* revert manager

* revert .storybook

* remove dupe export

* export

* README

* use active theme

* add docstring

* Change files

* fix md

* drop icon

* update md

* set global theme to react-components

* add container to page

* use type

* header styling

* styling updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react-components docs: theme switcher

7 participants