-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathtokens.ts
More file actions
143 lines (129 loc) · 2.94 KB
/
Copy pathtokens.ts
File metadata and controls
143 lines (129 loc) · 2.94 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import type { ViewStyle } from 'react-native';
import { tokens } from '../../theme/tokens';
import type {
ColorRole,
Elevation,
ThemeShapeCorners,
TypescaleKey,
} from '../../theme/types';
export type Variant =
| 'primary'
| 'secondary'
| 'tertiary'
| 'tonalPrimary'
| 'tonalSecondary'
| 'tonalTertiary';
export type Size = 'default' | 'medium' | 'large';
type SizeSpec = {
container: number;
icon: number;
shape: keyof ThemeShapeCorners;
leading: number;
trailing: number;
iconLabelGap: number;
labelTypescale: TypescaleKey;
};
const sizes = {
default: {
container: 56,
icon: 24,
shape: 'large',
leading: 16,
trailing: 16,
iconLabelGap: 8,
labelTypescale: 'titleMedium',
},
medium: {
container: 80,
icon: 28,
shape: 'largeIncreased',
leading: 26,
trailing: 26,
iconLabelGap: 12,
labelTypescale: 'titleLarge',
},
large: {
container: 96,
icon: 36,
shape: 'extraLarge',
// (container - icon) / 2 keeps the icon centered inside the visible
// square when the Extended FAB collapses to icon-only width.
leading: 30,
trailing: 30,
iconLabelGap: 16,
labelTypescale: 'headlineSmall',
},
} as const satisfies Record<Size, SizeSpec>;
const stateElevation = {
enabled: 3,
hover: 4,
focus: 3,
pressed: 3,
} as const satisfies Record<string, Elevation>;
const variants = {
primary: {
container: 'primary',
content: 'onPrimary',
stateLayer: 'onPrimary',
},
secondary: {
container: 'secondary',
content: 'onSecondary',
stateLayer: 'onSecondary',
},
tertiary: {
container: 'tertiary',
content: 'onTertiary',
stateLayer: 'onTertiary',
},
tonalPrimary: {
container: 'primaryContainer',
content: 'onPrimaryContainer',
stateLayer: 'onPrimaryContainer',
},
tonalSecondary: {
container: 'secondaryContainer',
content: 'onSecondaryContainer',
stateLayer: 'onSecondaryContainer',
},
tonalTertiary: {
container: 'tertiaryContainer',
content: 'onTertiaryContainer',
stateLayer: 'onTertiaryContainer',
},
} as const satisfies Record<
Variant,
{ container: ColorRole; content: ColorRole; stateLayer: ColorRole }
>;
export const Tokens = {
sizes,
stateElevation,
variants,
};
const closeButton = {
container: 56,
iconSize: 20,
shape: 'full',
} as const;
const listItem = {
height: 56,
shape: 'full',
iconSize: 24,
leading: 24,
trailing: 24,
iconLabelGap: 8,
} as const;
const spacing = {
betweenItems: 4,
closeToLastItem: 8,
} as const;
export const MenuTokens = {
closeButton,
listItem,
spacing,
};
const focusIndicator = tokens.md.sys.state.focusIndicator;
export const FOCUS_RING_THICKNESS = focusIndicator.thickness;
export const FOCUS_RING_OUTER_OFFSET = focusIndicator.outerOffset;
export const FOCUS_RING_INSET = FOCUS_RING_OUTER_OFFSET + FOCUS_RING_THICKNESS;
export const webNoOutline = { outline: 'none' } as unknown as ViewStyle;