Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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": "patch",
"comment": "chore: Cleaning up tokens in Button components so they better adhere to the design spec.",
"packageName": "@fluentui/react-button",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ const useRootStyles = makeStyles({
},
primary: {
backgroundColor: tokens.colorBrandBackground,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,

':hover': {
backgroundColor: tokens.colorBrandBackgroundHover,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,
},

':hover:active': {
backgroundColor: tokens.colorBrandBackgroundPressed,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,
},
},
Expand All @@ -123,35 +123,35 @@ const useRootStyles = makeStyles({
},
subtle: {
backgroundColor: tokens.colorSubtleBackground,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,

':hover': {
backgroundColor: tokens.colorSubtleBackgroundHover,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,
},

':hover:active': {
backgroundColor: tokens.colorSubtleBackgroundPressed,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,
},
},
transparent: {
backgroundColor: tokens.colorTransparentBackground,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,

':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2BrandHover,
},

':hover:active': {
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2BrandPressed,
},
},
Expand Down Expand Up @@ -278,53 +278,53 @@ const useRootDisabledStyles = makeStyles({
},
},
primary: {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
secondary: {
/* The secondary styles are exactly the same as the base styles. */
},
subtle: {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackground,
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
transparent: {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackground,
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
});

const useRootFocusStyles = makeStyles({
base: createCustomFocusIndicatorStyle({
...shorthands.borderColor('transparent'),
outlineColor: 'transparent',
...shorthands.borderColor(tokens.colorTransparentStroke),
outlineColor: tokens.colorTransparentStroke,
outlineWidth: tokens.strokeWidthThick,
outlineStyle: 'solid',
boxShadow: `
Expand Down Expand Up @@ -416,6 +416,17 @@ const useIconStyles = makeStyles({
[iconSpacingVar]: tokens.spacingHorizontalSNudge,
},

// Appearance variations
subtle: {
':hover': {
color: tokens.colorNeutralForeground2BrandHover,
},

':hover:active': {
color: tokens.colorNeutralForeground2BrandPressed,
},
},

// Icon position variations
before: {
marginRight: `var(${iconSpacingVar})`,
Expand Down Expand Up @@ -467,6 +478,7 @@ export const useButtonStyles_unstable = (state: ButtonState): ButtonState => {
buttonClassNames.icon,
iconStyles.base,
state.root.children !== undefined && state.root.children !== null && iconStyles[iconPosition],
appearance === 'subtle' && iconStyles.subtle,
iconStyles[size],
state.icon.className,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useRootStyles = makeStyles({

':hover:active': {
[`& .${compoundButtonClassNames.secondaryContent}`]: {
color: tokens.colorNeutralForeground2BrandPressed,
color: tokens.colorNeutralForeground2BrandHover,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ const useRootStyles = makeStyles({
},
primary: {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralForegroundInverted,
borderRightColor: tokens.colorNeutralForegroundOnBrand,
},

':hover': {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralForegroundInverted,
borderRightColor: tokens.colorNeutralForegroundOnBrand,
},
},

':hover:active': {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralForegroundInverted,
borderRightColor: tokens.colorNeutralForegroundOnBrand,
},
},
},
Expand All @@ -70,7 +70,7 @@ const useRootStyles = makeStyles({
},
subtle: {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralStroke1Hover,
borderRightColor: tokens.colorNeutralStroke1,
},

':hover': {
Expand All @@ -81,13 +81,13 @@ const useRootStyles = makeStyles({

':hover:active': {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralStroke1Hover,
borderRightColor: tokens.colorNeutralStroke1Pressed,
},
},
},
transparent: {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralStroke1Hover,
borderRightColor: tokens.colorNeutralStroke1,
},

':hover': {
Expand All @@ -98,7 +98,7 @@ const useRootStyles = makeStyles({

':hover:active': {
[`& .${splitButtonClassNames.primaryActionButton}`]: {
borderRightColor: tokens.colorNeutralStroke1Hover,
borderRightColor: tokens.colorNeutralStroke1Pressed,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ const useCheckedStyles = makeStyles({
},
primary: {
backgroundColor: tokens.colorBrandBackgroundSelected,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,

':hover': {
backgroundColor: tokens.colorBrandBackgroundHover,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,
},

':hover:active': {
backgroundColor: tokens.colorBrandBackgroundPressed,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForegroundOnBrand,
},
},
Expand All @@ -110,35 +110,35 @@ const useCheckedStyles = makeStyles({
},
subtle: {
backgroundColor: tokens.colorSubtleBackgroundSelected,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandSelected,
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,

':hover': {
backgroundColor: tokens.colorSubtleBackgroundHover,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,
},

':hover:active': {
backgroundColor: tokens.colorSubtleBackgroundPressed,
...shorthands.borderColor('transparent'),
color: tokens.colorNeutralForeground2BrandPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2,
},
},
transparent: {
backgroundColor: tokens.colorTransparentBackgroundSelected,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2BrandSelected,

':hover': {
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2BrandHover,
},

':hover:active': {
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
color: tokens.colorNeutralForeground2BrandPressed,
},
},
Expand Down Expand Up @@ -169,52 +169,68 @@ const useDisabledStyles = makeStyles({
/* No styles */
},
primary: {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
...shorthands.borderColor('transparent'),
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
secondary: {
/* The secondary styles are exactly the same as the base styles. */
},
subtle: {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackground,
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
transparent: {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackground,
...shorthands.borderColor(tokens.colorTransparentStroke),

':hover': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundHover,
...shorthands.borderColor(tokens.colorTransparentStroke),
},

':hover:active': {
backgroundColor: 'transparent',
...shorthands.borderColor('transparent'),
backgroundColor: tokens.colorTransparentBackgroundPressed,
...shorthands.borderColor(tokens.colorTransparentStroke),
},
},
});

const useIconStyles = makeStyles({
// Appearance variations
subtle: {
color: tokens.colorNeutralForeground2BrandSelected,

':hover': {
color: tokens.colorNeutralForeground2BrandHover,
},

':hover:active': {
color: tokens.colorNeutralForeground2BrandPressed,
},
},
});

export const useToggleButtonStyles_unstable = (state: ToggleButtonState): ToggleButtonState => {
const checkedStyles = useCheckedStyles();
const disabledStyles = useDisabledStyles();
const iconStyles = useIconStyles();

const { appearance, checked, disabled, disabledFocusable } = state;

Expand All @@ -235,7 +251,11 @@ export const useToggleButtonStyles_unstable = (state: ToggleButtonState): Toggle
);

if (state.icon) {
state.icon.className = mergeClasses(toggleButtonClassNames.icon, state.icon.className);
state.icon.className = mergeClasses(
toggleButtonClassNames.icon,
appearance === 'subtle' && iconStyles.subtle,
state.icon.className,
);
}

useButtonStyles_unstable(state);
Expand Down