@fluentui-react-native/experimental-avatar 0.14.25 → 0.14.28
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 +52 -1
- package/CHANGELOG.md +27 -2
- package/jest.config.js +2 -0
- package/lib/JSAvatar.d.ts.map +1 -1
- package/lib/JSAvatar.js +3 -1
- package/lib/JSAvatar.js.map +1 -1
- package/lib/JSAvatar.styling.d.ts.map +1 -1
- package/lib/JSAvatar.styling.js +20 -13
- package/lib/JSAvatar.styling.js.map +1 -1
- package/lib/JSAvatar.types.d.ts +5 -6
- package/lib/JSAvatar.types.d.ts.map +1 -1
- package/lib/JSAvatarTokens.d.ts.map +1 -1
- package/lib/JSAvatarTokens.js +109 -105
- package/lib/JSAvatarTokens.js.map +1 -1
- package/lib/JSAvatarTokens.win32.d.ts +5 -0
- package/lib/JSAvatarTokens.win32.d.ts.map +1 -0
- package/lib/JSAvatarTokens.win32.js +210 -0
- package/lib/JSAvatarTokens.win32.js.map +1 -0
- package/lib/titles.d.ts +2 -0
- package/lib/titles.d.ts.map +1 -0
- package/lib/titles.js +109 -0
- package/lib/titles.js.map +1 -0
- package/lib/useAvatar.d.ts +25 -0
- package/lib/useAvatar.d.ts.map +1 -1
- package/lib/useAvatar.js +47 -2
- package/lib/useAvatar.js.map +1 -1
- package/lib/utils/getInitials.d.ts +15 -0
- package/lib/utils/getInitials.d.ts.map +1 -0
- package/lib/utils/getInitials.js +78 -0
- package/lib/utils/getInitials.js.map +1 -0
- package/lib/utils/getInitials.test.d.ts +2 -0
- package/lib/utils/getInitials.test.d.ts.map +1 -0
- package/lib/utils/getInitials.test.js +116 -0
- package/lib/utils/getInitials.test.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/lib-commonjs/JSAvatar.d.ts.map +1 -1
- package/lib-commonjs/JSAvatar.js +3 -1
- package/lib-commonjs/JSAvatar.js.map +1 -1
- package/lib-commonjs/JSAvatar.styling.d.ts.map +1 -1
- package/lib-commonjs/JSAvatar.styling.js +19 -12
- package/lib-commonjs/JSAvatar.styling.js.map +1 -1
- package/lib-commonjs/JSAvatar.types.d.ts +5 -6
- package/lib-commonjs/JSAvatar.types.d.ts.map +1 -1
- package/lib-commonjs/JSAvatarTokens.d.ts.map +1 -1
- package/lib-commonjs/JSAvatarTokens.js +109 -105
- package/lib-commonjs/JSAvatarTokens.js.map +1 -1
- package/lib-commonjs/JSAvatarTokens.win32.d.ts +5 -0
- package/lib-commonjs/JSAvatarTokens.win32.d.ts.map +1 -0
- package/lib-commonjs/JSAvatarTokens.win32.js +214 -0
- package/lib-commonjs/JSAvatarTokens.win32.js.map +1 -0
- package/lib-commonjs/titles.d.ts +2 -0
- package/lib-commonjs/titles.d.ts.map +1 -0
- package/lib-commonjs/titles.js +112 -0
- package/lib-commonjs/titles.js.map +1 -0
- package/lib-commonjs/useAvatar.d.ts +25 -0
- package/lib-commonjs/useAvatar.d.ts.map +1 -1
- package/lib-commonjs/useAvatar.js +51 -3
- package/lib-commonjs/useAvatar.js.map +1 -1
- package/lib-commonjs/utils/getInitials.d.ts +15 -0
- package/lib-commonjs/utils/getInitials.d.ts.map +1 -0
- package/lib-commonjs/utils/getInitials.js +82 -0
- package/lib-commonjs/utils/getInitials.js.map +1 -0
- package/lib-commonjs/utils/getInitials.test.d.ts +2 -0
- package/lib-commonjs/utils/getInitials.test.d.ts.map +1 -0
- package/lib-commonjs/utils/getInitials.test.js +118 -0
- package/lib-commonjs/utils/getInitials.test.js.map +1 -0
- package/lib-commonjs/utils/index.d.ts +2 -0
- package/lib-commonjs/utils/index.d.ts.map +1 -0
- package/lib-commonjs/utils/index.js +6 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- package/package.json +5 -4
- package/src/.eslintrc.js +3 -0
- package/src/JSAvatar.styling.ts +25 -10
- package/src/JSAvatar.tsx +12 -1
- package/src/JSAvatar.types.ts +5 -6
- package/src/JSAvatarTokens.ts +110 -105
- package/src/JSAvatarTokens.win32.ts +213 -0
- package/src/__tests__/JSAvatar.test.jsx +156 -0
- package/src/__tests__/__snapshots__/JSAvatar.test.jsx.snap +92 -0
- package/src/titles.ts +108 -0
- package/src/useAvatar.ts +51 -1
- package/src/utils/getInitials.test.ts +154 -0
- package/src/utils/getInitials.ts +92 -0
- package/src/utils/index.ts +1 -0
- package/tsconfig.json +2 -1
package/src/JSAvatar.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { useAvatar } from './useAvatar';
|
|
|
7
7
|
import { PresenceBadge } from '@fluentui-react-native/badge';
|
|
8
8
|
import { Icon } from '@fluentui-react-native/icon';
|
|
9
9
|
import { createIconProps } from '@fluentui-react-native/interactive-hooks';
|
|
10
|
+
import { SvgXml } from 'react-native-svg';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* A function which determines if a set of styles should be applied to the compoent given the current state and props of the avatar.
|
|
@@ -52,6 +53,10 @@ export const JSAvatar = compose<JSAvatarType>({
|
|
|
52
53
|
const { activeAppearance, icon, initials, image, badge, ...mergedProps } = mergeProps(avatar.props, final);
|
|
53
54
|
const { showRing, transparentRing, showBadge } = avatar.state;
|
|
54
55
|
const svgIconsEnabled = ['ios', 'macos', 'win32', 'android'].includes(Platform.OS as string);
|
|
56
|
+
const fallBackIconXml = `<svg width="14" height="16" viewBox="0 0 14 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
57
|
+
<path d="M7 0C4.79086 0 3 1.79086 3 4C3 6.20914 4.79086 8 7 8C9.20914 8 11 6.20914 11 4C11 1.79086 9.20914 0 7 0ZM4 4C4 2.34315 5.34315 1 7 1C8.65685 1 10 2.34315 10 4C10 5.65685 8.65685 7 7 7C5.34315 7 4 5.65685 4 4ZM2.00873 9C0.903151 9 0 9.88687 0 11C0 12.6912 0.83281 13.9663 2.13499 14.7966C3.41697 15.614 5.14526 16 7 16C8.85474 16 10.583 15.614 11.865 14.7966C13.1672 13.9663 14 12.6912 14 11C14 9.89557 13.1045 9.00001 12 9.00001L2.00873 9ZM1 11C1 10.4467 1.44786 10 2.00873 10L12 10C12.5522 10 13 10.4478 13 11C13 12.3088 12.3777 13.2837 11.3274 13.9534C10.2568 14.636 8.73511 15 7 15C5.26489 15 3.74318 14.636 2.67262 13.9534C1.62226 13.2837 1 12.3088 1 11Z" fill="currentColor"/>
|
|
58
|
+
</svg>
|
|
59
|
+
`;
|
|
55
60
|
|
|
56
61
|
return (
|
|
57
62
|
<Slots.root {...mergedProps}>
|
|
@@ -59,7 +64,13 @@ export const JSAvatar = compose<JSAvatarType>({
|
|
|
59
64
|
<Slots.image {...image} />
|
|
60
65
|
) : (
|
|
61
66
|
<Slots.initialsBackground>
|
|
62
|
-
{initials ?
|
|
67
|
+
{initials ? (
|
|
68
|
+
<Slots.initials>{initials}</Slots.initials>
|
|
69
|
+
) : userProps.icon ? (
|
|
70
|
+
<Slots.icon {...iconProps} />
|
|
71
|
+
) : (
|
|
72
|
+
<SvgXml xml={fallBackIconXml} />
|
|
73
|
+
)}
|
|
63
74
|
</Slots.initialsBackground>
|
|
64
75
|
)}
|
|
65
76
|
{showRing && !transparentRing && <Slots.ring />}
|
package/src/JSAvatar.types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IViewProps } from '@fluentui-react-native/adapters';
|
|
2
2
|
import { ImageProps, ViewProps, TextProps, ColorValue } from 'react-native';
|
|
3
|
-
import { IBackgroundColorTokens, IForegroundColorTokens, IBorderTokens } from '@fluentui-react-native/tokens';
|
|
3
|
+
import { IBackgroundColorTokens, IForegroundColorTokens, IBorderTokens, FontTokens } from '@fluentui-react-native/tokens';
|
|
4
4
|
import { BadgeProps, PresenceBadgeProps, BadgeSize } from '@fluentui-react-native/badge';
|
|
5
5
|
import { IconProps, IconSourcesType } from '@fluentui-react-native/icon';
|
|
6
6
|
|
|
@@ -69,8 +69,6 @@ export type IconAlignment = 'start' | 'center' | 'end';
|
|
|
69
69
|
export interface RingConfig {
|
|
70
70
|
accent?: boolean;
|
|
71
71
|
transparent?: boolean;
|
|
72
|
-
ringColor?: ColorValue; // glow
|
|
73
|
-
ringBackgroundColor?: ColorValue; // inner/outer rings
|
|
74
72
|
ringThickness?: number;
|
|
75
73
|
innerGap?: number;
|
|
76
74
|
}
|
|
@@ -159,17 +157,18 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
|
|
|
159
157
|
src?: string;
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColorTokens, AvatarConfigurableProps, IBorderTokens {
|
|
160
|
+
export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColorTokens, AvatarConfigurableProps, IBorderTokens, FontTokens {
|
|
161
|
+
iconColor?: ColorValue;
|
|
163
162
|
iconSize?: number;
|
|
164
|
-
initialsSize?: number;
|
|
165
163
|
height?: number;
|
|
166
164
|
horizontalIconAlignment?: IconAlignment;
|
|
167
165
|
verticalIconAlignment?: IconAlignment;
|
|
168
166
|
circular?: JSAvatarTokens;
|
|
167
|
+
ringColor?: ColorValue;
|
|
168
|
+
ringBackgroundColor?: ColorValue;
|
|
169
169
|
square?: JSAvatarTokens;
|
|
170
170
|
inactive?: JSAvatarTokens;
|
|
171
171
|
avatarOpacity?: number;
|
|
172
|
-
ringColor?: ColorValue;
|
|
173
172
|
size20?: JSAvatarTokens;
|
|
174
173
|
size24?: JSAvatarTokens;
|
|
175
174
|
size28?: JSAvatarTokens;
|
package/src/JSAvatarTokens.ts
CHANGED
|
@@ -10,8 +10,16 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
|
|
|
10
10
|
color: globalTokens.color.white,
|
|
11
11
|
backgroundColor: globalTokens.color.cornflower.primary,
|
|
12
12
|
avatarOpacity: 1,
|
|
13
|
+
fontFamily: t.typography.families.primary,
|
|
14
|
+
fontWeight: globalTokens.font.weight.semibold,
|
|
15
|
+
fontSize: globalTokens.font.size[200],
|
|
13
16
|
width: 24,
|
|
14
17
|
height: 24,
|
|
18
|
+
iconSize: 16,
|
|
19
|
+
iconColor: globalTokens.color.white,
|
|
20
|
+
ringColor: t.colors.transparentStroke,
|
|
21
|
+
borderColor: globalTokens.color.white,
|
|
22
|
+
borderWidth: t.host.appearance === 'highContrast' ? 1 : 0,
|
|
15
23
|
circular: {
|
|
16
24
|
borderRadius: globalTokens.corner.radius.circle,
|
|
17
25
|
},
|
|
@@ -26,183 +34,180 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
|
|
|
26
34
|
height: 20,
|
|
27
35
|
badgeSize: 'smallest',
|
|
28
36
|
iconSize: 16,
|
|
29
|
-
|
|
37
|
+
fontSize: globalTokens.font.size[100],
|
|
38
|
+
square: {
|
|
39
|
+
borderRadius: globalTokens.corner.radius.small,
|
|
40
|
+
},
|
|
30
41
|
},
|
|
31
42
|
size24: {
|
|
32
43
|
width: 24,
|
|
33
44
|
height: 24,
|
|
34
45
|
badgeSize: 'smallest',
|
|
35
46
|
iconSize: 16,
|
|
36
|
-
|
|
47
|
+
fontSize: globalTokens.font.size[100],
|
|
48
|
+
square: {
|
|
49
|
+
borderRadius: globalTokens.corner.radius.small,
|
|
50
|
+
},
|
|
37
51
|
},
|
|
38
52
|
size28: {
|
|
39
53
|
width: 28,
|
|
40
54
|
height: 28,
|
|
41
55
|
badgeSize: 'smaller',
|
|
42
56
|
iconSize: 20,
|
|
43
|
-
|
|
57
|
+
fontWeight: globalTokens.font.weight.semibold,
|
|
58
|
+
fontSize: globalTokens.font.size[100],
|
|
44
59
|
},
|
|
45
60
|
size32: {
|
|
46
61
|
width: 32,
|
|
47
62
|
height: 32,
|
|
48
63
|
badgeSize: 'smaller',
|
|
49
64
|
iconSize: 20,
|
|
50
|
-
|
|
65
|
+
fontSize: globalTokens.font.size[100],
|
|
51
66
|
},
|
|
52
67
|
size36: {
|
|
53
68
|
width: 36,
|
|
54
69
|
height: 36,
|
|
55
70
|
badgeSize: 'smaller',
|
|
56
71
|
iconSize: 20,
|
|
57
|
-
initialsSize: 20,
|
|
58
72
|
},
|
|
59
73
|
size40: {
|
|
60
74
|
width: 40,
|
|
61
75
|
height: 40,
|
|
62
76
|
badgeSize: 'small',
|
|
63
77
|
iconSize: 20,
|
|
64
|
-
initialsSize: 20,
|
|
65
78
|
},
|
|
66
79
|
size48: {
|
|
67
80
|
width: 48,
|
|
68
81
|
height: 48,
|
|
69
82
|
badgeSize: 'small',
|
|
70
83
|
iconSize: 24,
|
|
71
|
-
initialsSize: 24,
|
|
72
84
|
},
|
|
73
85
|
size56: {
|
|
74
86
|
width: 56,
|
|
75
87
|
height: 56,
|
|
76
88
|
badgeSize: 'medium',
|
|
77
89
|
iconSize: 28,
|
|
78
|
-
|
|
90
|
+
fontSize: globalTokens.font.size[400],
|
|
91
|
+
square: {
|
|
92
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
93
|
+
},
|
|
79
94
|
},
|
|
80
95
|
size64: {
|
|
81
96
|
width: 64,
|
|
82
97
|
height: 64,
|
|
83
98
|
badgeSize: 'large',
|
|
84
99
|
iconSize: 32,
|
|
85
|
-
|
|
100
|
+
fontSize: globalTokens.font.size[500],
|
|
101
|
+
square: {
|
|
102
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
103
|
+
},
|
|
86
104
|
},
|
|
87
105
|
size72: {
|
|
88
106
|
width: 72,
|
|
89
107
|
height: 72,
|
|
90
108
|
badgeSize: 'large',
|
|
91
109
|
iconSize: 32,
|
|
92
|
-
|
|
110
|
+
fontSize: globalTokens.font.size[500],
|
|
111
|
+
square: {
|
|
112
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
113
|
+
},
|
|
93
114
|
},
|
|
94
115
|
size96: {
|
|
95
116
|
width: 96,
|
|
96
117
|
height: 96,
|
|
97
118
|
badgeSize: 'largest',
|
|
98
119
|
iconSize: 48,
|
|
99
|
-
|
|
120
|
+
fontWeight: globalTokens.font.weight.regular,
|
|
121
|
+
fontSize: globalTokens.font.size[700],
|
|
122
|
+
square: {
|
|
123
|
+
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
124
|
+
},
|
|
100
125
|
},
|
|
101
126
|
size120: {
|
|
102
127
|
width: 120,
|
|
103
128
|
height: 120,
|
|
104
129
|
badgeSize: 'largest',
|
|
105
130
|
iconSize: 48,
|
|
106
|
-
|
|
131
|
+
fontWeight: globalTokens.font.weight.regular,
|
|
132
|
+
fontSize: globalTokens.font.size[900],
|
|
133
|
+
square: {
|
|
134
|
+
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
135
|
+
},
|
|
107
136
|
},
|
|
108
137
|
neutral: {
|
|
109
138
|
backgroundColor: t.colors.neutralBackground6,
|
|
110
139
|
color: t.colors.neutralForeground3,
|
|
111
|
-
|
|
140
|
+
iconColor: t.colors.neutralForeground3,
|
|
141
|
+
ringColor: t.colors.transparentStroke,
|
|
112
142
|
},
|
|
113
143
|
brand: {
|
|
114
144
|
backgroundColor: t.colors.brandBackgroundStatic,
|
|
115
145
|
color: t.colors.neutralForegroundOnBrand,
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
backgroundColor: globalTokens.color.seafoam.primary,
|
|
150
|
-
},
|
|
151
|
-
darkGreen: {
|
|
152
|
-
backgroundColor: globalTokens.color.darkGreen.primary,
|
|
153
|
-
},
|
|
154
|
-
lightTeal: {
|
|
155
|
-
backgroundColor: globalTokens.color.lightTeal.primary,
|
|
156
|
-
},
|
|
157
|
-
teal: {
|
|
158
|
-
backgroundColor: globalTokens.color.teal.primary,
|
|
159
|
-
},
|
|
160
|
-
steel: {
|
|
161
|
-
backgroundColor: globalTokens.color.steel.primary,
|
|
162
|
-
},
|
|
163
|
-
blue: {
|
|
164
|
-
backgroundColor: globalTokens.color.blue.primary,
|
|
165
|
-
},
|
|
166
|
-
royalBlue: {
|
|
167
|
-
backgroundColor: globalTokens.color.royalBlue.primary,
|
|
168
|
-
},
|
|
169
|
-
cornflower: {
|
|
170
|
-
backgroundColor: globalTokens.color.cornflower.primary,
|
|
171
|
-
},
|
|
172
|
-
navy: {
|
|
173
|
-
backgroundColor: globalTokens.color.navy.primary,
|
|
174
|
-
},
|
|
175
|
-
lavender: {
|
|
176
|
-
backgroundColor: globalTokens.color.lavender.primary,
|
|
177
|
-
},
|
|
178
|
-
purple: {
|
|
179
|
-
backgroundColor: globalTokens.color.purple.primary,
|
|
180
|
-
},
|
|
181
|
-
grape: {
|
|
182
|
-
backgroundColor: globalTokens.color.grape.primary,
|
|
183
|
-
},
|
|
184
|
-
lilac: {
|
|
185
|
-
backgroundColor: globalTokens.color.lilac.primary,
|
|
186
|
-
},
|
|
187
|
-
pink: {
|
|
188
|
-
backgroundColor: globalTokens.color.pink.primary,
|
|
189
|
-
},
|
|
190
|
-
magenta: {
|
|
191
|
-
backgroundColor: globalTokens.color.magenta.primary,
|
|
192
|
-
},
|
|
193
|
-
plum: {
|
|
194
|
-
backgroundColor: globalTokens.color.plum.primary,
|
|
195
|
-
},
|
|
196
|
-
beige: {
|
|
197
|
-
backgroundColor: globalTokens.color.beige.primary,
|
|
198
|
-
},
|
|
199
|
-
mink: {
|
|
200
|
-
backgroundColor: globalTokens.color.mink.primary,
|
|
201
|
-
},
|
|
202
|
-
platinum: {
|
|
203
|
-
backgroundColor: globalTokens.color.platinum.primary,
|
|
204
|
-
},
|
|
205
|
-
anchor: {
|
|
206
|
-
backgroundColor: globalTokens.color.anchor.primary,
|
|
207
|
-
},
|
|
146
|
+
iconColor: t.colors.neutralForegroundOnBrand,
|
|
147
|
+
ringColor: t.colors.transparentStroke,
|
|
148
|
+
},
|
|
149
|
+
darkRed: getColorProps('darkRed', t),
|
|
150
|
+
cranberry: getColorProps('cranberry', t),
|
|
151
|
+
red: getColorProps('red', t),
|
|
152
|
+
pumpkin: getColorProps('pumpkin', t),
|
|
153
|
+
peach: getColorProps('peach', t),
|
|
154
|
+
marigold: getColorProps('marigold', t),
|
|
155
|
+
gold: getColorProps('gold', t),
|
|
156
|
+
brass: getColorProps('brass', t),
|
|
157
|
+
brown: getColorProps('brown', t),
|
|
158
|
+
forest: getColorProps('forest', t),
|
|
159
|
+
seafoam: getColorProps('seafoam', t),
|
|
160
|
+
darkGreen: getColorProps('darkGreen', t),
|
|
161
|
+
lightTeal: getColorProps('lightTeal', t),
|
|
162
|
+
teal: getColorProps('teal', t),
|
|
163
|
+
steel: getColorProps('steel', t),
|
|
164
|
+
blue: getColorProps('blue', t),
|
|
165
|
+
royalBlue: getColorProps('royalBlue', t),
|
|
166
|
+
cornflower: getColorProps('cornflower', t),
|
|
167
|
+
navy: getColorProps('navy', t),
|
|
168
|
+
lavender: getColorProps('lavender', t),
|
|
169
|
+
purple: getColorProps('purple', t),
|
|
170
|
+
grape: getColorProps('grape', t),
|
|
171
|
+
lilac: getColorProps('lilac', t),
|
|
172
|
+
pink: getColorProps('pink', t),
|
|
173
|
+
magenta: getColorProps('magenta', t),
|
|
174
|
+
plum: getColorProps('plum', t),
|
|
175
|
+
beige: getColorProps('beige', t),
|
|
176
|
+
mink: getColorProps('mink', t),
|
|
177
|
+
platinum: getColorProps('platinum', t),
|
|
178
|
+
anchor: getColorProps('anchor', t),
|
|
208
179
|
} as JSAvatarTokens);
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A function which returns object of props depending on color and theme.
|
|
183
|
+
* @param color
|
|
184
|
+
* @param theme
|
|
185
|
+
* @returns object of props - backgroundColor, color and ringColor
|
|
186
|
+
*/
|
|
187
|
+
function getColorProps(color: string, theme: Theme) {
|
|
188
|
+
const themeAppearance = theme.host.appearance;
|
|
189
|
+
switch (themeAppearance) {
|
|
190
|
+
case 'light':
|
|
191
|
+
default:
|
|
192
|
+
return {
|
|
193
|
+
backgroundColor: globalTokens.color[color].tint40,
|
|
194
|
+
color: globalTokens.color[color].shade30,
|
|
195
|
+
iconColor: globalTokens.color[color].shade30,
|
|
196
|
+
ringColor: globalTokens.color[color].primary,
|
|
197
|
+
};
|
|
198
|
+
case 'dark':
|
|
199
|
+
return {
|
|
200
|
+
backgroundColor: globalTokens.color[color].shade30,
|
|
201
|
+
color: globalTokens.color[color].tint40,
|
|
202
|
+
iconColor: globalTokens.color[color].tint40,
|
|
203
|
+
ringColor: globalTokens.color[color].tint30,
|
|
204
|
+
};
|
|
205
|
+
case 'highContrast':
|
|
206
|
+
return {
|
|
207
|
+
backgroundColor: theme.colors.neutralBackground6,
|
|
208
|
+
color: theme.colors.neutralForeground3,
|
|
209
|
+
iconColor: theme.colors.neutralForeground3,
|
|
210
|
+
ringColor: theme.colors.transparentStroke,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
horizontalIconAlignment: 'end',
|
|
9
|
+
verticalIconAlignment: 'end',
|
|
10
|
+
color: globalTokens.color.white,
|
|
11
|
+
backgroundColor: globalTokens.color.cornflower.primary,
|
|
12
|
+
avatarOpacity: 1,
|
|
13
|
+
fontFamily: t.typography.families.primary,
|
|
14
|
+
fontWeight: globalTokens.font.weight.semibold,
|
|
15
|
+
fontSize: globalTokens.font.size[200],
|
|
16
|
+
width: 24,
|
|
17
|
+
height: 24,
|
|
18
|
+
iconSize: 16,
|
|
19
|
+
iconColor: globalTokens.color.white,
|
|
20
|
+
ringColor: t.colors.transparentStroke,
|
|
21
|
+
borderColor: globalTokens.color.white,
|
|
22
|
+
borderWidth: t.name === 'HighContrast' ? 1 : 0,
|
|
23
|
+
circular: {
|
|
24
|
+
borderRadius: globalTokens.corner.radius.circle,
|
|
25
|
+
},
|
|
26
|
+
square: {
|
|
27
|
+
borderRadius: globalTokens.corner.radius.medium,
|
|
28
|
+
},
|
|
29
|
+
inactive: {
|
|
30
|
+
avatarOpacity: 0.8,
|
|
31
|
+
},
|
|
32
|
+
size20: {
|
|
33
|
+
width: 20,
|
|
34
|
+
height: 20,
|
|
35
|
+
badgeSize: 'smallest',
|
|
36
|
+
iconSize: 16,
|
|
37
|
+
fontSize: globalTokens.font.size[100],
|
|
38
|
+
square: {
|
|
39
|
+
borderRadius: globalTokens.corner.radius.small,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
size24: {
|
|
43
|
+
width: 24,
|
|
44
|
+
height: 24,
|
|
45
|
+
badgeSize: 'smallest',
|
|
46
|
+
iconSize: 16,
|
|
47
|
+
fontSize: globalTokens.font.size[100],
|
|
48
|
+
square: {
|
|
49
|
+
borderRadius: globalTokens.corner.radius.small,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
size28: {
|
|
53
|
+
width: 28,
|
|
54
|
+
height: 28,
|
|
55
|
+
badgeSize: 'smaller',
|
|
56
|
+
iconSize: 20,
|
|
57
|
+
fontWeight: globalTokens.font.weight.semibold,
|
|
58
|
+
fontSize: globalTokens.font.size[100],
|
|
59
|
+
},
|
|
60
|
+
size32: {
|
|
61
|
+
width: 32,
|
|
62
|
+
height: 32,
|
|
63
|
+
badgeSize: 'smaller',
|
|
64
|
+
iconSize: 20,
|
|
65
|
+
fontSize: globalTokens.font.size[100],
|
|
66
|
+
},
|
|
67
|
+
size36: {
|
|
68
|
+
width: 36,
|
|
69
|
+
height: 36,
|
|
70
|
+
badgeSize: 'smaller',
|
|
71
|
+
iconSize: 20,
|
|
72
|
+
},
|
|
73
|
+
size40: {
|
|
74
|
+
width: 40,
|
|
75
|
+
height: 40,
|
|
76
|
+
badgeSize: 'small',
|
|
77
|
+
iconSize: 20,
|
|
78
|
+
},
|
|
79
|
+
size48: {
|
|
80
|
+
width: 48,
|
|
81
|
+
height: 48,
|
|
82
|
+
badgeSize: 'small',
|
|
83
|
+
iconSize: 24,
|
|
84
|
+
},
|
|
85
|
+
size56: {
|
|
86
|
+
width: 56,
|
|
87
|
+
height: 56,
|
|
88
|
+
badgeSize: 'medium',
|
|
89
|
+
iconSize: 28,
|
|
90
|
+
fontSize: globalTokens.font.size[400],
|
|
91
|
+
square: {
|
|
92
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
size64: {
|
|
96
|
+
width: 64,
|
|
97
|
+
height: 64,
|
|
98
|
+
badgeSize: 'large',
|
|
99
|
+
iconSize: 32,
|
|
100
|
+
fontSize: globalTokens.font.size[500],
|
|
101
|
+
square: {
|
|
102
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
size72: {
|
|
106
|
+
width: 72,
|
|
107
|
+
height: 72,
|
|
108
|
+
badgeSize: 'large',
|
|
109
|
+
iconSize: 32,
|
|
110
|
+
fontSize: globalTokens.font.size[500],
|
|
111
|
+
square: {
|
|
112
|
+
borderRadius: globalTokens.corner.radius.large,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
size96: {
|
|
116
|
+
width: 96,
|
|
117
|
+
height: 96,
|
|
118
|
+
badgeSize: 'largest',
|
|
119
|
+
iconSize: 48,
|
|
120
|
+
fontWeight: globalTokens.font.weight.regular,
|
|
121
|
+
fontSize: globalTokens.font.size[700],
|
|
122
|
+
square: {
|
|
123
|
+
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
size120: {
|
|
127
|
+
width: 120,
|
|
128
|
+
height: 120,
|
|
129
|
+
badgeSize: 'largest',
|
|
130
|
+
iconSize: 48,
|
|
131
|
+
fontWeight: globalTokens.font.weight.regular,
|
|
132
|
+
fontSize: globalTokens.font.size[900],
|
|
133
|
+
square: {
|
|
134
|
+
borderRadius: globalTokens.corner.radius.extraLarge,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
neutral: {
|
|
138
|
+
backgroundColor: t.colors.neutralBackground6,
|
|
139
|
+
color: t.colors.neutralForeground3,
|
|
140
|
+
ringColor: t.colors.transparentStroke,
|
|
141
|
+
},
|
|
142
|
+
brand: {
|
|
143
|
+
backgroundColor: t.colors.brandBackgroundStatic,
|
|
144
|
+
color: t.colors.neutralForegroundOnBrand,
|
|
145
|
+
ringColor: t.colors.transparentStroke,
|
|
146
|
+
},
|
|
147
|
+
darkRed: getColorProps('darkRed', t),
|
|
148
|
+
cranberry: getColorProps('cranberry', t),
|
|
149
|
+
red: getColorProps('red', t),
|
|
150
|
+
pumpkin: getColorProps('pumpkin', t),
|
|
151
|
+
peach: getColorProps('peach', t),
|
|
152
|
+
marigold: getColorProps('marigold', t),
|
|
153
|
+
gold: getColorProps('gold', t),
|
|
154
|
+
brass: getColorProps('brass', t),
|
|
155
|
+
brown: getColorProps('brown', t),
|
|
156
|
+
forest: getColorProps('forest', t),
|
|
157
|
+
seafoam: getColorProps('seafoam', t),
|
|
158
|
+
darkGreen: getColorProps('darkGreen', t),
|
|
159
|
+
lightTeal: getColorProps('lightTeal', t),
|
|
160
|
+
teal: getColorProps('teal', t),
|
|
161
|
+
steel: getColorProps('steel', t),
|
|
162
|
+
blue: getColorProps('blue', t),
|
|
163
|
+
royalBlue: getColorProps('royalBlue', t),
|
|
164
|
+
cornflower: getColorProps('cornflower', t),
|
|
165
|
+
navy: getColorProps('navy', t),
|
|
166
|
+
lavender: getColorProps('lavender', t),
|
|
167
|
+
purple: getColorProps('purple', t),
|
|
168
|
+
grape: getColorProps('grape', t),
|
|
169
|
+
lilac: getColorProps('lilac', t),
|
|
170
|
+
pink: getColorProps('pink', t),
|
|
171
|
+
magenta: getColorProps('magenta', t),
|
|
172
|
+
plum: getColorProps('plum', t),
|
|
173
|
+
beige: getColorProps('beige', t),
|
|
174
|
+
mink: getColorProps('mink', t),
|
|
175
|
+
platinum: getColorProps('platinum', t),
|
|
176
|
+
anchor: getColorProps('anchor', t),
|
|
177
|
+
} as JSAvatarTokens);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A function which returns object of props depending on color and theme.
|
|
181
|
+
* @param color
|
|
182
|
+
* @param theme
|
|
183
|
+
* @returns object of props - backgroundColor, color and ringColor
|
|
184
|
+
*/
|
|
185
|
+
function getColorProps(color: string, theme: Theme) {
|
|
186
|
+
const themeAppearance = theme.name;
|
|
187
|
+
switch (themeAppearance) {
|
|
188
|
+
case 'White':
|
|
189
|
+
case 'Colorful':
|
|
190
|
+
default:
|
|
191
|
+
return {
|
|
192
|
+
backgroundColor: globalTokens.color[color].tint40,
|
|
193
|
+
color: globalTokens.color[color].shade30,
|
|
194
|
+
iconColor: globalTokens.color[color].shade30,
|
|
195
|
+
ringColor: globalTokens.color[color].primary,
|
|
196
|
+
};
|
|
197
|
+
case 'DarkGray':
|
|
198
|
+
case 'Black':
|
|
199
|
+
return {
|
|
200
|
+
backgroundColor: globalTokens.color[color].shade30,
|
|
201
|
+
color: globalTokens.color[color].tint40,
|
|
202
|
+
iconColor: globalTokens.color[color].tint40,
|
|
203
|
+
ringColor: globalTokens.color[color].tint30,
|
|
204
|
+
};
|
|
205
|
+
case 'HighContrast':
|
|
206
|
+
return {
|
|
207
|
+
backgroundColor: theme.colors.neutralBackground6,
|
|
208
|
+
color: theme.colors.neutralForeground3,
|
|
209
|
+
iconColor: theme.colors.neutralForeground3,
|
|
210
|
+
ringColor: theme.colors.transparentStroke,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|