@fluentui/react-avatar 9.2.6 → 9.2.8
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 +105 -1
- package/CHANGELOG.md +31 -2
- package/dist/index.d.ts +35 -4
- package/lib/components/AvatarGroupItem/useAvatarGroupItemStyles.js +18 -1
- package/lib/components/AvatarGroupItem/useAvatarGroupItemStyles.js.map +1 -1
- package/lib-amd/Avatar.js +6 -0
- package/lib-amd/Avatar.js.map +1 -0
- package/lib-amd/AvatarGroup.js +6 -0
- package/lib-amd/AvatarGroup.js.map +1 -0
- package/lib-amd/AvatarGroupItem.js +6 -0
- package/lib-amd/AvatarGroupItem.js.map +1 -0
- package/lib-amd/AvatarGroupPopover.js +6 -0
- package/lib-amd/AvatarGroupPopover.js.map +1 -0
- package/lib-amd/components/Avatar/Avatar.js +12 -0
- package/lib-amd/components/Avatar/Avatar.js.map +1 -0
- package/lib-amd/components/Avatar/Avatar.types.js +5 -0
- package/lib-amd/components/Avatar/Avatar.types.js.map +1 -0
- package/lib-amd/components/Avatar/index.js +10 -0
- package/lib-amd/components/Avatar/index.js.map +1 -0
- package/lib-amd/components/Avatar/renderAvatar.js +16 -0
- package/lib-amd/components/Avatar/renderAvatar.js.map +1 -0
- package/lib-amd/components/Avatar/useAvatar.js +175 -0
- package/lib-amd/components/Avatar/useAvatar.js.map +1 -0
- package/lib-amd/components/Avatar/useAvatarStyles.js +390 -0
- package/lib-amd/components/Avatar/useAvatarStyles.js.map +1 -0
- package/lib-amd/components/AvatarGroup/AvatarGroup.js +17 -0
- package/lib-amd/components/AvatarGroup/AvatarGroup.js.map +1 -0
- package/lib-amd/components/AvatarGroup/AvatarGroup.types.js +5 -0
- package/lib-amd/components/AvatarGroup/AvatarGroup.types.js.map +1 -0
- package/lib-amd/components/AvatarGroup/index.js +11 -0
- package/lib-amd/components/AvatarGroup/index.js.map +1 -0
- package/lib-amd/components/AvatarGroup/renderAvatarGroup.js +15 -0
- package/lib-amd/components/AvatarGroup/renderAvatarGroup.js.map +1 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroup.js +29 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroup.js.map +1 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroupContextValues.js +15 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroupContextValues.js.map +1 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroupStyles.js +36 -0
- package/lib-amd/components/AvatarGroup/useAvatarGroupStyles.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.js +16 -0
- package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.types.js +5 -0
- package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.types.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/index.js +10 -0
- package/lib-amd/components/AvatarGroupItem/index.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/renderAvatarGroupItem.js +16 -0
- package/lib-amd/components/AvatarGroupItem/renderAvatarGroupItem.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/useAvatarGroupItem.js +58 -0
- package/lib-amd/components/AvatarGroupItem/useAvatarGroupItem.js.map +1 -0
- package/lib-amd/components/AvatarGroupItem/useAvatarGroupItemStyles.js +236 -0
- package/lib-amd/components/AvatarGroupItem/useAvatarGroupItemStyles.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.js +17 -0
- package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.types.js +5 -0
- package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.types.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/index.js +10 -0
- package/lib-amd/components/AvatarGroupPopover/index.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/renderAvatarGroupPopover.js +20 -0
- package/lib-amd/components/AvatarGroupPopover/renderAvatarGroupPopover.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopover.js +86 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopover.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverContextValues.js +14 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverContextValues.js.map +1 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverStyles.js +136 -0
- package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverStyles.js.map +1 -0
- package/lib-amd/contexts/AvatarContext.js +17 -0
- package/lib-amd/contexts/AvatarContext.js.map +1 -0
- package/lib-amd/contexts/AvatarGroupContext.js +20 -0
- package/lib-amd/contexts/AvatarGroupContext.js.map +1 -0
- package/lib-amd/contexts/index.js +7 -0
- package/lib-amd/contexts/index.js.map +1 -0
- package/lib-amd/index.js +33 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/utils/getInitials.js +87 -0
- package/lib-amd/utils/getInitials.js.map +1 -0
- package/lib-amd/utils/index.js +8 -0
- package/lib-amd/utils/index.js.map +1 -0
- package/lib-amd/utils/partitionAvatarGroupItems.js +32 -0
- package/lib-amd/utils/partitionAvatarGroupItems.js.map +1 -0
- package/lib-commonjs/components/AvatarGroupItem/useAvatarGroupItemStyles.js +19 -1
- package/lib-commonjs/components/AvatarGroupItem/useAvatarGroupItemStyles.js.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../utils/index", "@fluentui/react-icons", "@fluentui/react-badge", "@fluentui/react-shared-contexts", "../../contexts/AvatarContext"], function (require, exports, tslib_1, React, react_utilities_1, index_1, react_icons_1, react_badge_1, react_shared_contexts_1, AvatarContext_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useAvatar_unstable = exports.DEFAULT_STRINGS = void 0;
|
|
5
|
+
exports.DEFAULT_STRINGS = {
|
|
6
|
+
active: 'active',
|
|
7
|
+
inactive: 'inactive',
|
|
8
|
+
};
|
|
9
|
+
var useAvatar_unstable = function (props, ref) {
|
|
10
|
+
var _a;
|
|
11
|
+
var dir = react_shared_contexts_1.useFluent_unstable().dir;
|
|
12
|
+
var contextSize = AvatarContext_1.useAvatarContext().size;
|
|
13
|
+
var name = props.name, _b = props.size, size = _b === void 0 ? contextSize !== null && contextSize !== void 0 ? contextSize : 32 : _b, _c = props.shape, shape = _c === void 0 ? 'circular' : _c, _d = props.active, active = _d === void 0 ? 'unset' : _d, _e = props.activeAppearance, activeAppearance = _e === void 0 ? 'ring' : _e, idForColor = props.idForColor;
|
|
14
|
+
var _f = props.color, color = _f === void 0 ? 'neutral' : _f;
|
|
15
|
+
// Resolve 'colorful' to a specific color name
|
|
16
|
+
if (color === 'colorful') {
|
|
17
|
+
color = avatarColors[getHashCode((_a = idForColor !== null && idForColor !== void 0 ? idForColor : name) !== null && _a !== void 0 ? _a : '') % avatarColors.length];
|
|
18
|
+
}
|
|
19
|
+
var baseId = react_utilities_1.useId('avatar-');
|
|
20
|
+
var root = react_utilities_1.getNativeElementProps('span', tslib_1.__assign(tslib_1.__assign({ role: 'img', id: baseId }, props), { ref: ref }),
|
|
21
|
+
/* excludedPropNames: */ ['name']);
|
|
22
|
+
// Resolve the initials slot, defaulted to getInitials.
|
|
23
|
+
var initials = react_utilities_1.resolveShorthand(props.initials, {
|
|
24
|
+
required: true,
|
|
25
|
+
defaultProps: {
|
|
26
|
+
children: index_1.getInitials(name, dir === 'rtl', { firstInitialOnly: size <= 16 }),
|
|
27
|
+
id: baseId + '__initials',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
// Render the icon slot *only if* there aren't any initials to display.
|
|
31
|
+
var icon = undefined;
|
|
32
|
+
if (!(initials === null || initials === void 0 ? void 0 : initials.children)) {
|
|
33
|
+
initials = undefined;
|
|
34
|
+
icon = react_utilities_1.resolveShorthand(props.icon, {
|
|
35
|
+
required: true,
|
|
36
|
+
defaultProps: {
|
|
37
|
+
children: React.createElement(react_icons_1.PersonRegular, null),
|
|
38
|
+
'aria-hidden': true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var _g = React.useState(undefined), imageHidden = _g[0], setImageHidden = _g[1];
|
|
43
|
+
var image = react_utilities_1.resolveShorthand(props.image, {
|
|
44
|
+
defaultProps: {
|
|
45
|
+
alt: '',
|
|
46
|
+
role: 'presentation',
|
|
47
|
+
'aria-hidden': true,
|
|
48
|
+
hidden: imageHidden,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// Hide the image if it fails to load and restore it on a successful load
|
|
52
|
+
if (image) {
|
|
53
|
+
image.onError = react_utilities_1.mergeCallbacks(image.onError, function () { return setImageHidden(true); });
|
|
54
|
+
image.onLoad = react_utilities_1.mergeCallbacks(image.onLoad, function () { return setImageHidden(undefined); });
|
|
55
|
+
}
|
|
56
|
+
var badge = react_utilities_1.resolveShorthand(props.badge, {
|
|
57
|
+
defaultProps: {
|
|
58
|
+
size: getBadgeSize(size),
|
|
59
|
+
id: baseId + '__badge',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
var activeAriaLabelElement;
|
|
63
|
+
// Resolve aria-label and/or aria-labelledby if not provided by the user
|
|
64
|
+
if (!root['aria-label'] && !root['aria-labelledby']) {
|
|
65
|
+
if (name) {
|
|
66
|
+
root['aria-label'] = name;
|
|
67
|
+
// Include the badge in labelledby if it exists
|
|
68
|
+
if (badge) {
|
|
69
|
+
root['aria-labelledby'] = root.id + ' ' + badge.id;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (initials) {
|
|
73
|
+
// root's aria-label should be the name, but fall back to being labelledby the initials if name is missing
|
|
74
|
+
root['aria-labelledby'] = initials.id + (badge ? ' ' + badge.id : '');
|
|
75
|
+
}
|
|
76
|
+
// Add the active state to the aria label
|
|
77
|
+
if (active === 'active' || active === 'inactive') {
|
|
78
|
+
var activeText = exports.DEFAULT_STRINGS[active];
|
|
79
|
+
if (root['aria-labelledby']) {
|
|
80
|
+
// If using aria-labelledby, render a hidden span and append it to the labelledby
|
|
81
|
+
var activeId = baseId + '__active';
|
|
82
|
+
root['aria-labelledby'] += ' ' + activeId;
|
|
83
|
+
activeAriaLabelElement = (React.createElement("span", { hidden: true, id: activeId }, activeText));
|
|
84
|
+
}
|
|
85
|
+
else if (root['aria-label']) {
|
|
86
|
+
// Otherwise, just append it to the aria-label
|
|
87
|
+
root['aria-label'] += ' ' + activeText;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
size: size,
|
|
93
|
+
shape: shape,
|
|
94
|
+
active: active,
|
|
95
|
+
activeAppearance: activeAppearance,
|
|
96
|
+
activeAriaLabelElement: activeAriaLabelElement,
|
|
97
|
+
color: color,
|
|
98
|
+
components: {
|
|
99
|
+
root: 'span',
|
|
100
|
+
initials: 'span',
|
|
101
|
+
icon: 'span',
|
|
102
|
+
image: 'img',
|
|
103
|
+
badge: react_badge_1.PresenceBadge,
|
|
104
|
+
},
|
|
105
|
+
root: root,
|
|
106
|
+
initials: initials,
|
|
107
|
+
icon: icon,
|
|
108
|
+
image: image,
|
|
109
|
+
badge: badge,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
exports.useAvatar_unstable = useAvatar_unstable;
|
|
113
|
+
var getBadgeSize = function (size) {
|
|
114
|
+
if (size >= 96) {
|
|
115
|
+
return 'extra-large';
|
|
116
|
+
}
|
|
117
|
+
else if (size >= 64) {
|
|
118
|
+
return 'large';
|
|
119
|
+
}
|
|
120
|
+
else if (size >= 56) {
|
|
121
|
+
return 'medium';
|
|
122
|
+
}
|
|
123
|
+
else if (size >= 40) {
|
|
124
|
+
return 'small';
|
|
125
|
+
}
|
|
126
|
+
else if (size >= 28) {
|
|
127
|
+
return 'extra-small';
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return 'tiny';
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var avatarColors = [
|
|
134
|
+
'dark-red',
|
|
135
|
+
'cranberry',
|
|
136
|
+
'red',
|
|
137
|
+
'pumpkin',
|
|
138
|
+
'peach',
|
|
139
|
+
'marigold',
|
|
140
|
+
'gold',
|
|
141
|
+
'brass',
|
|
142
|
+
'brown',
|
|
143
|
+
'forest',
|
|
144
|
+
'seafoam',
|
|
145
|
+
'dark-green',
|
|
146
|
+
'light-teal',
|
|
147
|
+
'teal',
|
|
148
|
+
'steel',
|
|
149
|
+
'blue',
|
|
150
|
+
'royal-blue',
|
|
151
|
+
'cornflower',
|
|
152
|
+
'navy',
|
|
153
|
+
'lavender',
|
|
154
|
+
'purple',
|
|
155
|
+
'grape',
|
|
156
|
+
'lilac',
|
|
157
|
+
'pink',
|
|
158
|
+
'magenta',
|
|
159
|
+
'plum',
|
|
160
|
+
'beige',
|
|
161
|
+
'mink',
|
|
162
|
+
'platinum',
|
|
163
|
+
'anchor',
|
|
164
|
+
];
|
|
165
|
+
var getHashCode = function (str) {
|
|
166
|
+
var hashCode = 0;
|
|
167
|
+
for (var len = str.length - 1; len >= 0; len--) {
|
|
168
|
+
var ch = str.charCodeAt(len);
|
|
169
|
+
var shift = len % 8;
|
|
170
|
+
hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise
|
|
171
|
+
}
|
|
172
|
+
return hashCode;
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
//# sourceMappingURL=useAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvatar.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/useAvatar.tsx"],"names":[],"mappings":";;;;IASa,QAAA,eAAe,GAAG;QAC7B,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;KACrB,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,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE;YACtD,IAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAM,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;YACtB,QAAQ,IAAI,CAAC,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,iCAAiC;SACnF;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { getInitials } from '../../utils/index';\nimport type { AvatarNamedColor, AvatarProps, AvatarState } from './Avatar.types';\nimport { PersonRegular } from '@fluentui/react-icons';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useAvatarContext } from '../../contexts/AvatarContext';\n\nexport const DEFAULT_STRINGS = {\n active: 'active',\n inactive: 'inactive',\n};\n\nexport const useAvatar_unstable = (props: AvatarProps, ref: React.Ref<HTMLElement>): AvatarState => {\n const { dir } = useFluent();\n const { size: contextSize } = useAvatarContext();\n const {\n name,\n size = contextSize ?? (32 as const),\n shape = 'circular',\n active = 'unset',\n activeAppearance = 'ring',\n idForColor,\n } = props;\n let { color = 'neutral' } = props;\n\n // Resolve 'colorful' to a specific color name\n if (color === 'colorful') {\n color = avatarColors[getHashCode(idForColor ?? name ?? '') % avatarColors.length];\n }\n\n const baseId = useId('avatar-');\n\n const root: AvatarState['root'] = getNativeElementProps(\n 'span',\n {\n role: 'img',\n id: baseId,\n // aria-label and/or aria-labelledby are resolved below\n ...props,\n ref,\n },\n /* excludedPropNames: */ ['name'],\n );\n\n // Resolve the initials slot, defaulted to getInitials.\n let initials: AvatarState['initials'] = resolveShorthand(props.initials, {\n required: true,\n defaultProps: {\n children: getInitials(name, dir === 'rtl', { firstInitialOnly: size <= 16 }),\n id: baseId + '__initials',\n },\n });\n\n // Render the icon slot *only if* there aren't any initials to display.\n let icon: AvatarState['icon'] = undefined;\n if (!initials?.children) {\n initials = undefined;\n icon = resolveShorthand(props.icon, {\n required: true,\n defaultProps: {\n children: <PersonRegular />,\n 'aria-hidden': true,\n },\n });\n }\n\n const [imageHidden, setImageHidden] = React.useState<true | undefined>(undefined);\n const image: AvatarState['image'] = resolveShorthand(props.image, {\n defaultProps: {\n alt: '',\n role: 'presentation',\n 'aria-hidden': true,\n hidden: imageHidden,\n },\n });\n\n // Hide the image if it fails to load and restore it on a successful load\n if (image) {\n image.onError = mergeCallbacks(image.onError, () => setImageHidden(true));\n image.onLoad = mergeCallbacks(image.onLoad, () => setImageHidden(undefined));\n }\n\n const badge: AvatarState['badge'] = resolveShorthand(props.badge, {\n defaultProps: {\n size: getBadgeSize(size),\n id: baseId + '__badge',\n },\n });\n\n let activeAriaLabelElement: AvatarState['activeAriaLabelElement'];\n\n // Resolve aria-label and/or aria-labelledby if not provided by the user\n if (!root['aria-label'] && !root['aria-labelledby']) {\n if (name) {\n root['aria-label'] = name;\n\n // Include the badge in labelledby if it exists\n if (badge) {\n root['aria-labelledby'] = root.id + ' ' + badge.id;\n }\n } else if (initials) {\n // root's aria-label should be the name, but fall back to being labelledby the initials if name is missing\n root['aria-labelledby'] = initials.id + (badge ? ' ' + badge.id : '');\n }\n\n // Add the active state to the aria label\n if (active === 'active' || active === 'inactive') {\n const activeText = DEFAULT_STRINGS[active];\n if (root['aria-labelledby']) {\n // If using aria-labelledby, render a hidden span and append it to the labelledby\n const activeId = baseId + '__active';\n root['aria-labelledby'] += ' ' + activeId;\n activeAriaLabelElement = (\n <span hidden id={activeId}>\n {activeText}\n </span>\n );\n } else if (root['aria-label']) {\n // Otherwise, just append it to the aria-label\n root['aria-label'] += ' ' + activeText;\n }\n }\n }\n\n return {\n size,\n shape,\n active,\n activeAppearance,\n activeAriaLabelElement,\n color,\n\n components: {\n root: 'span',\n initials: 'span',\n icon: 'span',\n image: 'img',\n badge: PresenceBadge,\n },\n\n root,\n initials,\n icon,\n image,\n badge,\n };\n};\n\nconst getBadgeSize = (size: AvatarState['size']) => {\n if (size >= 96) {\n return 'extra-large';\n } else if (size >= 64) {\n return 'large';\n } else if (size >= 56) {\n return 'medium';\n } else if (size >= 40) {\n return 'small';\n } else if (size >= 28) {\n return 'extra-small';\n } else {\n return 'tiny';\n }\n};\n\nconst avatarColors: AvatarNamedColor[] = [\n 'dark-red',\n 'cranberry',\n 'red',\n 'pumpkin',\n 'peach',\n 'marigold',\n 'gold',\n 'brass',\n 'brown',\n 'forest',\n 'seafoam',\n 'dark-green',\n 'light-teal',\n 'teal',\n 'steel',\n 'blue',\n 'royal-blue',\n 'cornflower',\n 'navy',\n 'lavender',\n 'purple',\n 'grape',\n 'lilac',\n 'pink',\n 'magenta',\n 'plum',\n 'beige',\n 'mink',\n 'platinum',\n 'anchor',\n];\n\nconst getHashCode = (str: string): number => {\n let hashCode = 0;\n for (let len: number = str.length - 1; len >= 0; len--) {\n const ch = str.charCodeAt(len);\n const shift = len % 8;\n hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise\n }\n\n return hashCode;\n};\n"]}
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-theme"], function (require, exports, tslib_1, react_1, react_theme_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useAvatarStyles_unstable = exports.useSizeStyles = exports.avatarClassNames = void 0;
|
|
5
|
+
exports.avatarClassNames = {
|
|
6
|
+
root: 'fui-Avatar',
|
|
7
|
+
image: 'fui-Avatar__image',
|
|
8
|
+
initials: 'fui-Avatar__initials',
|
|
9
|
+
icon: 'fui-Avatar__icon',
|
|
10
|
+
badge: 'fui-Avatar__badge',
|
|
11
|
+
};
|
|
12
|
+
var animations = {
|
|
13
|
+
fastOutSlowInMax: react_theme_1.tokens.curveDecelerateMax,
|
|
14
|
+
fastOutSlowInMid: react_theme_1.tokens.curveDecelerateMid,
|
|
15
|
+
fastOutSlowInMin: react_theme_1.tokens.curveDecelerateMin,
|
|
16
|
+
slowOutFastInMax: react_theme_1.tokens.curveAccelerateMax,
|
|
17
|
+
slowOutFastInMid: react_theme_1.tokens.curveAccelerateMid,
|
|
18
|
+
slowOutFastInMin: react_theme_1.tokens.curveAccelerateMin,
|
|
19
|
+
fastEase: react_theme_1.tokens.curveEasyEaseMax,
|
|
20
|
+
normalEase: react_theme_1.tokens.curveEasyEase,
|
|
21
|
+
nullEasing: react_theme_1.tokens.curveLinear,
|
|
22
|
+
};
|
|
23
|
+
var useStyles = react_1.makeStyles({
|
|
24
|
+
root: tslib_1.__assign(tslib_1.__assign({ display: 'inline-block', flexShrink: 0, position: 'relative', verticalAlign: 'middle' }, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusCircular)), { fontFamily: react_theme_1.tokens.fontFamilyBase, fontWeight: react_theme_1.tokens.fontWeightSemibold }),
|
|
25
|
+
textCaption2Strong: {
|
|
26
|
+
fontSize: react_theme_1.tokens.fontSizeBase100,
|
|
27
|
+
fontWeight: react_theme_1.tokens.fontWeightSemibold,
|
|
28
|
+
},
|
|
29
|
+
textCaption1Strong: { fontSize: react_theme_1.tokens.fontSizeBase200 },
|
|
30
|
+
textBody1Strong: { fontSize: react_theme_1.tokens.fontSizeBase300 },
|
|
31
|
+
textSubtitle2: { fontSize: react_theme_1.tokens.fontSizeBase400 },
|
|
32
|
+
textSubtitle1: { fontSize: react_theme_1.tokens.fontSizeBase500 },
|
|
33
|
+
textTitle: { fontSize: react_theme_1.tokens.fontSizeBase600 },
|
|
34
|
+
squareSmall: tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusSmall)),
|
|
35
|
+
squareMedium: tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)),
|
|
36
|
+
squareLarge: tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusLarge)),
|
|
37
|
+
squareXLarge: tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusXLarge)),
|
|
38
|
+
activeOrInactive: {
|
|
39
|
+
transform: 'perspective(1px)',
|
|
40
|
+
transitionProperty: 'transform, opacity',
|
|
41
|
+
transitionDuration: react_theme_1.tokens.durationUltraSlow + ", " + react_theme_1.tokens.durationFaster,
|
|
42
|
+
transitionDelay: animations.fastEase + ", " + animations.nullEasing,
|
|
43
|
+
'@media screen and (prefers-reduced-motion: reduce)': {
|
|
44
|
+
transitionDuration: '0.01ms',
|
|
45
|
+
},
|
|
46
|
+
'::before': tslib_1.__assign(tslib_1.__assign({ content: '""', position: 'absolute', top: 0, left: 0, bottom: 0, right: 0 }, react_1.shorthands.borderRadius('inherit')), { transitionProperty: 'margin, opacity', transitionDuration: react_theme_1.tokens.durationUltraSlow + ", " + react_theme_1.tokens.durationSlower, transitionDelay: animations.fastEase + ", " + animations.nullEasing, '@media screen and (prefers-reduced-motion: reduce)': {
|
|
47
|
+
transitionDuration: '0.01ms',
|
|
48
|
+
transitionDelay: '0.01ms',
|
|
49
|
+
} }),
|
|
50
|
+
},
|
|
51
|
+
ring: {
|
|
52
|
+
'::before': tslib_1.__assign({}, react_1.shorthands.borderStyle('solid')),
|
|
53
|
+
},
|
|
54
|
+
ringThick: {
|
|
55
|
+
'::before': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.margin("calc(-2 * " + react_theme_1.tokens.strokeWidthThick + ")")), react_1.shorthands.borderWidth(react_theme_1.tokens.strokeWidthThick)),
|
|
56
|
+
},
|
|
57
|
+
ringThicker: {
|
|
58
|
+
'::before': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.margin("calc(-2 * " + react_theme_1.tokens.strokeWidthThicker + ")")), react_1.shorthands.borderWidth(react_theme_1.tokens.strokeWidthThicker)),
|
|
59
|
+
},
|
|
60
|
+
ringThickest: {
|
|
61
|
+
'::before': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.margin("calc(-2 * " + react_theme_1.tokens.strokeWidthThickest + ")")), react_1.shorthands.borderWidth(react_theme_1.tokens.strokeWidthThickest)),
|
|
62
|
+
},
|
|
63
|
+
shadow4: { '::before': { boxShadow: react_theme_1.tokens.shadow4 } },
|
|
64
|
+
shadow8: { '::before': { boxShadow: react_theme_1.tokens.shadow8 } },
|
|
65
|
+
shadow16: { '::before': { boxShadow: react_theme_1.tokens.shadow16 } },
|
|
66
|
+
shadow28: { '::before': { boxShadow: react_theme_1.tokens.shadow28 } },
|
|
67
|
+
inactive: {
|
|
68
|
+
opacity: '0.8',
|
|
69
|
+
transform: 'scale(0.875)',
|
|
70
|
+
transitionProperty: 'transform, opacity',
|
|
71
|
+
transitionDuration: react_theme_1.tokens.durationUltraSlow + ", " + react_theme_1.tokens.durationFaster,
|
|
72
|
+
transitionDelay: animations.fastOutSlowInMin + ", " + animations.nullEasing,
|
|
73
|
+
'@media screen and (prefers-reduced-motion: reduce)': {
|
|
74
|
+
transitionDuration: '0.01ms',
|
|
75
|
+
transitionDelay: '0.01ms',
|
|
76
|
+
},
|
|
77
|
+
'::before': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.margin(0)), { opacity: 0, transitionProperty: 'margin, opacity', transitionDuration: react_theme_1.tokens.durationUltraSlow + ", " + react_theme_1.tokens.durationSlower, transitionDelay: animations.fastOutSlowInMin + ", " + animations.nullEasing, '@media screen and (prefers-reduced-motion: reduce)': {
|
|
78
|
+
transitionDuration: '0.01ms',
|
|
79
|
+
transitionDelay: '0.01ms',
|
|
80
|
+
} }),
|
|
81
|
+
},
|
|
82
|
+
badge: {
|
|
83
|
+
position: 'absolute',
|
|
84
|
+
bottom: 0,
|
|
85
|
+
right: 0,
|
|
86
|
+
boxShadow: "0 0 0 " + react_theme_1.tokens.strokeWidthThin + " " + react_theme_1.tokens.colorNeutralBackground1,
|
|
87
|
+
},
|
|
88
|
+
badgeLarge: {
|
|
89
|
+
boxShadow: "0 0 0 " + react_theme_1.tokens.strokeWidthThick + " " + react_theme_1.tokens.colorNeutralBackground1,
|
|
90
|
+
},
|
|
91
|
+
image: tslib_1.__assign(tslib_1.__assign({ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }, react_1.shorthands.borderRadius('inherit')), { objectFit: 'cover', verticalAlign: 'top' }),
|
|
92
|
+
iconInitials: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ position: 'absolute', boxSizing: 'border-box', top: 0, left: 0, width: '100%', height: '100%', lineHeight: '1' }, react_1.shorthands.border(react_theme_1.tokens.strokeWidthThin, 'solid', react_theme_1.tokens.colorTransparentStroke)), { display: 'flex', alignItems: 'center', justifyContent: 'center', verticalAlign: 'center', textAlign: 'center', userSelect: 'none' }), react_1.shorthands.borderRadius('inherit')),
|
|
93
|
+
icon12: { fontSize: '12px' },
|
|
94
|
+
icon16: { fontSize: '16px' },
|
|
95
|
+
icon20: { fontSize: '20px' },
|
|
96
|
+
icon24: { fontSize: '24px' },
|
|
97
|
+
icon28: { fontSize: '28px' },
|
|
98
|
+
icon32: { fontSize: '32px' },
|
|
99
|
+
icon48: { fontSize: '48px' },
|
|
100
|
+
});
|
|
101
|
+
exports.useSizeStyles = react_1.makeStyles({
|
|
102
|
+
16: { width: '16px', height: '16px' },
|
|
103
|
+
20: { width: '20px', height: '20px' },
|
|
104
|
+
24: { width: '24px', height: '24px' },
|
|
105
|
+
28: { width: '28px', height: '28px' },
|
|
106
|
+
32: { width: '32px', height: '32px' },
|
|
107
|
+
36: { width: '36px', height: '36px' },
|
|
108
|
+
40: { width: '40px', height: '40px' },
|
|
109
|
+
48: { width: '48px', height: '48px' },
|
|
110
|
+
56: { width: '56px', height: '56px' },
|
|
111
|
+
64: { width: '64px', height: '64px' },
|
|
112
|
+
72: { width: '72px', height: '72px' },
|
|
113
|
+
96: { width: '96px', height: '96px' },
|
|
114
|
+
120: { width: '120px', height: '120px' },
|
|
115
|
+
128: { width: '128px', height: '128px' },
|
|
116
|
+
});
|
|
117
|
+
var useColorStyles = react_1.makeStyles({
|
|
118
|
+
neutral: {
|
|
119
|
+
color: react_theme_1.tokens.colorNeutralForeground3,
|
|
120
|
+
backgroundColor: react_theme_1.tokens.colorNeutralBackground6,
|
|
121
|
+
// The ::before element is the ring when active
|
|
122
|
+
'::before': { color: react_theme_1.tokens.colorBrandStroke1 },
|
|
123
|
+
},
|
|
124
|
+
brand: {
|
|
125
|
+
color: react_theme_1.tokens.colorNeutralForegroundStaticInverted,
|
|
126
|
+
backgroundColor: react_theme_1.tokens.colorBrandBackgroundStatic,
|
|
127
|
+
'::before': { color: react_theme_1.tokens.colorBrandStroke1 },
|
|
128
|
+
},
|
|
129
|
+
'dark-red': {
|
|
130
|
+
color: react_theme_1.tokens.colorPaletteDarkRedForeground2,
|
|
131
|
+
backgroundColor: react_theme_1.tokens.colorPaletteDarkRedBackground2,
|
|
132
|
+
'::before': { color: react_theme_1.tokens.colorPaletteDarkRedBorderActive },
|
|
133
|
+
},
|
|
134
|
+
cranberry: {
|
|
135
|
+
color: react_theme_1.tokens.colorPaletteCranberryForeground2,
|
|
136
|
+
backgroundColor: react_theme_1.tokens.colorPaletteCranberryBackground2,
|
|
137
|
+
'::before': { color: react_theme_1.tokens.colorPaletteCranberryBorderActive },
|
|
138
|
+
},
|
|
139
|
+
red: {
|
|
140
|
+
color: react_theme_1.tokens.colorPaletteRedForeground2,
|
|
141
|
+
backgroundColor: react_theme_1.tokens.colorPaletteRedBackground2,
|
|
142
|
+
'::before': { color: react_theme_1.tokens.colorPaletteRedBorderActive },
|
|
143
|
+
},
|
|
144
|
+
pumpkin: {
|
|
145
|
+
color: react_theme_1.tokens.colorPalettePumpkinForeground2,
|
|
146
|
+
backgroundColor: react_theme_1.tokens.colorPalettePumpkinBackground2,
|
|
147
|
+
'::before': { color: react_theme_1.tokens.colorPalettePumpkinBorderActive },
|
|
148
|
+
},
|
|
149
|
+
peach: {
|
|
150
|
+
color: react_theme_1.tokens.colorPalettePeachForeground2,
|
|
151
|
+
backgroundColor: react_theme_1.tokens.colorPalettePeachBackground2,
|
|
152
|
+
'::before': { color: react_theme_1.tokens.colorPalettePeachBorderActive },
|
|
153
|
+
},
|
|
154
|
+
marigold: {
|
|
155
|
+
color: react_theme_1.tokens.colorPaletteMarigoldForeground2,
|
|
156
|
+
backgroundColor: react_theme_1.tokens.colorPaletteMarigoldBackground2,
|
|
157
|
+
'::before': { color: react_theme_1.tokens.colorPaletteMarigoldBorderActive },
|
|
158
|
+
},
|
|
159
|
+
gold: {
|
|
160
|
+
color: react_theme_1.tokens.colorPaletteGoldForeground2,
|
|
161
|
+
backgroundColor: react_theme_1.tokens.colorPaletteGoldBackground2,
|
|
162
|
+
'::before': { color: react_theme_1.tokens.colorPaletteGoldBorderActive },
|
|
163
|
+
},
|
|
164
|
+
brass: {
|
|
165
|
+
color: react_theme_1.tokens.colorPaletteBrassForeground2,
|
|
166
|
+
backgroundColor: react_theme_1.tokens.colorPaletteBrassBackground2,
|
|
167
|
+
'::before': { color: react_theme_1.tokens.colorPaletteBrassBorderActive },
|
|
168
|
+
},
|
|
169
|
+
brown: {
|
|
170
|
+
color: react_theme_1.tokens.colorPaletteBrownForeground2,
|
|
171
|
+
backgroundColor: react_theme_1.tokens.colorPaletteBrownBackground2,
|
|
172
|
+
'::before': { color: react_theme_1.tokens.colorPaletteBrownBorderActive },
|
|
173
|
+
},
|
|
174
|
+
forest: {
|
|
175
|
+
color: react_theme_1.tokens.colorPaletteForestForeground2,
|
|
176
|
+
backgroundColor: react_theme_1.tokens.colorPaletteForestBackground2,
|
|
177
|
+
'::before': { color: react_theme_1.tokens.colorPaletteForestBorderActive },
|
|
178
|
+
},
|
|
179
|
+
seafoam: {
|
|
180
|
+
color: react_theme_1.tokens.colorPaletteSeafoamForeground2,
|
|
181
|
+
backgroundColor: react_theme_1.tokens.colorPaletteSeafoamBackground2,
|
|
182
|
+
'::before': { color: react_theme_1.tokens.colorPaletteSeafoamBorderActive },
|
|
183
|
+
},
|
|
184
|
+
'dark-green': {
|
|
185
|
+
color: react_theme_1.tokens.colorPaletteDarkGreenForeground2,
|
|
186
|
+
backgroundColor: react_theme_1.tokens.colorPaletteDarkGreenBackground2,
|
|
187
|
+
'::before': { color: react_theme_1.tokens.colorPaletteDarkGreenBorderActive },
|
|
188
|
+
},
|
|
189
|
+
'light-teal': {
|
|
190
|
+
color: react_theme_1.tokens.colorPaletteLightTealForeground2,
|
|
191
|
+
backgroundColor: react_theme_1.tokens.colorPaletteLightTealBackground2,
|
|
192
|
+
'::before': { color: react_theme_1.tokens.colorPaletteLightTealBorderActive },
|
|
193
|
+
},
|
|
194
|
+
teal: {
|
|
195
|
+
color: react_theme_1.tokens.colorPaletteTealForeground2,
|
|
196
|
+
backgroundColor: react_theme_1.tokens.colorPaletteTealBackground2,
|
|
197
|
+
'::before': { color: react_theme_1.tokens.colorPaletteTealBorderActive },
|
|
198
|
+
},
|
|
199
|
+
steel: {
|
|
200
|
+
color: react_theme_1.tokens.colorPaletteSteelForeground2,
|
|
201
|
+
backgroundColor: react_theme_1.tokens.colorPaletteSteelBackground2,
|
|
202
|
+
'::before': { color: react_theme_1.tokens.colorPaletteSteelBorderActive },
|
|
203
|
+
},
|
|
204
|
+
blue: {
|
|
205
|
+
color: react_theme_1.tokens.colorPaletteBlueForeground2,
|
|
206
|
+
backgroundColor: react_theme_1.tokens.colorPaletteBlueBackground2,
|
|
207
|
+
'::before': { color: react_theme_1.tokens.colorPaletteBlueBorderActive },
|
|
208
|
+
},
|
|
209
|
+
'royal-blue': {
|
|
210
|
+
color: react_theme_1.tokens.colorPaletteRoyalBlueForeground2,
|
|
211
|
+
backgroundColor: react_theme_1.tokens.colorPaletteRoyalBlueBackground2,
|
|
212
|
+
'::before': { color: react_theme_1.tokens.colorPaletteRoyalBlueBorderActive },
|
|
213
|
+
},
|
|
214
|
+
cornflower: {
|
|
215
|
+
color: react_theme_1.tokens.colorPaletteCornflowerForeground2,
|
|
216
|
+
backgroundColor: react_theme_1.tokens.colorPaletteCornflowerBackground2,
|
|
217
|
+
'::before': { color: react_theme_1.tokens.colorPaletteCornflowerBorderActive },
|
|
218
|
+
},
|
|
219
|
+
navy: {
|
|
220
|
+
color: react_theme_1.tokens.colorPaletteNavyForeground2,
|
|
221
|
+
backgroundColor: react_theme_1.tokens.colorPaletteNavyBackground2,
|
|
222
|
+
'::before': { color: react_theme_1.tokens.colorPaletteNavyBorderActive },
|
|
223
|
+
},
|
|
224
|
+
lavender: {
|
|
225
|
+
color: react_theme_1.tokens.colorPaletteLavenderForeground2,
|
|
226
|
+
backgroundColor: react_theme_1.tokens.colorPaletteLavenderBackground2,
|
|
227
|
+
'::before': { color: react_theme_1.tokens.colorPaletteLavenderBorderActive },
|
|
228
|
+
},
|
|
229
|
+
purple: {
|
|
230
|
+
color: react_theme_1.tokens.colorPalettePurpleForeground2,
|
|
231
|
+
backgroundColor: react_theme_1.tokens.colorPalettePurpleBackground2,
|
|
232
|
+
'::before': { color: react_theme_1.tokens.colorPalettePurpleBorderActive },
|
|
233
|
+
},
|
|
234
|
+
grape: {
|
|
235
|
+
color: react_theme_1.tokens.colorPaletteGrapeForeground2,
|
|
236
|
+
backgroundColor: react_theme_1.tokens.colorPaletteGrapeBackground2,
|
|
237
|
+
'::before': { color: react_theme_1.tokens.colorPaletteGrapeBorderActive },
|
|
238
|
+
},
|
|
239
|
+
lilac: {
|
|
240
|
+
color: react_theme_1.tokens.colorPaletteLilacForeground2,
|
|
241
|
+
backgroundColor: react_theme_1.tokens.colorPaletteLilacBackground2,
|
|
242
|
+
'::before': { color: react_theme_1.tokens.colorPaletteLilacBorderActive },
|
|
243
|
+
},
|
|
244
|
+
pink: {
|
|
245
|
+
color: react_theme_1.tokens.colorPalettePinkForeground2,
|
|
246
|
+
backgroundColor: react_theme_1.tokens.colorPalettePinkBackground2,
|
|
247
|
+
'::before': { color: react_theme_1.tokens.colorPalettePinkBorderActive },
|
|
248
|
+
},
|
|
249
|
+
magenta: {
|
|
250
|
+
color: react_theme_1.tokens.colorPaletteMagentaForeground2,
|
|
251
|
+
backgroundColor: react_theme_1.tokens.colorPaletteMagentaBackground2,
|
|
252
|
+
'::before': { color: react_theme_1.tokens.colorPaletteMagentaBorderActive },
|
|
253
|
+
},
|
|
254
|
+
plum: {
|
|
255
|
+
color: react_theme_1.tokens.colorPalettePlumForeground2,
|
|
256
|
+
backgroundColor: react_theme_1.tokens.colorPalettePlumBackground2,
|
|
257
|
+
'::before': { color: react_theme_1.tokens.colorPalettePlumBorderActive },
|
|
258
|
+
},
|
|
259
|
+
beige: {
|
|
260
|
+
color: react_theme_1.tokens.colorPaletteBeigeForeground2,
|
|
261
|
+
backgroundColor: react_theme_1.tokens.colorPaletteBeigeBackground2,
|
|
262
|
+
'::before': { color: react_theme_1.tokens.colorPaletteBeigeBorderActive },
|
|
263
|
+
},
|
|
264
|
+
mink: {
|
|
265
|
+
color: react_theme_1.tokens.colorPaletteMinkForeground2,
|
|
266
|
+
backgroundColor: react_theme_1.tokens.colorPaletteMinkBackground2,
|
|
267
|
+
'::before': { color: react_theme_1.tokens.colorPaletteMinkBorderActive },
|
|
268
|
+
},
|
|
269
|
+
platinum: {
|
|
270
|
+
color: react_theme_1.tokens.colorPalettePlatinumForeground2,
|
|
271
|
+
backgroundColor: react_theme_1.tokens.colorPalettePlatinumBackground2,
|
|
272
|
+
'::before': { color: react_theme_1.tokens.colorPalettePlatinumBorderActive },
|
|
273
|
+
},
|
|
274
|
+
anchor: {
|
|
275
|
+
color: react_theme_1.tokens.colorPaletteAnchorForeground2,
|
|
276
|
+
backgroundColor: react_theme_1.tokens.colorPaletteAnchorBackground2,
|
|
277
|
+
'::before': { color: react_theme_1.tokens.colorPaletteAnchorBorderActive },
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
var useAvatarStyles_unstable = function (state) {
|
|
281
|
+
var size = state.size, shape = state.shape, active = state.active, activeAppearance = state.activeAppearance, color = state.color;
|
|
282
|
+
var styles = useStyles();
|
|
283
|
+
var sizeStyles = exports.useSizeStyles();
|
|
284
|
+
var colorStyles = useColorStyles();
|
|
285
|
+
var rootClasses = [styles.root, sizeStyles[size], colorStyles[color]];
|
|
286
|
+
if (size <= 24) {
|
|
287
|
+
rootClasses.push(styles.textCaption2Strong);
|
|
288
|
+
}
|
|
289
|
+
else if (size <= 28) {
|
|
290
|
+
rootClasses.push(styles.textCaption1Strong);
|
|
291
|
+
}
|
|
292
|
+
else if (size <= 40) {
|
|
293
|
+
rootClasses.push(styles.textBody1Strong);
|
|
294
|
+
}
|
|
295
|
+
else if (size <= 56) {
|
|
296
|
+
rootClasses.push(styles.textSubtitle2);
|
|
297
|
+
}
|
|
298
|
+
else if (size <= 96) {
|
|
299
|
+
rootClasses.push(styles.textSubtitle1);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
rootClasses.push(styles.textTitle);
|
|
303
|
+
}
|
|
304
|
+
if (shape === 'square') {
|
|
305
|
+
if (size <= 24) {
|
|
306
|
+
rootClasses.push(styles.squareSmall);
|
|
307
|
+
}
|
|
308
|
+
else if (size <= 48) {
|
|
309
|
+
rootClasses.push(styles.squareMedium);
|
|
310
|
+
}
|
|
311
|
+
else if (size <= 72) {
|
|
312
|
+
rootClasses.push(styles.squareLarge);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
rootClasses.push(styles.squareXLarge);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (active === 'active' || active === 'inactive') {
|
|
319
|
+
rootClasses.push(styles.activeOrInactive);
|
|
320
|
+
if (activeAppearance === 'ring' || activeAppearance === 'ring-shadow') {
|
|
321
|
+
rootClasses.push(styles.ring);
|
|
322
|
+
if (size <= 48) {
|
|
323
|
+
rootClasses.push(styles.ringThick);
|
|
324
|
+
}
|
|
325
|
+
else if (size <= 64) {
|
|
326
|
+
rootClasses.push(styles.ringThicker);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
rootClasses.push(styles.ringThickest);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (activeAppearance === 'shadow' || activeAppearance === 'ring-shadow') {
|
|
333
|
+
if (size <= 28) {
|
|
334
|
+
rootClasses.push(styles.shadow4);
|
|
335
|
+
}
|
|
336
|
+
else if (size <= 48) {
|
|
337
|
+
rootClasses.push(styles.shadow8);
|
|
338
|
+
}
|
|
339
|
+
else if (size <= 64) {
|
|
340
|
+
rootClasses.push(styles.shadow16);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
rootClasses.push(styles.shadow28);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Note: The inactive style overrides some of the activeAppearance styles and must be applied after them
|
|
347
|
+
if (active === 'inactive') {
|
|
348
|
+
rootClasses.push(styles.inactive);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
state.root.className = react_1.mergeClasses.apply(void 0, tslib_1.__spreadArray(tslib_1.__spreadArray([exports.avatarClassNames.root], rootClasses), [state.root.className]));
|
|
352
|
+
if (state.badge) {
|
|
353
|
+
state.badge.className = react_1.mergeClasses(exports.avatarClassNames.badge, styles.badge, size >= 64 && styles.badgeLarge, state.badge.className);
|
|
354
|
+
}
|
|
355
|
+
if (state.image) {
|
|
356
|
+
state.image.className = react_1.mergeClasses(exports.avatarClassNames.image, styles.image, state.image.className);
|
|
357
|
+
}
|
|
358
|
+
if (state.initials) {
|
|
359
|
+
state.initials.className = react_1.mergeClasses(exports.avatarClassNames.initials, styles.iconInitials, state.initials.className);
|
|
360
|
+
}
|
|
361
|
+
if (state.icon) {
|
|
362
|
+
var iconSizeClass = void 0;
|
|
363
|
+
if (size <= 16) {
|
|
364
|
+
iconSizeClass = styles.icon12;
|
|
365
|
+
}
|
|
366
|
+
else if (size <= 24) {
|
|
367
|
+
iconSizeClass = styles.icon16;
|
|
368
|
+
}
|
|
369
|
+
else if (size <= 40) {
|
|
370
|
+
iconSizeClass = styles.icon20;
|
|
371
|
+
}
|
|
372
|
+
else if (size <= 48) {
|
|
373
|
+
iconSizeClass = styles.icon24;
|
|
374
|
+
}
|
|
375
|
+
else if (size <= 56) {
|
|
376
|
+
iconSizeClass = styles.icon28;
|
|
377
|
+
}
|
|
378
|
+
else if (size <= 72) {
|
|
379
|
+
iconSizeClass = styles.icon32;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
iconSizeClass = styles.icon48;
|
|
383
|
+
}
|
|
384
|
+
state.icon.className = react_1.mergeClasses(exports.avatarClassNames.icon, styles.iconInitials, iconSizeClass, state.icon.className);
|
|
385
|
+
}
|
|
386
|
+
return state;
|
|
387
|
+
};
|
|
388
|
+
exports.useAvatarStyles_unstable = useAvatarStyles_unstable;
|
|
389
|
+
});
|
|
390
|
+
//# sourceMappingURL=useAvatarStyles.js.map
|