Skip to content

Conversation

@behowell
Copy link
Contributor

@behowell behowell commented Feb 10, 2023

Previous Behavior

Input styles were written before griffel's makeResetStyles was available.

New Behavior

Refactor the Input component's styles to use griffel reset styles for the base styles on each slot.

Move the styles for some of the default states (enabled; size=medium; appearance=outline) into the reset styles. In some cases, this required updating the per-state overrides: for example, previously appearance=underline added a single bottom border; but now it removes the top/left/right borders because the base styles include all of the borders.

There are two different reset style classes for the root slot. When enabled (aka "interactive"), Input adds a large number of styles to account for the focus visuals. However, those styles aren't present for the disabled state. useInputStyles picks between the two reset styles, useRootInteractiveClassName or useRootNonInteractiveClassName, based on whether it's enabled.

This significantly reduces the number of classNames applied to the slots of Input. Here are some counts of classNames added (sum of classNames on all slots of Input) for some of the examples on storybook for Input.

Scenario Old New
default 94 13
appearance: underline 81 19
appearance: filled-lighter 90 14
contentBefore 100 15
contentBefore + contentAfter 106 17
disabled 63 20
size: small 94 20
size: large 94 25

@behowell behowell self-assigned this Feb 10, 2023
@size-auditor
Copy link

size-auditor bot commented Feb 10, 2023

Asset size changes

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

Baseline commit: 88e04372fc18f70429c015293f2370097a966374 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 10, 2023

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-input
Input
24.853 kB
8.136 kB
23.89 kB
7.246 kB
-963 B
-890 B
react-input
InputField
35.058 kB
11.096 kB
33.626 kB
10.099 kB
-1.432 kB
-997 B
react-spinbutton
SpinButton
45.184 kB
13.043 kB
44.079 kB
12.356 kB
-1.105 kB
-687 B
react-spinbutton
SpinButtonField
54.447 kB
15.634 kB
53.015 kB
14.806 kB
-1.432 kB
-828 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
64.09 kB
17.544 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
201.941 kB
56.241 kB
react-components
react-components: FluentProvider & webLightTheme
35.049 kB
11.533 kB
react-portal-compat
PortalCompatProvider
6.324 kB
2.129 kB
🤖 This report was generated against 88e04372fc18f70429c015293f2370097a966374

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 10, 2023

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 acf8705:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 10, 2023

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1319 1346 5000
Button mount 929 938 5000
Field mount 2048 2057 5000
FluentProvider mount 1642 1627 5000
FluentProviderWithTheme mount 636 629 10
FluentProviderWithTheme virtual-rerender 595 595 10
FluentProviderWithTheme virtual-rerender-with-unmount 628 626 10
InfoButton mount 565 557 5000
MakeStyles mount 1900 1928 50000
Persona mount 3011 2978 5000
SpinButton mount 2560 2499 5000

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 13, 2023

🕵 fluentuiv9 No visual regressions between this PR and main

@behowell behowell marked this pull request as ready for review February 14, 2023 19:03
@behowell behowell requested review from a team and spmonahan as code owners February 14, 2023 19:03
@behowell behowell merged commit 2a39824 into microsoft:master Feb 15, 2023
@behowell behowell deleted the input/reset-styles branch February 15, 2023 21:19
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.

4 participants