@fluentui-react-native/experimental-avatar 0.14.45 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/{lib-commonjs/Avatar.d.ts → lib/NativeAvatar.d.ts} +6 -6
- package/lib/NativeAvatar.d.ts.map +1 -0
- package/lib/{Avatar.js → NativeAvatar.js} +3 -3
- package/lib/NativeAvatar.js.map +1 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/{lib/Avatar.d.ts → lib-commonjs/NativeAvatar.d.ts} +6 -6
- package/lib-commonjs/NativeAvatar.d.ts.map +1 -0
- package/lib-commonjs/{Avatar.js → NativeAvatar.js} +4 -4
- package/lib-commonjs/NativeAvatar.js.map +1 -0
- package/lib-commonjs/index.d.ts +1 -3
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js +1 -3
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +2 -10
- package/src/{Avatar.tsx → NativeAvatar.tsx} +11 -11
- package/src/__tests__/Avatar.test.jsx +129 -0
- package/src/__tests__/__snapshots__/{JSAvatar.test.jsx.snap → Avatar.test.jsx.snap} +0 -0
- package/src/index.ts +1 -3
- package/MIGRATION.md +0 -157
- package/SPEC.md +0 -295
- package/jest.config.js +0 -2
- package/lib/Avatar.d.ts.map +0 -1
- package/lib/Avatar.js.map +0 -1
- package/lib/JSAvatar.d.ts +0 -12
- package/lib/JSAvatar.d.ts.map +0 -1
- package/lib/JSAvatar.js +0 -84
- package/lib/JSAvatar.js.map +0 -1
- package/lib/JSAvatar.styling.d.ts +0 -5
- package/lib/JSAvatar.styling.d.ts.map +0 -1
- package/lib/JSAvatar.styling.js +0 -158
- package/lib/JSAvatar.styling.js.map +0 -1
- package/lib/JSAvatar.types.d.ts +0 -213
- package/lib/JSAvatar.types.d.ts.map +0 -1
- package/lib/JSAvatar.types.js +0 -56
- package/lib/JSAvatar.types.js.map +0 -1
- package/lib/JSAvatarTokens.d.ts +0 -5
- package/lib/JSAvatarTokens.d.ts.map +0 -1
- package/lib/JSAvatarTokens.js +0 -198
- package/lib/JSAvatarTokens.js.map +0 -1
- package/lib/JSAvatarTokens.win32.d.ts +0 -5
- package/lib/JSAvatarTokens.win32.d.ts.map +0 -1
- package/lib/JSAvatarTokens.win32.js +0 -201
- package/lib/JSAvatarTokens.win32.js.map +0 -1
- package/lib/getHashCode.d.ts +0 -8
- package/lib/getHashCode.d.ts.map +0 -1
- package/lib/getHashCode.js +0 -16
- package/lib/getHashCode.js.map +0 -1
- package/lib/titles.d.ts +0 -2
- package/lib/titles.d.ts.map +0 -1
- package/lib/titles.js +0 -109
- package/lib/titles.js.map +0 -1
- package/lib/useAvatar.d.ts +0 -33
- package/lib/useAvatar.d.ts.map +0 -1
- package/lib/useAvatar.js +0 -106
- package/lib/useAvatar.js.map +0 -1
- package/lib-commonjs/Avatar.d.ts.map +0 -1
- package/lib-commonjs/Avatar.js.map +0 -1
- package/lib-commonjs/JSAvatar.d.ts +0 -12
- package/lib-commonjs/JSAvatar.d.ts.map +0 -1
- package/lib-commonjs/JSAvatar.js +0 -88
- package/lib-commonjs/JSAvatar.js.map +0 -1
- package/lib-commonjs/JSAvatar.styling.d.ts +0 -5
- package/lib-commonjs/JSAvatar.styling.d.ts.map +0 -1
- package/lib-commonjs/JSAvatar.styling.js +0 -161
- package/lib-commonjs/JSAvatar.styling.js.map +0 -1
- package/lib-commonjs/JSAvatar.types.d.ts +0 -213
- package/lib-commonjs/JSAvatar.types.d.ts.map +0 -1
- package/lib-commonjs/JSAvatar.types.js +0 -59
- package/lib-commonjs/JSAvatar.types.js.map +0 -1
- package/lib-commonjs/JSAvatarTokens.d.ts +0 -5
- package/lib-commonjs/JSAvatarTokens.d.ts.map +0 -1
- package/lib-commonjs/JSAvatarTokens.js +0 -202
- package/lib-commonjs/JSAvatarTokens.js.map +0 -1
- package/lib-commonjs/JSAvatarTokens.win32.d.ts +0 -5
- package/lib-commonjs/JSAvatarTokens.win32.d.ts.map +0 -1
- package/lib-commonjs/JSAvatarTokens.win32.js +0 -205
- package/lib-commonjs/JSAvatarTokens.win32.js.map +0 -1
- package/lib-commonjs/getHashCode.d.ts +0 -8
- package/lib-commonjs/getHashCode.d.ts.map +0 -1
- package/lib-commonjs/getHashCode.js +0 -20
- package/lib-commonjs/getHashCode.js.map +0 -1
- package/lib-commonjs/titles.d.ts +0 -2
- package/lib-commonjs/titles.d.ts.map +0 -1
- package/lib-commonjs/titles.js +0 -112
- package/lib-commonjs/titles.js.map +0 -1
- package/lib-commonjs/useAvatar.d.ts +0 -33
- package/lib-commonjs/useAvatar.d.ts.map +0 -1
- package/lib-commonjs/useAvatar.js +0 -113
- package/lib-commonjs/useAvatar.js.map +0 -1
- package/src/JSAvatar.styling.ts +0 -201
- package/src/JSAvatar.tsx +0 -96
- package/src/JSAvatar.types.ts +0 -286
- package/src/JSAvatarTokens.ts +0 -201
- package/src/JSAvatarTokens.win32.ts +0 -204
- package/src/__tests__/JSAvatar.test.jsx +0 -96
- package/src/getHashCode.ts +0 -16
- package/src/titles.ts +0 -108
- package/src/useAvatar.ts +0 -126
package/src/JSAvatarTokens.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { Theme } from '@fluentui-react-native/framework';
|
|
2
|
-
import { TokenSettings } from '@fluentui-react-native/use-styling';
|
|
3
|
-
import { JSAvatarTokens } from '.';
|
|
4
|
-
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
5
|
-
|
|
6
|
-
export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: Theme) =>
|
|
7
|
-
({
|
|
8
|
-
color: t.colors.neutralForeground3,
|
|
9
|
-
backgroundColor: t.colors.neutralBackground6,
|
|
10
|
-
avatarOpacity: 1,
|
|
11
|
-
fontFamily: t.typography.families.primary,
|
|
12
|
-
fontWeight: globalTokens.font.weight.semibold,
|
|
13
|
-
fontSize: globalTokens.font.size[200],
|
|
14
|
-
size: 24,
|
|
15
|
-
iconSize: 16,
|
|
16
|
-
iconColor: t.colors.neutralForeground3,
|
|
17
|
-
ringColor: t.colors.transparentStroke,
|
|
18
|
-
borderColor: globalTokens.color.white,
|
|
19
|
-
borderWidth: t.host.appearance === 'highContrast' ? 1 : 0,
|
|
20
|
-
circular: {
|
|
21
|
-
borderRadius: globalTokens.corner.radius.circle,
|
|
22
|
-
},
|
|
23
|
-
square: {
|
|
24
|
-
borderRadius: globalTokens.corner.radius.medium,
|
|
25
|
-
},
|
|
26
|
-
inactive: {
|
|
27
|
-
avatarOpacity: 0.8,
|
|
28
|
-
},
|
|
29
|
-
size20: {
|
|
30
|
-
size: 20,
|
|
31
|
-
badgeSize: 'smallest',
|
|
32
|
-
iconSize: 16,
|
|
33
|
-
fontSize: globalTokens.font.size[100],
|
|
34
|
-
square: {
|
|
35
|
-
borderRadius: globalTokens.corner.radius.small,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
size24: {
|
|
39
|
-
size: 24,
|
|
40
|
-
badgeSize: 'smallest',
|
|
41
|
-
iconSize: 16,
|
|
42
|
-
fontSize: globalTokens.font.size[100],
|
|
43
|
-
square: {
|
|
44
|
-
borderRadius: globalTokens.corner.radius.small,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
size28: {
|
|
48
|
-
size: 28,
|
|
49
|
-
badgeSize: 'smaller',
|
|
50
|
-
iconSize: 20,
|
|
51
|
-
fontWeight: globalTokens.font.weight.semibold,
|
|
52
|
-
fontSize: globalTokens.font.size[100],
|
|
53
|
-
},
|
|
54
|
-
size32: {
|
|
55
|
-
size: 32,
|
|
56
|
-
badgeSize: 'smaller',
|
|
57
|
-
iconSize: 20,
|
|
58
|
-
fontSize: globalTokens.font.size[100],
|
|
59
|
-
},
|
|
60
|
-
size36: {
|
|
61
|
-
size: 36,
|
|
62
|
-
badgeSize: 'smaller',
|
|
63
|
-
iconSize: 20,
|
|
64
|
-
},
|
|
65
|
-
size40: {
|
|
66
|
-
size: 40,
|
|
67
|
-
badgeSize: 'small',
|
|
68
|
-
iconSize: 20,
|
|
69
|
-
},
|
|
70
|
-
size48: {
|
|
71
|
-
size: 48,
|
|
72
|
-
badgeSize: 'small',
|
|
73
|
-
iconSize: 24,
|
|
74
|
-
},
|
|
75
|
-
size56: {
|
|
76
|
-
size: 56,
|
|
77
|
-
badgeSize: 'medium',
|
|
78
|
-
iconSize: 28,
|
|
79
|
-
fontSize: globalTokens.font.size[400],
|
|
80
|
-
square: {
|
|
81
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
size64: {
|
|
85
|
-
size: 64,
|
|
86
|
-
badgeSize: 'large',
|
|
87
|
-
iconSize: 32,
|
|
88
|
-
fontSize: globalTokens.font.size[500],
|
|
89
|
-
square: {
|
|
90
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
size72: {
|
|
94
|
-
size: 72,
|
|
95
|
-
badgeSize: 'large',
|
|
96
|
-
iconSize: 32,
|
|
97
|
-
fontSize: globalTokens.font.size[500],
|
|
98
|
-
square: {
|
|
99
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
size96: {
|
|
103
|
-
size: 96,
|
|
104
|
-
badgeSize: 'largest',
|
|
105
|
-
iconSize: 48,
|
|
106
|
-
fontWeight: globalTokens.font.weight.regular,
|
|
107
|
-
fontSize: globalTokens.font.size[700],
|
|
108
|
-
square: {
|
|
109
|
-
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
size120: {
|
|
113
|
-
size: 120,
|
|
114
|
-
badgeSize: 'largest',
|
|
115
|
-
iconSize: 48,
|
|
116
|
-
fontWeight: globalTokens.font.weight.regular,
|
|
117
|
-
fontSize: globalTokens.font.size[900],
|
|
118
|
-
square: {
|
|
119
|
-
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
neutral: {
|
|
123
|
-
backgroundColor: t.colors.neutralBackground6,
|
|
124
|
-
color: t.colors.neutralForeground3,
|
|
125
|
-
iconColor: t.colors.neutralForeground3,
|
|
126
|
-
ringColor: t.colors.transparentStroke,
|
|
127
|
-
},
|
|
128
|
-
brand: {
|
|
129
|
-
backgroundColor: t.colors.brandBackgroundStatic,
|
|
130
|
-
color: t.colors.neutralForegroundOnBrand,
|
|
131
|
-
iconColor: t.colors.neutralForegroundOnBrand,
|
|
132
|
-
ringColor: t.colors.transparentStroke,
|
|
133
|
-
},
|
|
134
|
-
darkRed: getColorProps('darkRed', t),
|
|
135
|
-
cranberry: getColorProps('cranberry', t),
|
|
136
|
-
red: getColorProps('red', t),
|
|
137
|
-
pumpkin: getColorProps('pumpkin', t),
|
|
138
|
-
peach: getColorProps('peach', t),
|
|
139
|
-
marigold: getColorProps('marigold', t),
|
|
140
|
-
gold: getColorProps('gold', t),
|
|
141
|
-
brass: getColorProps('brass', t),
|
|
142
|
-
brown: getColorProps('brown', t),
|
|
143
|
-
forest: getColorProps('forest', t),
|
|
144
|
-
seafoam: getColorProps('seafoam', t),
|
|
145
|
-
darkGreen: getColorProps('darkGreen', t),
|
|
146
|
-
lightTeal: getColorProps('lightTeal', t),
|
|
147
|
-
teal: getColorProps('teal', t),
|
|
148
|
-
steel: getColorProps('steel', t),
|
|
149
|
-
blue: getColorProps('blue', t),
|
|
150
|
-
royalBlue: getColorProps('royalBlue', t),
|
|
151
|
-
cornflower: getColorProps('cornflower', t),
|
|
152
|
-
navy: getColorProps('navy', t),
|
|
153
|
-
lavender: getColorProps('lavender', t),
|
|
154
|
-
purple: getColorProps('purple', t),
|
|
155
|
-
grape: getColorProps('grape', t),
|
|
156
|
-
lilac: getColorProps('lilac', t),
|
|
157
|
-
pink: getColorProps('pink', t),
|
|
158
|
-
magenta: getColorProps('magenta', t),
|
|
159
|
-
plum: getColorProps('plum', t),
|
|
160
|
-
beige: getColorProps('beige', t),
|
|
161
|
-
mink: getColorProps('mink', t),
|
|
162
|
-
platinum: getColorProps('platinum', t),
|
|
163
|
-
anchor: getColorProps('anchor', t),
|
|
164
|
-
burgundy: getColorProps('burgundy', t),
|
|
165
|
-
hotPink: getColorProps('hotPink', t),
|
|
166
|
-
orchid: getColorProps('orchid', t),
|
|
167
|
-
} as JSAvatarTokens);
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* A function which returns object of props depending on color and theme.
|
|
171
|
-
* @param color
|
|
172
|
-
* @param theme
|
|
173
|
-
* @returns object of props - backgroundColor, color and ringColor
|
|
174
|
-
*/
|
|
175
|
-
function getColorProps(color: string, theme: Theme) {
|
|
176
|
-
const themeAppearance = theme.host.appearance;
|
|
177
|
-
switch (themeAppearance) {
|
|
178
|
-
case 'light':
|
|
179
|
-
default:
|
|
180
|
-
return {
|
|
181
|
-
backgroundColor: globalTokens.color[color].tint40,
|
|
182
|
-
color: globalTokens.color[color].shade30,
|
|
183
|
-
iconColor: globalTokens.color[color].shade30,
|
|
184
|
-
ringColor: globalTokens.color[color].primary,
|
|
185
|
-
};
|
|
186
|
-
case 'dark':
|
|
187
|
-
return {
|
|
188
|
-
backgroundColor: globalTokens.color[color].shade30,
|
|
189
|
-
color: globalTokens.color[color].tint40,
|
|
190
|
-
iconColor: globalTokens.color[color].tint40,
|
|
191
|
-
ringColor: globalTokens.color[color].tint30,
|
|
192
|
-
};
|
|
193
|
-
case 'highContrast':
|
|
194
|
-
return {
|
|
195
|
-
backgroundColor: theme.colors.neutralBackground6,
|
|
196
|
-
color: theme.colors.neutralForeground3,
|
|
197
|
-
iconColor: theme.colors.neutralForeground3,
|
|
198
|
-
ringColor: theme.colors.transparentStroke,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { Theme } from '@fluentui-react-native/framework';
|
|
2
|
-
import { TokenSettings } from '@fluentui-react-native/use-styling';
|
|
3
|
-
import { JSAvatarTokens } from '.';
|
|
4
|
-
import { globalTokens } from '@fluentui-react-native/theme-tokens';
|
|
5
|
-
|
|
6
|
-
export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: Theme) =>
|
|
7
|
-
({
|
|
8
|
-
badgeSize: 'smallest',
|
|
9
|
-
color: t.colors.neutralForeground3,
|
|
10
|
-
backgroundColor: t.colors.neutralBackground6,
|
|
11
|
-
avatarOpacity: 1,
|
|
12
|
-
fontFamily: t.typography.families.primary,
|
|
13
|
-
fontWeight: globalTokens.font.weight.semibold,
|
|
14
|
-
fontSize: globalTokens.font.size[200],
|
|
15
|
-
size: 24,
|
|
16
|
-
iconSize: 16,
|
|
17
|
-
iconColor: t.colors.neutralForeground3,
|
|
18
|
-
ringColor: t.colors.transparentStroke,
|
|
19
|
-
borderColor: globalTokens.color.white,
|
|
20
|
-
borderWidth: t.name === 'HighContrast' ? 1 : 0,
|
|
21
|
-
circular: {
|
|
22
|
-
borderRadius: globalTokens.corner.radius.circle,
|
|
23
|
-
},
|
|
24
|
-
square: {
|
|
25
|
-
borderRadius: globalTokens.corner.radius.medium,
|
|
26
|
-
},
|
|
27
|
-
inactive: {
|
|
28
|
-
avatarOpacity: 0.8,
|
|
29
|
-
},
|
|
30
|
-
size20: {
|
|
31
|
-
size: 20,
|
|
32
|
-
badgeSize: 'smallest',
|
|
33
|
-
iconSize: 16,
|
|
34
|
-
fontSize: globalTokens.font.size[100],
|
|
35
|
-
square: {
|
|
36
|
-
borderRadius: globalTokens.corner.radius.small,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
size24: {
|
|
40
|
-
size: 24,
|
|
41
|
-
badgeSize: 'smallest',
|
|
42
|
-
iconSize: 16,
|
|
43
|
-
fontSize: globalTokens.font.size[100],
|
|
44
|
-
square: {
|
|
45
|
-
borderRadius: globalTokens.corner.radius.small,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
size28: {
|
|
49
|
-
size: 28,
|
|
50
|
-
badgeSize: 'smaller',
|
|
51
|
-
iconSize: 20,
|
|
52
|
-
fontWeight: globalTokens.font.weight.semibold,
|
|
53
|
-
fontSize: globalTokens.font.size[100],
|
|
54
|
-
},
|
|
55
|
-
size32: {
|
|
56
|
-
size: 32,
|
|
57
|
-
badgeSize: 'smaller',
|
|
58
|
-
iconSize: 20,
|
|
59
|
-
fontSize: globalTokens.font.size[100],
|
|
60
|
-
},
|
|
61
|
-
size36: {
|
|
62
|
-
size: 36,
|
|
63
|
-
badgeSize: 'smaller',
|
|
64
|
-
iconSize: 20,
|
|
65
|
-
},
|
|
66
|
-
size40: {
|
|
67
|
-
size: 40,
|
|
68
|
-
badgeSize: 'small',
|
|
69
|
-
iconSize: 20,
|
|
70
|
-
},
|
|
71
|
-
size48: {
|
|
72
|
-
size: 48,
|
|
73
|
-
badgeSize: 'small',
|
|
74
|
-
iconSize: 24,
|
|
75
|
-
},
|
|
76
|
-
size56: {
|
|
77
|
-
size: 56,
|
|
78
|
-
badgeSize: 'medium',
|
|
79
|
-
iconSize: 28,
|
|
80
|
-
fontSize: globalTokens.font.size[400],
|
|
81
|
-
square: {
|
|
82
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
size64: {
|
|
86
|
-
size: 64,
|
|
87
|
-
badgeSize: 'large',
|
|
88
|
-
iconSize: 32,
|
|
89
|
-
fontSize: globalTokens.font.size[500],
|
|
90
|
-
square: {
|
|
91
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
size72: {
|
|
95
|
-
size: 72,
|
|
96
|
-
badgeSize: 'large',
|
|
97
|
-
iconSize: 32,
|
|
98
|
-
fontSize: globalTokens.font.size[500],
|
|
99
|
-
square: {
|
|
100
|
-
borderRadius: globalTokens.corner.radius.large,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
size96: {
|
|
104
|
-
size: 96,
|
|
105
|
-
badgeSize: 'largest',
|
|
106
|
-
iconSize: 48,
|
|
107
|
-
fontWeight: globalTokens.font.weight.regular,
|
|
108
|
-
fontSize: globalTokens.font.size[700],
|
|
109
|
-
square: {
|
|
110
|
-
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
size120: {
|
|
114
|
-
size: 120,
|
|
115
|
-
badgeSize: 'largest',
|
|
116
|
-
iconSize: 48,
|
|
117
|
-
fontWeight: globalTokens.font.weight.regular,
|
|
118
|
-
fontSize: globalTokens.font.size[900],
|
|
119
|
-
square: {
|
|
120
|
-
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
neutral: {
|
|
124
|
-
backgroundColor: t.colors.neutralBackground6,
|
|
125
|
-
color: t.colors.neutralForeground3,
|
|
126
|
-
iconColor: t.colors.neutralForeground3,
|
|
127
|
-
ringColor: t.colors.transparentStroke,
|
|
128
|
-
},
|
|
129
|
-
brand: {
|
|
130
|
-
backgroundColor: t.colors.brandBackgroundStatic,
|
|
131
|
-
color: t.colors.neutralForegroundOnBrand,
|
|
132
|
-
iconColor: t.colors.neutralForegroundOnBrand,
|
|
133
|
-
ringColor: t.colors.transparentStroke,
|
|
134
|
-
},
|
|
135
|
-
darkRed: getColorProps('darkRed', t),
|
|
136
|
-
cranberry: getColorProps('cranberry', t),
|
|
137
|
-
red: getColorProps('red', t),
|
|
138
|
-
pumpkin: getColorProps('pumpkin', t),
|
|
139
|
-
peach: getColorProps('peach', t),
|
|
140
|
-
marigold: getColorProps('marigold', t),
|
|
141
|
-
gold: getColorProps('gold', t),
|
|
142
|
-
brass: getColorProps('brass', t),
|
|
143
|
-
brown: getColorProps('brown', t),
|
|
144
|
-
forest: getColorProps('forest', t),
|
|
145
|
-
seafoam: getColorProps('seafoam', t),
|
|
146
|
-
darkGreen: getColorProps('darkGreen', t),
|
|
147
|
-
lightTeal: getColorProps('lightTeal', t),
|
|
148
|
-
teal: getColorProps('teal', t),
|
|
149
|
-
steel: getColorProps('steel', t),
|
|
150
|
-
blue: getColorProps('blue', t),
|
|
151
|
-
royalBlue: getColorProps('royalBlue', t),
|
|
152
|
-
cornflower: getColorProps('cornflower', t),
|
|
153
|
-
navy: getColorProps('navy', t),
|
|
154
|
-
lavender: getColorProps('lavender', t),
|
|
155
|
-
purple: getColorProps('purple', t),
|
|
156
|
-
grape: getColorProps('grape', t),
|
|
157
|
-
lilac: getColorProps('lilac', t),
|
|
158
|
-
pink: getColorProps('pink', t),
|
|
159
|
-
magenta: getColorProps('magenta', t),
|
|
160
|
-
plum: getColorProps('plum', t),
|
|
161
|
-
beige: getColorProps('beige', t),
|
|
162
|
-
mink: getColorProps('mink', t),
|
|
163
|
-
platinum: getColorProps('platinum', t),
|
|
164
|
-
anchor: getColorProps('anchor', t),
|
|
165
|
-
burgundy: getColorProps('burgundy', t),
|
|
166
|
-
hotPink: getColorProps('hotPink', t),
|
|
167
|
-
orchid: getColorProps('orchid', t),
|
|
168
|
-
} as JSAvatarTokens);
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* A function which returns object of props depending on color and theme.
|
|
172
|
-
* @param color
|
|
173
|
-
* @param theme
|
|
174
|
-
* @returns object of props - backgroundColor, color and ringColor
|
|
175
|
-
*/
|
|
176
|
-
function getColorProps(color: string, theme: Theme) {
|
|
177
|
-
const themeAppearance = theme.name;
|
|
178
|
-
switch (themeAppearance) {
|
|
179
|
-
case 'White':
|
|
180
|
-
case 'Colorful':
|
|
181
|
-
default:
|
|
182
|
-
return {
|
|
183
|
-
backgroundColor: globalTokens.color[color].tint40,
|
|
184
|
-
color: globalTokens.color[color].shade30,
|
|
185
|
-
iconColor: globalTokens.color[color].shade30,
|
|
186
|
-
ringColor: globalTokens.color[color].primary,
|
|
187
|
-
};
|
|
188
|
-
case 'DarkGray':
|
|
189
|
-
case 'Black':
|
|
190
|
-
return {
|
|
191
|
-
backgroundColor: globalTokens.color[color].shade30,
|
|
192
|
-
color: globalTokens.color[color].tint40,
|
|
193
|
-
iconColor: globalTokens.color[color].tint40,
|
|
194
|
-
ringColor: globalTokens.color[color].tint30,
|
|
195
|
-
};
|
|
196
|
-
case 'HighContrast':
|
|
197
|
-
return {
|
|
198
|
-
backgroundColor: theme.colors.neutralBackground6,
|
|
199
|
-
color: theme.colors.neutralForeground3,
|
|
200
|
-
iconColor: theme.colors.neutralForeground3,
|
|
201
|
-
ringColor: theme.colors.transparentStroke,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { JSAvatar } from '..';
|
|
3
|
-
import { getInitials } from '../useAvatar';
|
|
4
|
-
import * as renderer from 'react-test-renderer';
|
|
5
|
-
|
|
6
|
-
const emptyData = [
|
|
7
|
-
[undefined, ''],
|
|
8
|
-
[null, ''],
|
|
9
|
-
['', ''],
|
|
10
|
-
];
|
|
11
|
-
const testData = [
|
|
12
|
-
['Marie', 'M'],
|
|
13
|
-
['Aadi KaPoor', 'AK'],
|
|
14
|
-
['Marie Beaudouin', 'MB'],
|
|
15
|
-
['Aadi Meni KaPoor', 'AK'],
|
|
16
|
-
['Will Little (Teams)', 'WL'],
|
|
17
|
-
['Will Little-Tanaka', 'WL'],
|
|
18
|
-
['-Aadi Kapoor', 'AK'],
|
|
19
|
-
['Richard 23 Feynman', 'RF'],
|
|
20
|
-
['* Richard *', 'R'],
|
|
21
|
-
['Richard Feynman [Teams],', 'RF'],
|
|
22
|
-
['Richard Feynman {Teams}', 'RF'],
|
|
23
|
-
['-Test str with *spaces', 'TS'],
|
|
24
|
-
['Second, First', 'SF'],
|
|
25
|
-
];
|
|
26
|
-
const namesWithTitles = [
|
|
27
|
-
['Mr Feynman', 'F'],
|
|
28
|
-
['Dr Richard Feynman', 'RF'],
|
|
29
|
-
['Aadi Meni Ka Jr', 'AK'],
|
|
30
|
-
['Consul General Richard Faynman', 'RF'],
|
|
31
|
-
['Major General Victor', 'V'],
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const languageTestData = [
|
|
35
|
-
['خسرو رحیمی', 'خ'], // Arabic
|
|
36
|
-
['桂英', '桂'], // Chinese
|
|
37
|
-
['佳', '佳'],
|
|
38
|
-
['宋智洋', '宋'],
|
|
39
|
-
['강현', '강'], // Korean
|
|
40
|
-
['최종래', '최'],
|
|
41
|
-
['남궁 성종', '남'],
|
|
42
|
-
['松田', '松'], // Japanese
|
|
43
|
-
['海野', '海'],
|
|
44
|
-
['かり', 'か'],
|
|
45
|
-
['Илон Маск', 'ИМ'], // Cyrillic
|
|
46
|
-
['Írissa Þórðardóttir', 'ÍÞ'], // non-ASCII characters
|
|
47
|
-
['Øyvind Åsen', 'ØÅ'],
|
|
48
|
-
['ثابت بن قره', 'ث'], // Thābit ibn Qurra - result in PCX - ثابت
|
|
49
|
-
['שירה לוי', 'של'], // Hebrew - Shira Levi
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const phoneNumbersAndDigits = [
|
|
53
|
-
['12345678', ''],
|
|
54
|
-
['+47 12 34 56 78 (X 5678)', ''],
|
|
55
|
-
['47 12 34', ''],
|
|
56
|
-
['47 12', ''],
|
|
57
|
-
['James Ext 2', 'JE'],
|
|
58
|
-
['1', ''],
|
|
59
|
-
['A2', 'A'],
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
const edgeCaseData = [
|
|
63
|
-
['4lex 5loo', 'LL'],
|
|
64
|
-
[' !@#$%^&*()=+ (Alpha) David (The man) `~<>,./?[]{}| Goff (Gamma) ', 'DG'],
|
|
65
|
-
['+1 (555) 123-4567 ext.4567', 'E'],
|
|
66
|
-
['1 Ext 2', 'E'],
|
|
67
|
-
['1x1', 'X'],
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
describe('Avatar rendering', () => {
|
|
71
|
-
it('renders Avatar', () => {
|
|
72
|
-
const tree = renderer.create(<JSAvatar />).toJSON();
|
|
73
|
-
expect(tree).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('getInitials method', () => {
|
|
78
|
-
it.each(emptyData)("returns an empty string for '%s'", (text, expected) => {
|
|
79
|
-
expect(getInitials(text)).toBe(expected);
|
|
80
|
-
});
|
|
81
|
-
it.each(testData)("render correct initials for input '%s'", (text, expected) => {
|
|
82
|
-
expect(getInitials(text)).toBe(expected);
|
|
83
|
-
});
|
|
84
|
-
it.each(namesWithTitles)("render initials for names with titles: '%s'", (text, expected) => {
|
|
85
|
-
expect(getInitials(text)).toBe(expected);
|
|
86
|
-
});
|
|
87
|
-
it.each(languageTestData)("render initials for different languages: '%s'", (text, expected) => {
|
|
88
|
-
expect(getInitials(text)).toBe(expected);
|
|
89
|
-
});
|
|
90
|
-
it.each(phoneNumbersAndDigits)("returns an empty string for phone numbers: '%s'", (text, expected) => {
|
|
91
|
-
expect(getInitials(text)).toBe(expected);
|
|
92
|
-
});
|
|
93
|
-
it.each(edgeCaseData)("render initials for edge cases: '%s'", (text, expected) => {
|
|
94
|
-
expect(getInitials(text)).toBe(expected);
|
|
95
|
-
});
|
|
96
|
-
});
|
package/src/getHashCode.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A function which returns hash code for the avatar color. Web implementation
|
|
3
|
-
*
|
|
4
|
-
* @param str is idForColor or name
|
|
5
|
-
* @returns hash code of the color
|
|
6
|
-
*/
|
|
7
|
-
export const getHashCodeWeb = (str: string): number => {
|
|
8
|
-
let hashCode = 0;
|
|
9
|
-
for (let len: number = str.length - 1; len >= 0; len--) {
|
|
10
|
-
const ch = str.charCodeAt(len);
|
|
11
|
-
const shift = len % 8;
|
|
12
|
-
hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return hashCode;
|
|
16
|
-
};
|
package/src/titles.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
export const titles = new Set<string>([
|
|
2
|
-
'Mr',
|
|
3
|
-
'Mrs',
|
|
4
|
-
'Miss',
|
|
5
|
-
'Ms',
|
|
6
|
-
'Dr',
|
|
7
|
-
'Admiral',
|
|
8
|
-
'Air Comm',
|
|
9
|
-
'Ambassador',
|
|
10
|
-
'Baron',
|
|
11
|
-
'Baroness',
|
|
12
|
-
'Brig & Mrs',
|
|
13
|
-
'Brig Gen',
|
|
14
|
-
'Brigadier',
|
|
15
|
-
'Brother',
|
|
16
|
-
'Canon',
|
|
17
|
-
'Capt',
|
|
18
|
-
'Chief',
|
|
19
|
-
'Cllr',
|
|
20
|
-
'Col',
|
|
21
|
-
'Commander',
|
|
22
|
-
'Commander & Mrs',
|
|
23
|
-
'Consul',
|
|
24
|
-
'Consul General',
|
|
25
|
-
'Count',
|
|
26
|
-
'Countess',
|
|
27
|
-
'Countess of',
|
|
28
|
-
'Cpl',
|
|
29
|
-
'Dame',
|
|
30
|
-
'Deputy',
|
|
31
|
-
'Dr & Mrs',
|
|
32
|
-
'Drs',
|
|
33
|
-
'Duchess',
|
|
34
|
-
'Duke',
|
|
35
|
-
'Earl',
|
|
36
|
-
'Father',
|
|
37
|
-
'General',
|
|
38
|
-
'Gräfin',
|
|
39
|
-
'HE',
|
|
40
|
-
'HMA',
|
|
41
|
-
'Her Grace',
|
|
42
|
-
'His Excellency',
|
|
43
|
-
'Jr',
|
|
44
|
-
'Judge',
|
|
45
|
-
'Justice',
|
|
46
|
-
'Lady',
|
|
47
|
-
'Lic',
|
|
48
|
-
'Llc',
|
|
49
|
-
'Lord',
|
|
50
|
-
'Lord & Lady',
|
|
51
|
-
'Lt',
|
|
52
|
-
'Lt Col',
|
|
53
|
-
'Lt Cpl',
|
|
54
|
-
'M',
|
|
55
|
-
'Madam',
|
|
56
|
-
'Madame',
|
|
57
|
-
'Major',
|
|
58
|
-
'Major General',
|
|
59
|
-
'Marchioness',
|
|
60
|
-
'Marquis',
|
|
61
|
-
'Minister',
|
|
62
|
-
'Mme',
|
|
63
|
-
'Mr & Dr',
|
|
64
|
-
'Mr & Mrs',
|
|
65
|
-
'Mr & Ms',
|
|
66
|
-
'Prince',
|
|
67
|
-
'Princess',
|
|
68
|
-
'Professor',
|
|
69
|
-
'Prof',
|
|
70
|
-
'Prof & Dr',
|
|
71
|
-
'Prof & Mrs',
|
|
72
|
-
'Prof & Rev',
|
|
73
|
-
'Prof Dame',
|
|
74
|
-
'Prof Dr',
|
|
75
|
-
'Pvt',
|
|
76
|
-
'Rabbi',
|
|
77
|
-
'Rear Admiral',
|
|
78
|
-
'Rev',
|
|
79
|
-
'Rev & Mrs',
|
|
80
|
-
'Rev Canon',
|
|
81
|
-
'Rev Dr',
|
|
82
|
-
'Senator',
|
|
83
|
-
'Sgt',
|
|
84
|
-
'Sheriff',
|
|
85
|
-
'Sir',
|
|
86
|
-
'Sir & Lady',
|
|
87
|
-
'Sister',
|
|
88
|
-
'Sr',
|
|
89
|
-
'Sqr. Leader',
|
|
90
|
-
'The Earl of',
|
|
91
|
-
'The Hon',
|
|
92
|
-
'The Hon Dr',
|
|
93
|
-
'The Hon Lady',
|
|
94
|
-
'The Hon Lord',
|
|
95
|
-
'The Hon Mrs',
|
|
96
|
-
'The Hon Sir',
|
|
97
|
-
'The Honourable',
|
|
98
|
-
'The Rt Hon',
|
|
99
|
-
'The Rt Hon Dr',
|
|
100
|
-
'The Rt Hon Lord',
|
|
101
|
-
'The Rt Hon Sir',
|
|
102
|
-
'The Rt Hon Visc',
|
|
103
|
-
'Viscount',
|
|
104
|
-
'van',
|
|
105
|
-
'I',
|
|
106
|
-
'II',
|
|
107
|
-
'III',
|
|
108
|
-
]);
|