Skip to content

chore: refactor SpinButton to use makeResetStyles#26849

Closed
spmonahan wants to merge 5 commits intomicrosoft:masterfrom
spmonahan:spinbutton/make-reset-styles
Closed

chore: refactor SpinButton to use makeResetStyles#26849
spmonahan wants to merge 5 commits intomicrosoft:masterfrom
spmonahan:spinbutton/make-reset-styles

Conversation

@spmonahan
Copy link
Contributor

Previous Behavior

SpinButton was implemented before Griffel's makeResetStyles() function was available. SpinButton also called react-input's useStyles() hook as a way to re-use complex styling of the control.

New Behavior

SpinButton uses makeResetStyles to reduce the number of class names present on the control. The dependency on react-input has been removed and the relevant styles are moved into useSpinButtonStyles. This creates code duplication but allows SpinButton to have better control over how its class names are generated.

Class name comparison table

Story Old New
default/controlled/uncontrolled/step 219 😱 16
bounds (when at max bound) 221 😱 26
display value 219 16
size (small) 219 33
appearance (underline) 194 43
appearance (filled lighter) 207 41
appearance (filled darker) 211 32
disabled 187 30

- remove dependency on react-input's useStyles hook
- copy styles from input
@size-auditor
Copy link

size-auditor bot commented Feb 14, 2023

Asset size changes

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

Baseline commit: 71029f8350e58c7fdde6c49dfca3744509b8e6ed (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 14, 2023

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-spinbutton
SpinButton
45.184 kB
13.043 kB
39.721 kB
9.905 kB
-5.463 kB
-3.138 kB
react-spinbutton
SpinButtonField
54.447 kB
15.634 kB
48.657 kB
12.372 kB
-5.79 kB
-3.262 kB
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.738 kB
56.207 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 71029f8350e58c7fdde6c49dfca3744509b8e6ed

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 14, 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 f68a9f3:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Feb 14, 2023

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1304 1282 5000
Button mount 909 930 5000
Field mount 1925 1921 5000
FluentProvider mount 1531 1555 5000
FluentProviderWithTheme mount 585 578 10
FluentProviderWithTheme virtual-rerender 545 556 10
FluentProviderWithTheme virtual-rerender-with-unmount 576 581 10
InfoButton mount 523 510 5000
MakeStyles mount 1966 1985 50000
Persona mount 2841 2846 5000
SpinButton mount 2340 2223 5000

@spmonahan spmonahan force-pushed the spinbutton/make-reset-styles branch from 3670a15 to f68a9f3 Compare February 15, 2023 01:13
@fabricteam
Copy link
Collaborator

🕵 fluentuiv9 No visual regressions between this PR and main

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.

5 participants