Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "fix: update styles based on design review",
"packageName": "@fluentui/react-select",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const iconSizes = {
large: '24px',
};

// TODO: This 400 style is not in the typography styles.
// This 400 style is not in the typography styles.
// May need a design change
const contentSizes = {
400: {
Expand All @@ -31,6 +31,36 @@ const fieldHeights = {
large: '40px',
};

/* Since the <select> element must span the full width and cannot have children,
* the right padding needs to be calculated from the sum of the following:
* 1. Field padding-right
* 2. Icon width
* 3. Content-icon spacing
* 4. Content inner padding
*/
const paddingRight = {
small: `calc(${tokens.spacingHorizontalSNudge}
+ ${iconSizes.small}
+ ${tokens.spacingHorizontalXXS}
+ ${tokens.spacingHorizontalXXS})`,
medium: `calc(${tokens.spacingHorizontalMNudge}
+ ${iconSizes.medium}
+ ${tokens.spacingHorizontalXXS}
+ ${tokens.spacingHorizontalXXS})`,
large: `calc(${tokens.spacingHorizontalM}
+ ${iconSizes.large}
+ ${tokens.spacingHorizontalSNudge}
+ ${tokens.spacingHorizontalSNudge})`,
};

/* Left padding is calculated from the outer padding + inner content padding values
* since <select> can't have additional child content or custom inner layout */
const paddingLeft = {
small: `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`,
medium: `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`,
large: `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`,
};

/* end of shared values */

const useRootStyles = makeStyles({
Expand Down Expand Up @@ -91,7 +121,9 @@ const useSelectStyles = makeStyles({
boxShadow: 'none',
boxSizing: 'border-box',
color: tokens.colorNeutralForeground1,
cursor: 'pointer',
flexGrow: 1,
maxWidth: '100%',

':focus': {
outlineWidth: '2px',
Expand All @@ -108,25 +140,45 @@ const useSelectStyles = makeStyles({
...shorthands.borderColor('GrayText'),
},
},

small: {
height: fieldHeights.small,
...shorthands.padding('0', tokens.spacingHorizontalSNudge),
paddingBottom: 0,
Copy link
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?

paddingLeft: paddingLeft.small,
paddingRight: paddingRight.small,
paddingTop: 0,
...typographyStyles.caption1,
},
medium: {
height: fieldHeights.medium,
...shorthands.padding('0', tokens.spacingHorizontalMNudge),
paddingBottom: 0,
paddingLeft: paddingLeft.medium,
paddingRight: paddingRight.medium,
paddingTop: 0,
...typographyStyles.body1,
},
large: {
height: fieldHeights.large,
...shorthands.padding('0', tokens.spacingHorizontalM),
paddingBottom: 0,
paddingLeft: paddingLeft.large,
paddingRight: paddingRight.large,
paddingTop: 0,
...contentSizes[400],
},
outline: {
backgroundColor: tokens.colorNeutralBackground1,
...shorthands.border('1px', 'solid', tokens.colorNeutralStroke1),
borderBottomColor: tokens.colorNeutralStrokeAccessible,

'&:hover': {
...shorthands.borderColor(tokens.colorNeutralStroke1Hover),
borderBottomColor: tokens.colorNeutralStrokeAccessible,
},

'&:active': {
...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),
borderBottomColor: tokens.colorNeutralStrokeAccessible,
},
},
underline: {
backgroundColor: tokens.colorTransparentBackground,
Expand All @@ -147,7 +199,6 @@ const useIconStyles = makeStyles({
color: tokens.colorNeutralStrokeAccessible,
display: 'block',
position: 'absolute',
right: tokens.spacingHorizontalMNudge,
pointerEvents: 'none',

// the SVG must have display: block for accurate positioning
Expand All @@ -165,22 +216,19 @@ const useIconStyles = makeStyles({
small: {
fontSize: iconSizes.small,
height: iconSizes.small,
paddingRight: tokens.spacingHorizontalSNudge,
paddingLeft: tokens.spacingHorizontalXXS,
right: tokens.spacingHorizontalSNudge,
width: iconSizes.small,
},
medium: {
fontSize: iconSizes.medium,
height: iconSizes.medium,
paddingRight: tokens.spacingHorizontalM,
paddingLeft: tokens.spacingHorizontalXXS,
right: tokens.spacingHorizontalMNudge,
width: iconSizes.medium,
},
large: {
fontSize: iconSizes.large,
height: iconSizes.large,
paddingRight: tokens.spacingHorizontalM,
paddingLeft: tokens.spacingHorizontalSNudge,
right: tokens.spacingHorizontalM,
width: iconSizes.large,
},
});
Expand Down