-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathMenuItem.styling.ts
More file actions
86 lines (82 loc) · 2.89 KB
/
MenuItem.styling.ts
File metadata and controls
86 lines (82 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { Platform } from 'react-native';
import type { Theme, UseStylingOptions } from '@fluentui-react-native/framework';
import { buildProps } from '@fluentui-react-native/framework';
import { borderStyles, fontStyles, layoutStyles } from '@fluentui-react-native/tokens';
import type { MenuItemProps, MenuItemTokens, MenuItemSlotProps } from './MenuItem.types';
import { menuItemName } from './MenuItem.types';
import { defaultMenuItemTokens } from './MenuItemTokens';
export const menuItemStates: (keyof MenuItemTokens)[] = ['hovered', 'focused', 'highlighted', 'pressed', 'disabled'];
export const stylingSettings: UseStylingOptions<MenuItemProps, MenuItemSlotProps, MenuItemTokens> = {
tokens: [defaultMenuItemTokens, menuItemName],
states: menuItemStates,
slotProps: {
root: buildProps(
(tokens: MenuItemTokens, theme: Theme) => ({
style: {
alignItems: 'center',
backgroundColor: tokens.backgroundColor,
display: 'flex',
flexDirection: 'row',
...layoutStyles.from(tokens, theme),
...borderStyles.from(tokens, theme),
},
}),
['backgroundColor', ...borderStyles.keys, ...layoutStyles.keys],
),
checkmark: buildProps(
(tokens: MenuItemTokens) => ({
style: {
height: tokens.checkmarkSize,
width: tokens.checkmarkSize,
marginEnd: Platform.OS === 'android' ? tokens.marginEndForCheckedAndroid : tokens.gap,
},
}),
['checkmarkSize', 'gap'],
),
content: buildProps(
(tokens: MenuItemTokens, theme: Theme) => {
return {
color: tokens.color,
style: {
flexGrow: 1,
...fontStyles.from(tokens, theme),
},
};
},
['color', ...fontStyles.keys],
),
iconPlaceholder: buildProps(
(tokens: MenuItemTokens) => ({
style: {
minHeight: tokens.iconSize,
minWidth: tokens.iconSize,
alignItems: 'center',
justifyContent: 'center',
marginEnd: tokens.gap,
},
}),
['checkmarkSize', 'gap'],
),
imgIcon: buildProps(
(tokens: MenuItemTokens) => ({
style: { tintColor: tokens.iconColor, height: tokens.iconSize, width: tokens.iconSize },
}),
['gap', 'iconColor', 'iconSize'],
),
fontOrSvgIcon: buildProps(
(tokens: MenuItemTokens) => ({ color: tokens.iconColor, size: tokens.iconSize }),
['gap', 'iconColor', 'iconSize'],
),
submenuIndicator: buildProps(
(tokens: MenuItemTokens) => {
return {
color: tokens.submenuIndicatorColor,
height: tokens.submenuIndicatorSize,
width: tokens.submenuIndicatorSize,
viewBox: `0 0 ${tokens.submenuIndicatorSize} ${tokens.submenuIndicatorSize}`,
};
},
['submenuIndicatorColor', 'submenuIndicatorPadding', 'submenuIndicatorSize'],
),
},
};