@fluentui-react-native/experimental-avatar 0.14.44 → 0.15.1
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 +61 -1
- package/CHANGELOG.md +26 -2
- package/FRNAvatar.podspec +2 -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__/{JSAvatar.test.jsx → Avatar.test.jsx} +2 -2
- 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/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
|
-
}
|
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
|
-
]);
|
package/src/useAvatar.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { JSAvatarProps, AvatarInfo, JSAvatarState, AvatarColors } from './JSAvatar.types';
|
|
2
|
-
import { PresenceBadgeProps } from '@fluentui-react-native/badge';
|
|
3
|
-
import { titles } from './titles';
|
|
4
|
-
import { getHashCodeWeb } from './getHashCode';
|
|
5
|
-
import { createIconProps } from '@fluentui-react-native/interactive-hooks';
|
|
6
|
-
/**
|
|
7
|
-
* Re-usable hook for FURN Avatar.
|
|
8
|
-
* This hook configures Avatar props and state for FURN Avatar.
|
|
9
|
-
*
|
|
10
|
-
* @param props user props sent to FURN Avatar
|
|
11
|
-
* @returns configured props and state for FURN Avatar
|
|
12
|
-
*/
|
|
13
|
-
export const useAvatar = (props: JSAvatarProps): AvatarInfo => {
|
|
14
|
-
const {
|
|
15
|
-
avatarColor,
|
|
16
|
-
active,
|
|
17
|
-
accessibilityLabel,
|
|
18
|
-
accessibilityRole,
|
|
19
|
-
activeAppearance,
|
|
20
|
-
badge,
|
|
21
|
-
idForColor,
|
|
22
|
-
initials,
|
|
23
|
-
name,
|
|
24
|
-
shape,
|
|
25
|
-
transparentRing,
|
|
26
|
-
icon,
|
|
27
|
-
...rest
|
|
28
|
-
} = props;
|
|
29
|
-
|
|
30
|
-
const showRing = active === 'active' && activeAppearance === 'ring';
|
|
31
|
-
const showBadge = (!active || active === 'unset') && !!badge && !!badge.status;
|
|
32
|
-
const accessibilityText = `${name || ''}${showBadge ? `, ${badge.status}` : ''}`;
|
|
33
|
-
|
|
34
|
-
const badgeProps: PresenceBadgeProps = {
|
|
35
|
-
size: 'small',
|
|
36
|
-
...badge,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const state: JSAvatarState = {
|
|
40
|
-
showRing,
|
|
41
|
-
transparentRing: !!transparentRing,
|
|
42
|
-
showBadge,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const _initials = initials || getInitials(name);
|
|
46
|
-
const avatarColorsIdx = getHashCodeWeb(idForColor ?? name ?? '') % AvatarColors.length;
|
|
47
|
-
const _avatarColor = avatarColor === 'colorful' ? AvatarColors[avatarColorsIdx] : avatarColor;
|
|
48
|
-
|
|
49
|
-
const iconProps = createIconProps(icon);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
props: {
|
|
53
|
-
accessible: true,
|
|
54
|
-
accessibilityLabel: accessibilityLabel || accessibilityText,
|
|
55
|
-
accessibilityRole: accessibilityRole ?? 'image',
|
|
56
|
-
avatarColor: _avatarColor,
|
|
57
|
-
shape: shape || 'circular',
|
|
58
|
-
...rest,
|
|
59
|
-
active,
|
|
60
|
-
activeAppearance,
|
|
61
|
-
badge: badgeProps,
|
|
62
|
-
initials: _initials,
|
|
63
|
-
icon: iconProps,
|
|
64
|
-
},
|
|
65
|
-
state: {
|
|
66
|
-
...state,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* A function which takes a name and returns initials
|
|
73
|
-
*
|
|
74
|
-
* @param name
|
|
75
|
-
* @returns initials. First letter of the word if only one word was provided.
|
|
76
|
-
* First letters of the first and last words if more words were provided.
|
|
77
|
-
* Words in braces, titles, special characters, parantheses and dashes should be ignored.
|
|
78
|
-
*/
|
|
79
|
-
export const getInitials = (name: string): string => {
|
|
80
|
-
if (!name) {
|
|
81
|
-
return '';
|
|
82
|
-
}
|
|
83
|
-
const ARABIC_ASIAN_REGEXP = new RegExp(
|
|
84
|
-
'[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uAC00-\uD7AF\uD7B0-\uD7FF\u3040-\u309F\u30A0-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uD840-\uD869]',
|
|
85
|
-
'g',
|
|
86
|
-
);
|
|
87
|
-
const words = removeRedundantCharacters(name);
|
|
88
|
-
const wordsLength = words.length;
|
|
89
|
-
const lastWordIdx = wordsLength - 1;
|
|
90
|
-
const firstLetter = words[0].charAt(0).toUpperCase();
|
|
91
|
-
const lastLetter = wordsLength > 1 ? words[lastWordIdx].charAt(0).toUpperCase() : '';
|
|
92
|
-
const initials = `${firstLetter}${ARABIC_ASIAN_REGEXP.test(name) ? '' : lastLetter}`;
|
|
93
|
-
return initials;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* A function which takes a name and returns array of valid words
|
|
98
|
-
*
|
|
99
|
-
* @param name
|
|
100
|
-
* @returns array of words without phone numbers and special characters.
|
|
101
|
-
*/
|
|
102
|
-
export const removeRedundantCharacters = (name: string): string[] => {
|
|
103
|
-
if (!name) {
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
const WORDS_IN_BRACES_REGEXP = new RegExp('[(\\[\\{][^\\)\\]\\}]*[\\)\\]\\}]', 'g');
|
|
107
|
-
const PHONE_NUMBER_REGEXP = new RegExp('(\\+|(\\d|\\s))', 'g');
|
|
108
|
-
const SPECIAL_CHARACTERS_REGEXP = new RegExp('[!"#\'$%&*+,-./:;>=<?@^_`|~¡¢£¤¥¦§¨©ª«¬®ˉ°±²¼½¾¿×÷]', 'g');
|
|
109
|
-
const words = name
|
|
110
|
-
.replace(WORDS_IN_BRACES_REGEXP, '')
|
|
111
|
-
.replace(PHONE_NUMBER_REGEXP, ' ')
|
|
112
|
-
.replace(SPECIAL_CHARACTERS_REGEXP, '')
|
|
113
|
-
.trim()
|
|
114
|
-
.split(' ');
|
|
115
|
-
return removeTitlesFromName(words);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* A function which verifies whether words array contains title
|
|
120
|
-
*
|
|
121
|
-
* @param words array of words in name
|
|
122
|
-
* @returns array of words without titles
|
|
123
|
-
*/
|
|
124
|
-
export const removeTitlesFromName = (words: string[]): string[] => {
|
|
125
|
-
return words.filter((word) => !titles.has(word));
|
|
126
|
-
};
|