Skip to content

Commit 7149414

Browse files
authored
fix(macOS Button): Use Fluent 2 alias tokens (#3778)
1 parent 1739458 commit 7149414

File tree

5 files changed

+82
-47
lines changed

5 files changed

+82
-47
lines changed

apps/fluent-tester/src/TestComponents/Button/ButtonVariantTestSection.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const ButtonVariantTest: React.FunctionComponent = () => {
2323
<Button appearance="subtle" style={commonTestStyles.vmargin}>
2424
Subtle
2525
</Button>
26+
<Button disabled appearance="subtle" style={commonTestStyles.vmargin}>
27+
Subtle Disabled
28+
</Button>
2629
<Button loading>Loading Button</Button>
2730
<Button block style={commonTestStyles.vmargin}>
2831
Block

apps/fluent-tester/src/TestComponents/Common/styles.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StyleSheet } from 'react-native';
1+
import { Platform, StyleSheet } from 'react-native';
22

33
import type { IStackProps } from '@fluentui-react-native/stack';
44

@@ -118,6 +118,10 @@ export const fluentTesterStyles = StyleSheet.create({
118118
testListItem: {
119119
width: '100%',
120120
borderRadius: 0,
121+
...(Platform.OS === 'macos' && {
122+
borderColor: 'transparent',
123+
borderRadius: 5,
124+
}),
121125
justifyContent: 'flex-start',
122126
},
123127
testListSeparator: { marginHorizontal: 8 },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "fix(macOS Button): Use Fluent 2 alias tokens",
4+
"packageName": "@fluentui-react-native/button",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fixup Sidebar tabs in High Contrast",
4+
"packageName": "@fluentui-react-native/tester",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
11
import type { Theme } from '@fluentui-react-native/framework';
2+
import { isHighContrast } from '@fluentui-react-native/theming-utils';
23
import type { TokenSettings } from '@fluentui-react-native/use-styling';
34

45
import type { ButtonTokens } from './Button.types';
56

7+
// https://github.com/microsoft/fluentui-react-native/issues/3782
8+
// The macOS brand ramps from the token package use blue from Fluent V1,
9+
// instead of communication blue. Update the packages to use the newly
10+
// defined Fluent 2 brand ramp.
11+
612
export const defaultButtonColorTokens: TokenSettings<ButtonTokens, Theme> = (t: Theme) =>
713
({
8-
backgroundColor: t.colors.defaultBackground,
9-
color: t.colors.defaultContent,
10-
borderColor: t.colors.defaultBorder,
11-
iconColor: t.colors.defaultContent,
14+
backgroundColor: t.colors.neutralBackground2,
15+
color: t.colors.neutralForeground2,
16+
borderColor: t.colors.neutralStroke2,
17+
iconColor: t.colors.neutralForeground2,
1218
disabled: {
13-
backgroundColor: t.colors.defaultDisabledBackground,
14-
color: t.colors.defaultDisabledContent,
15-
borderColor: t.colors.defaultDisabledBorder,
16-
iconColor: t.colors.defaultDisabledIcon,
19+
backgroundColor: t.colors.neutralBackground2,
20+
color: t.colors.neutralForegroundDisabled,
21+
borderColor: t.colors.neutralStrokeDisabled,
22+
iconColor: t.colors.neutralForegroundDisabled,
1723
},
1824
hovered: {
19-
backgroundColor: t.colors.defaultBackground,
20-
color: t.colors.defaultContent,
21-
borderColor: t.colors.defaultBorder,
22-
iconColor: t.colors.defaultHoveredIcon,
25+
backgroundColor: t.colors.neutralBackground2,
26+
color: t.colors.neutralForeground2,
27+
borderColor: t.colors.neutralStroke2,
28+
iconColor: t.colors.neutralForeground2,
2329
},
2430
pressed: {
25-
backgroundColor: t.colors.defaultPressedBackground,
26-
color: t.colors.defaultPressedContent,
27-
borderColor: t.colors.defaultBorder,
28-
iconColor: t.colors.defaultPressedIcon,
31+
backgroundColor: t.colors.neutralBackground2Pressed,
32+
color: t.colors.neutralForeground2,
33+
borderColor: t.colors.neutralStroke2,
34+
iconColor: t.colors.neutralForeground2,
2935
},
3036
focused: {
31-
backgroundColor: t.colors.defaultFocusedBackground,
32-
color: t.colors.defaultFocusedContent,
33-
borderColor: t.colors.defaultFocusedBorder,
34-
icon: t.colors.defaultFocusedIcon,
37+
backgroundColor: t.colors.neutralBackground2,
38+
color: t.colors.neutralForeground2,
39+
borderColor: t.colors.neutralStroke2,
40+
icon: t.colors.neutralForeground2,
3541
},
3642
primary: {
3743
backgroundColor: t.colors.brandBackground,
@@ -45,9 +51,12 @@ export const defaultButtonColorTokens: TokenSettings<ButtonTokens, Theme> = (t:
4551
iconColor: t.colors.neutralForegroundDisabled,
4652
},
4753
hovered: {
48-
backgroundColor: t.colors.brandBackgroundHover,
54+
// https://github.com/microsoft/fluentui-react-native/issues/3780
55+
// brandBackgroundHover should match brandBackground, but does not. Update
56+
// `backgroundColor` and `borderColor` here when fixed in design token package.
57+
backgroundColor: t.colors.brandBackground,
4958
color: t.colors.neutralForegroundOnBrandHover,
50-
borderColor: t.colors.brandBackgroundHover,
59+
borderColor: t.colors.brandBackground,
5160
iconColor: t.colors.neutralForegroundOnBrandHover,
5261
},
5362
pressed: {
@@ -57,40 +66,45 @@ export const defaultButtonColorTokens: TokenSettings<ButtonTokens, Theme> = (t:
5766
iconColor: t.colors.neutralForegroundOnBrandPressed,
5867
},
5968
focused: {
60-
backgroundColor: t.colors.brandBackgroundHover,
61-
color: t.colors.neutralForegroundOnBrandHover,
62-
borderColor: t.colors.strokeFocus2,
63-
iconColor: t.colors.neutralForegroundOnBrandHover,
69+
backgroundColor: t.colors.brandBackground,
70+
color: t.colors.neutralForegroundOnBrand,
71+
borderColor: t.colors.brandBackground,
72+
iconColor: t.colors.neutralForegroundOnBrand,
6473
},
6574
},
75+
// https://github.com/microsoft/fluentui-react-native/issues/3781
76+
// Subtle Button should match Titlebar buttons on macOS, which:
77+
// - Have a hover state (unlike most buttons in macOS)...
78+
// - Except in High Contrast, where instead they have a border around them
79+
// While the alias tokens aren't updated, manually check for High Contrast.
6680
subtle: {
67-
backgroundColor: t.colors.ghostBackground,
68-
color: t.colors.ghostContent,
69-
borderColor: t.colors.ghostBorder,
70-
iconColor: t.colors.ghostIcon,
81+
backgroundColor: t.colors.subtleBackground,
82+
color: t.colors.brandForeground1,
83+
borderColor: t.colors.transparentStroke,
84+
iconColor: t.colors.brandForeground1,
7185
disabled: {
72-
color: t.colors.ghostDisabledContent,
73-
borderColor: t.colors.ghostDisabledBorder,
74-
backgroundColor: t.colors.ghostDisabledBackground,
75-
iconColor: t.colors.ghostDisabledIcon,
86+
backgroundColor: t.colors.subtleBackground,
87+
color: t.colors.brandForeground1Disabled,
88+
borderColor: t.colors.transparentStrokeDisabled,
89+
iconColor: t.colors.brandForeground1Disabled,
7690
},
7791
hovered: {
78-
backgroundColor: t.colors.ghostHoveredBackground,
79-
color: t.colors.ghostHoveredContent,
80-
borderColor: t.colors.ghostHoveredBorder,
81-
iconColor: t.colors.ghostHoveredIcon,
92+
backgroundColor: isHighContrast(t) ? t.colors.subtleBackground : t.colors.subtleBackgroundHover,
93+
color: isHighContrast(t) ? t.colors.brandForeground1 : t.colors.brandForeground1Hover,
94+
borderColor: t.colors.transparentStroke,
95+
iconColor: isHighContrast(t) ? t.colors.brandForeground1 : t.colors.brandForeground1Hover,
8296
},
8397
pressed: {
84-
backgroundColor: t.colors.ghostPressedBackground,
85-
borderColor: t.colors.ghostPressedBorder,
86-
color: t.colors.ghostPressedContent,
87-
icon: t.colors.ghostPressedIcon,
98+
backgroundColor: t.colors.subtleBackgroundPressed,
99+
color: t.colors.brandForeground1Pressed,
100+
borderColor: t.colors.transparentStroke,
101+
iconColor: t.colors.brandForeground1Pressed,
88102
},
89103
focused: {
90-
borderColor: t.colors.ghostFocusedBorder,
91-
backgroundColor: t.colors.ghostFocusedBackground,
92-
color: t.colors.ghostFocusedContent,
93-
icon: t.colors.ghostFocusedIcon,
104+
backgroundColor: t.colors.subtleBackground,
105+
color: t.colors.brandForeground1,
106+
borderColor: t.colors.transparentStroke,
107+
iconColor: t.colors.brandForeground1,
94108
},
95109
},
96110
} as ButtonTokens);

0 commit comments

Comments
 (0)