1
1
import type { Theme } from '@fluentui-react-native/framework' ;
2
+ import { isHighContrast } from '@fluentui-react-native/theming-utils' ;
2
3
import type { TokenSettings } from '@fluentui-react-native/use-styling' ;
3
4
4
5
import type { ButtonTokens } from './Button.types' ;
5
6
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
+
6
12
export const defaultButtonColorTokens : TokenSettings < ButtonTokens , Theme > = ( t : Theme ) =>
7
13
( {
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 ,
12
18
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 ,
17
23
} ,
18
24
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 ,
23
29
} ,
24
30
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 ,
29
35
} ,
30
36
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 ,
35
41
} ,
36
42
primary : {
37
43
backgroundColor : t . colors . brandBackground ,
@@ -45,9 +51,12 @@ export const defaultButtonColorTokens: TokenSettings<ButtonTokens, Theme> = (t:
45
51
iconColor : t . colors . neutralForegroundDisabled ,
46
52
} ,
47
53
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 ,
49
58
color : t . colors . neutralForegroundOnBrandHover ,
50
- borderColor : t . colors . brandBackgroundHover ,
59
+ borderColor : t . colors . brandBackground ,
51
60
iconColor : t . colors . neutralForegroundOnBrandHover ,
52
61
} ,
53
62
pressed : {
@@ -57,40 +66,45 @@ export const defaultButtonColorTokens: TokenSettings<ButtonTokens, Theme> = (t:
57
66
iconColor : t . colors . neutralForegroundOnBrandPressed ,
58
67
} ,
59
68
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 ,
64
73
} ,
65
74
} ,
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.
66
80
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 ,
71
85
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 ,
76
90
} ,
77
91
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 ,
82
96
} ,
83
97
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 ,
88
102
} ,
89
103
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 ,
94
108
} ,
95
109
} ,
96
110
} as ButtonTokens ) ;
0 commit comments