Skip to content

react-select: update styles based on design review#24339

Merged
smhigley merged 6 commits into
microsoft:masterfrom
smhigley:select-styles
Oct 27, 2022
Merged

react-select: update styles based on design review#24339
smhigley merged 6 commits into
microsoft:masterfrom
smhigley:select-styles

Conversation

@smhigley

Copy link
Copy Markdown
Contributor

Fixes #23924

Before:

screenshot of small/medium/large select variants, showing some spacing issues

After:

screenshot of the same select variants, showing fixed spacing issues

@codesandbox-ci

codesandbox-ci Bot commented Aug 11, 2022

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 9a59600:

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

@fabricteam

fabricteam commented Aug 11, 2022

Copy link
Copy Markdown
Collaborator

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-select
Select
21.61 kB
7.568 kB
23.255 kB
7.954 kB
1.645 kB
386 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
62.94 kB
17.663 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.603 kB
52.909 kB
react-components
react-components: FluentProvider & webLightTheme
33.446 kB
11.033 kB
react-portal-compat
PortalCompatProvider
5.857 kB
1.978 kB
🤖 This report was generated against 870f51fc39736198871559d6e12ece5663b0525f

@size-auditor

size-auditor Bot commented Aug 11, 2022

Copy link
Copy Markdown

Asset size changes

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

Baseline commit: 870f51fc39736198871559d6e12ece5663b0525f (build)

@fabricteam

fabricteam commented Aug 11, 2022

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1294 1267 5000
Button mount 920 929 5000
FluentProvider mount 1485 1486 5000
FluentProviderWithTheme mount 575 572 10
FluentProviderWithTheme virtual-rerender 536 535 10
FluentProviderWithTheme virtual-rerender-with-unmount 579 573 10
MakeStyles mount 1952 1941 50000
SpinButton mount 2326 2336 5000

@smhigley

Copy link
Copy Markdown
Contributor Author

Verified the screener changes are the intentional ones 👍

@layershifter layershifter removed their assignment Aug 12, 2022
...shorthands.padding('0', tokens.spacingHorizontalSNudge),
paddingBottom: 0,
paddingLeft: `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`,
paddingRight: `calc(${tokens.spacingHorizontalSNudge}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this feels like a LOT of calculations to get padding. is there some other way to create this space? is our layout approach not sufficient for this? Do we need to switch to grid or something?

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.

it's b/c it's a <select> element, so the caret is absolutely positioned over the actual <select>, and can't be a child of it. I'm not sure if there's really a better way to do it :/

height: fieldHeights.small,
...shorthands.padding('0', tokens.spacingHorizontalSNudge),
paddingBottom: 0,
paddingLeft: 'var(--selectSpacingLeftS)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is just a suggestion, feel free to disregard. What about taking CSS vars one step further and just having one for left and one for right and then conditionally setting the values?

It would look roughly like:

makeStyles({
  base: {
    paddingLeft: 'var(--selectSpacingLeft)',
    paddingRight: 'var(--selectSpacingRight)'
  },
  small: {
    '--selectSpacingLeft': paddingLeft.small,
    '--selectSpacingRight': paddingRight.small
  },
  medium: {
    '--selectSpacingLeft': paddingLeft.medium,
    '--selectSpacingRight': paddingRight.medium
  }
  // ....
})

I think this is a bit simpler because there are really only two variables and their values change based on the size rather than having six variables. It will also eliminate a couple lines of code :)

Here's a working Codesandbox example.

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.

The reason I didn't do that is because I thought having separate variables would make it easier for someone who wants to override the spacing across all sizes, just by manipulating variables. I suppose it depends on how likely you think it is for app authors to be mixing sizes within the same app, while also wanting to override their spacing styles 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So the case is that:

  1. There are Selects of multiple sizes on the page
  2. Authors want to modify the spacing on just the medium sizes Selects across the page but leave the smalls and larges alone?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was thinking about this some more and if we want to support overriding CSS vars we should consider those vars as part of the component API. I know that we cannot technically prevent users for overriding the CSS vars but I think we should consider them private, internal implementation details.

The spacing values are based on spacing values from the theme so the correct way to change them is to change the theme imo. I realize that targeting the CSS vars provides finer-grained control over the spacing here as an author can change just the spacing for Select rather than the entire theme but nested ThemeProviders can address that and I don't know that we need this feature right now so I'm in favor of not going out of our way to support it at this time. We can always add it later. Do you know of a case where we need to support this scenario?

small: {
height: fieldHeights.small,
...shorthands.padding('0', tokens.spacingHorizontalSNudge),
paddingBottom: 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The paddingBottom/Top values are the same for all sizes. Can these be moved to the base styles?

@smhigley smhigley merged commit fe895d6 into microsoft:master Oct 27, 2022
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
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.

[Bug]: Select visual bug bash

6 participants