@fluentui/react-avatar 9.0.0-alpha.80 → 9.0.0-alpha.84
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 +149 -1
- package/CHANGELOG.md +50 -2
- package/SPEC.md +72 -71
- package/dist/react-avatar.d.ts +24 -9
- package/lib/Avatar.js.map +1 -1
- package/lib/common/isConformant.js.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts +14 -2
- package/lib/components/Avatar/Avatar.js.map +1 -1
- package/lib/components/Avatar/Avatar.types.d.ts +6 -5
- package/lib/components/Avatar/Avatar.types.js.map +1 -1
- package/lib/components/Avatar/index.js.map +1 -1
- package/lib/components/Avatar/renderAvatar.js.map +1 -1
- package/lib/components/Avatar/useAvatar.js +1 -0
- package/lib/components/Avatar/useAvatar.js.map +1 -1
- package/lib/components/Avatar/useAvatarStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/getInitials.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib-commonjs/Avatar.js.map +1 -1
- package/lib-commonjs/common/isConformant.js.map +1 -1
- package/lib-commonjs/components/Avatar/Avatar.d.ts +14 -2
- package/lib-commonjs/components/Avatar/Avatar.js.map +1 -1
- package/lib-commonjs/components/Avatar/Avatar.types.d.ts +6 -5
- package/lib-commonjs/components/Avatar/Avatar.types.js.map +1 -1
- package/lib-commonjs/components/Avatar/index.js.map +1 -1
- package/lib-commonjs/components/Avatar/renderAvatar.js.map +1 -1
- package/lib-commonjs/components/Avatar/useAvatar.js +1 -0
- package/lib-commonjs/components/Avatar/useAvatar.js.map +1 -1
- package/lib-commonjs/components/Avatar/useAvatarStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/getInitials.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/package.json +11 -11
- package/lib-amd/Avatar.d.ts +0 -1
- package/lib-amd/Avatar.js +0 -6
- package/lib-amd/Avatar.js.map +0 -1
- package/lib-amd/common/isConformant.d.ts +0 -4
- package/lib-amd/common/isConformant.js +0 -16
- package/lib-amd/common/isConformant.js.map +0 -1
- package/lib-amd/components/Avatar/Avatar.d.ts +0 -3
- package/lib-amd/components/Avatar/Avatar.js +0 -12
- package/lib-amd/components/Avatar/Avatar.js.map +0 -1
- package/lib-amd/components/Avatar/Avatar.types.d.ts +0 -108
- package/lib-amd/components/Avatar/Avatar.types.js +0 -5
- package/lib-amd/components/Avatar/Avatar.types.js.map +0 -1
- package/lib-amd/components/Avatar/index.d.ts +0 -5
- package/lib-amd/components/Avatar/index.js +0 -10
- package/lib-amd/components/Avatar/index.js.map +0 -1
- package/lib-amd/components/Avatar/renderAvatar.d.ts +0 -2
- package/lib-amd/components/Avatar/renderAvatar.js +0 -15
- package/lib-amd/components/Avatar/renderAvatar.js.map +0 -1
- package/lib-amd/components/Avatar/useAvatar.d.ts +0 -7
- package/lib-amd/components/Avatar/useAvatar.js +0 -141
- package/lib-amd/components/Avatar/useAvatar.js.map +0 -1
- package/lib-amd/components/Avatar/useAvatarStyles.d.ts +0 -2
- package/lib-amd/components/Avatar/useAvatarStyles.js +0 -416
- package/lib-amd/components/Avatar/useAvatarStyles.js.map +0 -1
- package/lib-amd/index.d.ts +0 -1
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/utils/getInitials.d.ts +0 -9
- package/lib-amd/utils/getInitials.js +0 -79
- package/lib-amd/utils/getInitials.js.map +0 -1
- package/lib-amd/utils/index.d.ts +0 -1
- package/lib-amd/utils/index.js +0 -7
- package/lib-amd/utils/index.js.map +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "./Avatar.types", "./Avatar", "./renderAvatar", "./useAvatar", "./useAvatarStyles"], function (require, exports, tslib_1, Avatar_types_1, Avatar_1, renderAvatar_1, useAvatar_1, useAvatarStyles_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
tslib_1.__exportStar(Avatar_types_1, exports);
|
|
5
|
-
tslib_1.__exportStar(Avatar_1, exports);
|
|
6
|
-
tslib_1.__exportStar(renderAvatar_1, exports);
|
|
7
|
-
tslib_1.__exportStar(useAvatar_1, exports);
|
|
8
|
-
tslib_1.__exportStar(useAvatarStyles_1, exports);
|
|
9
|
-
});
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Avatar/index.ts"],"names":[],"mappings":";;;IAAA,8CAA+B;IAC/B,wCAAyB;IACzB,8CAA+B;IAC/B,2CAA4B;IAC5B,iDAAkC","sourcesContent":["export * from './Avatar.types';\nexport * from './Avatar';\nexport * from './renderAvatar';\nexport * from './useAvatar';\nexport * from './useAvatarStyles';\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "./useAvatar"], function (require, exports, tslib_1, React, react_utilities_1, useAvatar_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.renderAvatar = void 0;
|
|
5
|
-
var renderAvatar = function (state) {
|
|
6
|
-
var _a = react_utilities_1.getSlotsCompat(state, useAvatar_1.avatarShorthandPropsCompat), slots = _a.slots, slotProps = _a.slotProps;
|
|
7
|
-
return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
|
|
8
|
-
React.createElement(slots.label, tslib_1.__assign({}, slotProps.label)),
|
|
9
|
-
state.showIcon && React.createElement(slots.icon, tslib_1.__assign({}, slotProps.icon)),
|
|
10
|
-
React.createElement(slots.image, tslib_1.__assign({}, slotProps.image)),
|
|
11
|
-
React.createElement(slots.badge, tslib_1.__assign({}, slotProps.badge))));
|
|
12
|
-
};
|
|
13
|
-
exports.renderAvatar = renderAvatar;
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=renderAvatar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderAvatar.js","sourceRoot":"../src/","sources":["components/Avatar/renderAvatar.tsx"],"names":[],"mappings":";;;;IAKO,IAAM,YAAY,GAAG,UAAC,KAAkB;QACvC,IAAA,KAAuB,gCAAc,CAAC,KAAK,EAAE,sCAA0B,CAAC,EAAtE,KAAK,WAAA,EAAE,SAAS,eAAsD,CAAC;QAC/E,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC5B,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACnC,KAAK,CAAC,QAAQ,IAAI,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI;YACrD,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACpC,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI,CACzB,CACd,CAAC;IACJ,CAAC,CAAC;IAVW,QAAA,YAAY,gBAUvB","sourcesContent":["import * as React from 'react';\nimport { getSlotsCompat } from '@fluentui/react-utilities';\nimport { avatarShorthandPropsCompat } from './useAvatar';\nimport type { AvatarState } from './Avatar.types';\n\nexport const renderAvatar = (state: AvatarState) => {\n const { slots, slotProps } = getSlotsCompat(state, avatarShorthandPropsCompat);\n return (\n <slots.root {...slotProps.root}>\n <slots.label {...slotProps.label} />\n {state.showIcon && <slots.icon {...slotProps.icon} />}\n <slots.image {...slotProps.image} />\n <slots.badge {...slotProps.badge} />\n </slots.root>\n );\n};\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { AvatarProps, AvatarState, AvatarShorthandPropsCompat } from './Avatar.types';
|
|
3
|
-
/**
|
|
4
|
-
* Names of the shorthand properties in AvatarProps
|
|
5
|
-
*/
|
|
6
|
-
export declare const avatarShorthandPropsCompat: AvatarShorthandPropsCompat[];
|
|
7
|
-
export declare const useAvatar: (props: AvatarProps, ref: React.Ref<HTMLElement>, defaultProps?: AvatarProps | undefined) => AvatarState;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../utils/index", "@fluentui/react-icons", "@fluentui/react-badge"], function (require, exports, tslib_1, React, react_utilities_1, index_1, react_icons_1, react_badge_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useAvatar = exports.avatarShorthandPropsCompat = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Names of the shorthand properties in AvatarProps
|
|
7
|
-
*/
|
|
8
|
-
exports.avatarShorthandPropsCompat = ['label', 'image', 'badge', 'icon'];
|
|
9
|
-
var mergeProps = react_utilities_1.makeMergeProps({ deepMerge: exports.avatarShorthandPropsCompat });
|
|
10
|
-
var useAvatar = function (props, ref, defaultProps) {
|
|
11
|
-
var state = mergeProps({
|
|
12
|
-
as: 'span',
|
|
13
|
-
label: { as: 'span' },
|
|
14
|
-
icon: { as: 'span' },
|
|
15
|
-
size: 32,
|
|
16
|
-
color: 'neutral',
|
|
17
|
-
activeDisplay: 'ring',
|
|
18
|
-
getInitials: index_1.getInitials,
|
|
19
|
-
ref: ref,
|
|
20
|
-
}, defaultProps && resolveAvatarShorthandPropsCompat(defaultProps), resolveAvatarShorthandPropsCompat(props));
|
|
21
|
-
var size = state.size, badge = state.badge, label = state.label, icon = state.icon;
|
|
22
|
-
// If a label was not provided, use the initials and fall back to the icon if initials aren't available
|
|
23
|
-
if (!label.children) {
|
|
24
|
-
var initials = state.getInitials(state.name || '', /*isRtl: */ false);
|
|
25
|
-
if (initials) {
|
|
26
|
-
label.children = initials;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
state.showIcon = true;
|
|
30
|
-
if (!icon.children) {
|
|
31
|
-
if (size <= 24) {
|
|
32
|
-
icon.children = React.createElement(react_icons_1.Person16Regular, null);
|
|
33
|
-
}
|
|
34
|
-
else if (size <= 40) {
|
|
35
|
-
icon.children = React.createElement(react_icons_1.Person20Regular, null);
|
|
36
|
-
}
|
|
37
|
-
else if (size <= 48) {
|
|
38
|
-
icon.children = React.createElement(react_icons_1.Person24Regular, null);
|
|
39
|
-
}
|
|
40
|
-
else if (size <= 56) {
|
|
41
|
-
icon.children = React.createElement(react_icons_1.Person28Regular, null);
|
|
42
|
-
}
|
|
43
|
-
else if (size <= 72) {
|
|
44
|
-
icon.children = React.createElement(react_icons_1.Person32Regular, null);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
icon.children = React.createElement(react_icons_1.Person48Regular, null);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Provide a default badge size based on the avatar size
|
|
53
|
-
if (badge && badge.size === undefined) {
|
|
54
|
-
if (size >= 96) {
|
|
55
|
-
badge.size = 'larger';
|
|
56
|
-
}
|
|
57
|
-
else if (size >= 64) {
|
|
58
|
-
badge.size = 'large';
|
|
59
|
-
}
|
|
60
|
-
else if (size >= 56) {
|
|
61
|
-
badge.size = 'medium';
|
|
62
|
-
}
|
|
63
|
-
else if (size >= 40) {
|
|
64
|
-
badge.size = 'small';
|
|
65
|
-
}
|
|
66
|
-
else if (size >= 28) {
|
|
67
|
-
badge.size = 'smaller';
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
badge.size = 'smallest';
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (state.color === 'colorful') {
|
|
74
|
-
var value = state.idForColor || state.name;
|
|
75
|
-
if (value) {
|
|
76
|
-
state.color = avatarColors[getHashCode(value) % avatarColors.length];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return state;
|
|
80
|
-
};
|
|
81
|
-
exports.useAvatar = useAvatar;
|
|
82
|
-
/**
|
|
83
|
-
* Avatar treats shorthand for the image and badge props differently. Rather than the string being
|
|
84
|
-
* the child of those slots, they translate to the image's src and the badge's status prop.
|
|
85
|
-
*/
|
|
86
|
-
var resolveAvatarShorthandPropsCompat = function (props) {
|
|
87
|
-
var image = props.image, badge = props.badge;
|
|
88
|
-
if (typeof image === 'string') {
|
|
89
|
-
image = { as: 'img', src: image, children: null };
|
|
90
|
-
}
|
|
91
|
-
if (typeof badge === 'string') {
|
|
92
|
-
badge = { as: react_badge_1.PresenceBadge, status: badge };
|
|
93
|
-
}
|
|
94
|
-
if (image !== props.image || badge !== props.badge) {
|
|
95
|
-
props = tslib_1.__assign(tslib_1.__assign({}, props), { image: image, badge: badge });
|
|
96
|
-
}
|
|
97
|
-
return react_utilities_1.resolveShorthandProps(props, exports.avatarShorthandPropsCompat);
|
|
98
|
-
};
|
|
99
|
-
var avatarColors = [
|
|
100
|
-
'darkRed',
|
|
101
|
-
'cranberry',
|
|
102
|
-
'red',
|
|
103
|
-
'pumpkin',
|
|
104
|
-
'peach',
|
|
105
|
-
'marigold',
|
|
106
|
-
'gold',
|
|
107
|
-
'brass',
|
|
108
|
-
'brown',
|
|
109
|
-
'forest',
|
|
110
|
-
'seafoam',
|
|
111
|
-
'darkGreen',
|
|
112
|
-
'lightTeal',
|
|
113
|
-
'teal',
|
|
114
|
-
'steel',
|
|
115
|
-
'blue',
|
|
116
|
-
'royalBlue',
|
|
117
|
-
'cornflower',
|
|
118
|
-
'navy',
|
|
119
|
-
'lavender',
|
|
120
|
-
'purple',
|
|
121
|
-
'grape',
|
|
122
|
-
'lilac',
|
|
123
|
-
'pink',
|
|
124
|
-
'magenta',
|
|
125
|
-
'plum',
|
|
126
|
-
'beige',
|
|
127
|
-
'mink',
|
|
128
|
-
'platinum',
|
|
129
|
-
'anchor',
|
|
130
|
-
];
|
|
131
|
-
var getHashCode = function (str) {
|
|
132
|
-
var hashCode = 0;
|
|
133
|
-
for (var len = str.length - 1; len >= 0; len--) {
|
|
134
|
-
var ch = str.charCodeAt(len);
|
|
135
|
-
var shift = len % 8;
|
|
136
|
-
hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise
|
|
137
|
-
}
|
|
138
|
-
return hashCode;
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
//# sourceMappingURL=useAvatar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAvatar.js","sourceRoot":"../src/","sources":["components/Avatar/useAvatar.tsx"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { makeMergeProps, resolveShorthandProps } from '@fluentui/react-utilities';\nimport { getInitials } from '../../utils/index';\nimport {\n Person16Regular,\n Person20Regular,\n Person24Regular,\n Person28Regular,\n Person32Regular,\n Person48Regular,\n} from '@fluentui/react-icons';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { AvatarProps, AvatarState, AvatarNamedColor, AvatarShorthandPropsCompat } from './Avatar.types';\n\n/**\n * Names of the shorthand properties in AvatarProps\n */\nexport const avatarShorthandPropsCompat: AvatarShorthandPropsCompat[] = ['label', 'image', 'badge', 'icon'];\n\nconst mergeProps = makeMergeProps<AvatarState>({ deepMerge: avatarShorthandPropsCompat });\n\nexport const useAvatar = (props: AvatarProps, ref: React.Ref<HTMLElement>, defaultProps?: AvatarProps): AvatarState => {\n const state = mergeProps(\n {\n as: 'span',\n label: { as: 'span' },\n icon: { as: 'span' },\n size: 32,\n color: 'neutral',\n activeDisplay: 'ring',\n getInitials,\n ref,\n },\n defaultProps && resolveAvatarShorthandPropsCompat(defaultProps),\n resolveAvatarShorthandPropsCompat(props),\n );\n\n const { size, badge, label, icon } = state;\n\n // If a label was not provided, use the initials and fall back to the icon if initials aren't available\n if (!label.children) {\n const initials = state.getInitials(state.name || '', /*isRtl: */ false);\n if (initials) {\n label.children = initials;\n } else {\n state.showIcon = true;\n if (!icon.children) {\n if (size <= 24) {\n icon.children = <Person16Regular />;\n } else if (size <= 40) {\n icon.children = <Person20Regular />;\n } else if (size <= 48) {\n icon.children = <Person24Regular />;\n } else if (size <= 56) {\n icon.children = <Person28Regular />;\n } else if (size <= 72) {\n icon.children = <Person32Regular />;\n } else {\n icon.children = <Person48Regular />;\n }\n }\n }\n }\n\n // Provide a default badge size based on the avatar size\n if (badge && badge.size === undefined) {\n if (size >= 96) {\n badge.size = 'larger';\n } else if (size >= 64) {\n badge.size = 'large';\n } else if (size >= 56) {\n badge.size = 'medium';\n } else if (size >= 40) {\n badge.size = 'small';\n } else if (size >= 28) {\n badge.size = 'smaller';\n } else {\n badge.size = 'smallest';\n }\n }\n\n if (state.color === 'colorful') {\n const value = state.idForColor || state.name;\n if (value) {\n state.color = avatarColors[getHashCode(value) % avatarColors.length];\n }\n }\n\n return state;\n};\n\n/**\n * Avatar treats shorthand for the image and badge props differently. Rather than the string being\n * the child of those slots, they translate to the image's src and the badge's status prop.\n */\nconst resolveAvatarShorthandPropsCompat = (props: AvatarProps) => {\n let { image, badge } = props;\n\n if (typeof image === 'string') {\n image = { as: 'img', src: image, children: null };\n }\n\n if (typeof badge === 'string') {\n badge = { as: PresenceBadge, status: badge };\n }\n\n if (image !== props.image || badge !== props.badge) {\n props = { ...props, image, badge };\n }\n\n return resolveShorthandProps(props, avatarShorthandPropsCompat);\n};\n\nconst avatarColors: AvatarNamedColor[] = [\n 'darkRed',\n 'cranberry',\n 'red',\n 'pumpkin',\n 'peach',\n 'marigold',\n 'gold',\n 'brass',\n 'brown',\n 'forest',\n 'seafoam',\n 'darkGreen',\n 'lightTeal',\n 'teal',\n 'steel',\n 'blue',\n 'royalBlue',\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"]}
|
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "@fluentui/react-make-styles"], function (require, exports, tslib_1, react_make_styles_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useAvatarStyles = void 0;
|
|
5
|
-
//
|
|
6
|
-
// TODO: All animation constants should go to theme or globals?
|
|
7
|
-
// https://github.com/microsoft/fluentui/issues/16372#issuecomment-778240665
|
|
8
|
-
var animationDuration = {
|
|
9
|
-
duration50: '50ms',
|
|
10
|
-
duration100: '100ms',
|
|
11
|
-
duration150: '150ms',
|
|
12
|
-
duration200: '200ms',
|
|
13
|
-
duration300: '300ms',
|
|
14
|
-
duration400: '400ms',
|
|
15
|
-
duration500: '500ms',
|
|
16
|
-
};
|
|
17
|
-
var animationTiming = {
|
|
18
|
-
ultraFast: animationDuration.duration50,
|
|
19
|
-
faster: animationDuration.duration100,
|
|
20
|
-
fast: animationDuration.duration150,
|
|
21
|
-
normal: animationDuration.duration200,
|
|
22
|
-
slow: animationDuration.duration300,
|
|
23
|
-
slower: animationDuration.duration400,
|
|
24
|
-
ultraSlow: animationDuration.duration500,
|
|
25
|
-
};
|
|
26
|
-
var animationLines = {
|
|
27
|
-
decelerateMax: 'cubic-bezier(0.00,0.00,0.00,1.00)',
|
|
28
|
-
decelerateMid: 'cubic-bezier(0.10,0.90,0.20,1.00)',
|
|
29
|
-
decelerateMin: 'cubic-bezier(0.33,0.00,0.10,1.00)',
|
|
30
|
-
accelerateMax: 'cubic-bezier(1.00,0.00,1.00,1.00)',
|
|
31
|
-
accelerateMid: 'cubic-bezier(0.90,0.10,1.00,0.20)',
|
|
32
|
-
accelerateMin: 'cubic-bezier(0.80,0.00,0.78,1.00)',
|
|
33
|
-
maxEasyEase: 'cubic-bezier(0.80,0.00,0.20,1.00)',
|
|
34
|
-
easyEase: 'cubic-bezier(0.33,0.00,0.67,1.00)',
|
|
35
|
-
linear: 'linear',
|
|
36
|
-
};
|
|
37
|
-
var animations = {
|
|
38
|
-
fastOutSlowInMax: animationLines.decelerateMax,
|
|
39
|
-
fastOutSlowInMid: animationLines.decelerateMid,
|
|
40
|
-
fastOutSlowInMin: animationLines.decelerateMin,
|
|
41
|
-
slowOutFastInMax: animationLines.accelerateMax,
|
|
42
|
-
slowOutFastInMid: animationLines.accelerateMid,
|
|
43
|
-
slowOutFastInMin: animationLines.accelerateMin,
|
|
44
|
-
fastEase: animationLines.maxEasyEase,
|
|
45
|
-
normalEase: animationLines.easyEase,
|
|
46
|
-
nullEasing: animationLines.linear,
|
|
47
|
-
};
|
|
48
|
-
var useStyles = react_make_styles_1.makeStyles({
|
|
49
|
-
root: function (theme) { return ({
|
|
50
|
-
display: 'inline-block',
|
|
51
|
-
flexShrink: 0,
|
|
52
|
-
position: 'relative',
|
|
53
|
-
verticalAlign: 'middle',
|
|
54
|
-
borderRadius: theme.global.borderRadius.circular,
|
|
55
|
-
fontFamily: theme.global.type.fontFamilies.base,
|
|
56
|
-
fontWeight: theme.global.type.fontWeights.semibold,
|
|
57
|
-
boxShadow: "0 0 0 " + theme.global.strokeWidth.thin + " " + theme.alias.color.neutral.transparentStroke + " inset",
|
|
58
|
-
}); },
|
|
59
|
-
textCaption2: function (theme) { return ({
|
|
60
|
-
fontSize: theme.global.type.fontSizes.base[100],
|
|
61
|
-
fontWeight: theme.global.type.fontWeights.regular,
|
|
62
|
-
}); },
|
|
63
|
-
textCaption1Strong: function (theme) { return ({ fontSize: theme.global.type.fontSizes.base[200] }); },
|
|
64
|
-
textBody1Strong: function (theme) { return ({ fontSize: theme.global.type.fontSizes.base[300] }); },
|
|
65
|
-
textSubtitle2: function (theme) { return ({ fontSize: theme.global.type.fontSizes.base[400] }); },
|
|
66
|
-
textSubtitle1: function (theme) { return ({ fontSize: theme.global.type.fontSizes.base[500] }); },
|
|
67
|
-
textTitle: function (theme) { return ({ fontSize: theme.global.type.fontSizes.base[600] }); },
|
|
68
|
-
squareSmall: function (theme) { return ({ borderRadius: theme.global.borderRadius.small }); },
|
|
69
|
-
squareMedium: function (theme) { return ({ borderRadius: theme.global.borderRadius.medium }); },
|
|
70
|
-
squareLarge: function (theme) { return ({ borderRadius: theme.global.borderRadius.large }); },
|
|
71
|
-
squareXLarge: function (theme) { return ({ borderRadius: theme.global.borderRadius.xLarge }); },
|
|
72
|
-
activeOrInactive: {
|
|
73
|
-
transform: 'perspective(1px)',
|
|
74
|
-
transition: "transform " + animationTiming.ultraSlow + " " + animations.fastEase + ", " +
|
|
75
|
-
("opacity " + animationTiming.faster + " " + animations.nullEasing),
|
|
76
|
-
':before': {
|
|
77
|
-
content: '""',
|
|
78
|
-
position: 'absolute',
|
|
79
|
-
top: 0,
|
|
80
|
-
left: 0,
|
|
81
|
-
bottom: 0,
|
|
82
|
-
right: 0,
|
|
83
|
-
borderRadius: 'inherit',
|
|
84
|
-
transition: "margin " + animationTiming.ultraSlow + " " + animations.fastEase + ", " +
|
|
85
|
-
("opacity " + animationTiming.slower + " " + animations.nullEasing),
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
ring: function (theme) { return ({
|
|
89
|
-
':before': {
|
|
90
|
-
borderColor: theme.alias.color.neutral.brandBackgroundStatic,
|
|
91
|
-
borderStyle: 'solid',
|
|
92
|
-
},
|
|
93
|
-
}); },
|
|
94
|
-
ringThick: function (theme) { return ({
|
|
95
|
-
':before': {
|
|
96
|
-
margin: "calc(-2 * " + theme.global.strokeWidth.thick + ")",
|
|
97
|
-
borderWidth: theme.global.strokeWidth.thick,
|
|
98
|
-
},
|
|
99
|
-
}); },
|
|
100
|
-
ringThicker: function (theme) { return ({
|
|
101
|
-
':before': {
|
|
102
|
-
margin: "calc(-2 * " + theme.global.strokeWidth.thicker + ")",
|
|
103
|
-
borderWidth: theme.global.strokeWidth.thicker,
|
|
104
|
-
},
|
|
105
|
-
}); },
|
|
106
|
-
ringThickest: function (theme) { return ({
|
|
107
|
-
':before': {
|
|
108
|
-
margin: "calc(-2 * " + theme.global.strokeWidth.thickest + ")",
|
|
109
|
-
borderWidth: theme.global.strokeWidth.thickest,
|
|
110
|
-
},
|
|
111
|
-
}); },
|
|
112
|
-
shadow4: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow4 } }); },
|
|
113
|
-
shadow8: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow8 } }); },
|
|
114
|
-
shadow16: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow16 } }); },
|
|
115
|
-
shadow28: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow28 } }); },
|
|
116
|
-
// TODO: use proper tokens instead of "rgba(0,120,212,0.3)"
|
|
117
|
-
glow4: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow4 + ", 0 0 4px 2px rgba(0,120,212,0.3)" } }); },
|
|
118
|
-
glow8: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow8 + ", 0 0 8px 2px rgba(0,120,212,0.3)" } }); },
|
|
119
|
-
glow16: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow16 + ", 0 0 8px 2px rgba(0,120,212,0.3)" } }); },
|
|
120
|
-
glow28: function (theme) { return ({ ':before': { boxShadow: theme.alias.shadow.shadow28 + ", 0 0 28px 4px rgba(0,120,212,0.3)" } }); },
|
|
121
|
-
inactive: {
|
|
122
|
-
opacity: '0.8',
|
|
123
|
-
transform: 'scale(0.875)',
|
|
124
|
-
transition: "transform " + animationTiming.ultraSlow + " " + animations.fastOutSlowInMin + ", " +
|
|
125
|
-
("opacity " + animationTiming.faster + " " + animations.nullEasing),
|
|
126
|
-
':before': {
|
|
127
|
-
margin: 0,
|
|
128
|
-
opacity: 0,
|
|
129
|
-
transition: "margin " + animationTiming.ultraSlow + " " + animations.fastOutSlowInMin + ", " +
|
|
130
|
-
("opacity " + animationTiming.slower + " " + animations.nullEasing),
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
badge: function (theme) { return ({
|
|
134
|
-
position: 'absolute',
|
|
135
|
-
bottom: 0,
|
|
136
|
-
right: 0,
|
|
137
|
-
boxShadow: "0 0 0 " + theme.global.strokeWidth.thin + " " + theme.alias.color.neutral.neutralBackground1,
|
|
138
|
-
}); },
|
|
139
|
-
badgeLarge: function (theme) { return ({
|
|
140
|
-
boxShadow: "0 0 0 " + theme.global.strokeWidth.thick + " " + theme.alias.color.neutral.neutralBackground1,
|
|
141
|
-
}); },
|
|
142
|
-
image: {
|
|
143
|
-
position: 'absolute',
|
|
144
|
-
top: 0,
|
|
145
|
-
left: 0,
|
|
146
|
-
width: '100%',
|
|
147
|
-
height: '100%',
|
|
148
|
-
borderRadius: 'inherit',
|
|
149
|
-
objectFit: 'cover',
|
|
150
|
-
verticalAlign: 'top',
|
|
151
|
-
},
|
|
152
|
-
iconLabel: {
|
|
153
|
-
position: 'absolute',
|
|
154
|
-
top: 0,
|
|
155
|
-
left: 0,
|
|
156
|
-
width: '100%',
|
|
157
|
-
height: '100%',
|
|
158
|
-
lineHeight: 1,
|
|
159
|
-
display: 'flex',
|
|
160
|
-
alignItems: 'center',
|
|
161
|
-
justifyContent: 'center',
|
|
162
|
-
verticalAlign: 'center',
|
|
163
|
-
textAlign: 'center',
|
|
164
|
-
borderRadius: 'inherit',
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
var useSizeStyles = react_make_styles_1.makeStyles({
|
|
168
|
-
20: { width: '20px', height: '20px' },
|
|
169
|
-
24: { width: '24px', height: '24px' },
|
|
170
|
-
28: { width: '28px', height: '28px' },
|
|
171
|
-
32: { width: '32px', height: '32px' },
|
|
172
|
-
36: { width: '36px', height: '36px' },
|
|
173
|
-
40: { width: '40px', height: '40px' },
|
|
174
|
-
48: { width: '48px', height: '48px' },
|
|
175
|
-
56: { width: '56px', height: '56px' },
|
|
176
|
-
64: { width: '64px', height: '64px' },
|
|
177
|
-
72: { width: '72px', height: '72px' },
|
|
178
|
-
96: { width: '96px', height: '96px' },
|
|
179
|
-
120: { width: '120px', height: '120px' },
|
|
180
|
-
128: { width: '128px', height: '128px' },
|
|
181
|
-
});
|
|
182
|
-
var useColorStyles = react_make_styles_1.makeStyles({
|
|
183
|
-
neutral: function (theme) { return ({
|
|
184
|
-
color: theme.alias.color.neutral.neutralForeground3,
|
|
185
|
-
background: theme.alias.color.neutral.neutralBackground6,
|
|
186
|
-
}); },
|
|
187
|
-
brand: function (theme) { return ({
|
|
188
|
-
color: theme.alias.color.neutral.neutralForegroundInverted,
|
|
189
|
-
background: theme.alias.color.neutral.brandBackgroundStatic,
|
|
190
|
-
}); },
|
|
191
|
-
darkRed: function (theme) { return ({
|
|
192
|
-
color: theme.alias.color.darkRed.foreground2,
|
|
193
|
-
background: theme.alias.color.darkRed.background2,
|
|
194
|
-
}); },
|
|
195
|
-
cranberry: function (theme) { return ({
|
|
196
|
-
color: theme.alias.color.cranberry.foreground2,
|
|
197
|
-
background: theme.alias.color.cranberry.background2,
|
|
198
|
-
}); },
|
|
199
|
-
red: function (theme) { return ({
|
|
200
|
-
color: theme.alias.color.red.foreground2,
|
|
201
|
-
background: theme.alias.color.red.background2,
|
|
202
|
-
}); },
|
|
203
|
-
pumpkin: function (theme) { return ({
|
|
204
|
-
color: theme.alias.color.pumpkin.foreground2,
|
|
205
|
-
background: theme.alias.color.pumpkin.background2,
|
|
206
|
-
}); },
|
|
207
|
-
peach: function (theme) { return ({
|
|
208
|
-
color: theme.alias.color.peach.foreground2,
|
|
209
|
-
background: theme.alias.color.peach.background2,
|
|
210
|
-
}); },
|
|
211
|
-
marigold: function (theme) { return ({
|
|
212
|
-
color: theme.alias.color.marigold.foreground2,
|
|
213
|
-
background: theme.alias.color.marigold.background2,
|
|
214
|
-
}); },
|
|
215
|
-
gold: function (theme) { return ({
|
|
216
|
-
color: theme.alias.color.gold.foreground2,
|
|
217
|
-
background: theme.alias.color.gold.background2,
|
|
218
|
-
}); },
|
|
219
|
-
brass: function (theme) { return ({
|
|
220
|
-
color: theme.alias.color.brass.foreground2,
|
|
221
|
-
background: theme.alias.color.brass.background2,
|
|
222
|
-
}); },
|
|
223
|
-
brown: function (theme) { return ({
|
|
224
|
-
color: theme.alias.color.brown.foreground2,
|
|
225
|
-
background: theme.alias.color.brown.background2,
|
|
226
|
-
}); },
|
|
227
|
-
forest: function (theme) { return ({
|
|
228
|
-
color: theme.alias.color.forest.foreground2,
|
|
229
|
-
background: theme.alias.color.forest.background2,
|
|
230
|
-
}); },
|
|
231
|
-
seafoam: function (theme) { return ({
|
|
232
|
-
color: theme.alias.color.seafoam.foreground2,
|
|
233
|
-
background: theme.alias.color.seafoam.background2,
|
|
234
|
-
}); },
|
|
235
|
-
darkGreen: function (theme) { return ({
|
|
236
|
-
color: theme.alias.color.darkGreen.foreground2,
|
|
237
|
-
background: theme.alias.color.darkGreen.background2,
|
|
238
|
-
}); },
|
|
239
|
-
lightTeal: function (theme) { return ({
|
|
240
|
-
color: theme.alias.color.lightTeal.foreground2,
|
|
241
|
-
background: theme.alias.color.lightTeal.background2,
|
|
242
|
-
}); },
|
|
243
|
-
teal: function (theme) { return ({
|
|
244
|
-
color: theme.alias.color.teal.foreground2,
|
|
245
|
-
background: theme.alias.color.teal.background2,
|
|
246
|
-
}); },
|
|
247
|
-
steel: function (theme) { return ({
|
|
248
|
-
color: theme.alias.color.steel.foreground2,
|
|
249
|
-
background: theme.alias.color.steel.background2,
|
|
250
|
-
}); },
|
|
251
|
-
blue: function (theme) { return ({
|
|
252
|
-
color: theme.alias.color.blue.foreground2,
|
|
253
|
-
background: theme.alias.color.blue.background2,
|
|
254
|
-
}); },
|
|
255
|
-
royalBlue: function (theme) { return ({
|
|
256
|
-
color: theme.alias.color.royalBlue.foreground2,
|
|
257
|
-
background: theme.alias.color.royalBlue.background2,
|
|
258
|
-
}); },
|
|
259
|
-
cornflower: function (theme) { return ({
|
|
260
|
-
color: theme.alias.color.cornflower.foreground2,
|
|
261
|
-
background: theme.alias.color.cornflower.background2,
|
|
262
|
-
}); },
|
|
263
|
-
navy: function (theme) { return ({
|
|
264
|
-
color: theme.alias.color.navy.foreground2,
|
|
265
|
-
background: theme.alias.color.navy.background2,
|
|
266
|
-
}); },
|
|
267
|
-
lavender: function (theme) { return ({
|
|
268
|
-
color: theme.alias.color.lavender.foreground2,
|
|
269
|
-
background: theme.alias.color.lavender.background2,
|
|
270
|
-
}); },
|
|
271
|
-
purple: function (theme) { return ({
|
|
272
|
-
color: theme.alias.color.purple.foreground2,
|
|
273
|
-
background: theme.alias.color.purple.background2,
|
|
274
|
-
}); },
|
|
275
|
-
grape: function (theme) { return ({
|
|
276
|
-
color: theme.alias.color.grape.foreground2,
|
|
277
|
-
background: theme.alias.color.grape.background2,
|
|
278
|
-
}); },
|
|
279
|
-
lilac: function (theme) { return ({
|
|
280
|
-
color: theme.alias.color.lilac.foreground2,
|
|
281
|
-
background: theme.alias.color.lilac.background2,
|
|
282
|
-
}); },
|
|
283
|
-
pink: function (theme) { return ({
|
|
284
|
-
color: theme.alias.color.pink.foreground2,
|
|
285
|
-
background: theme.alias.color.pink.background2,
|
|
286
|
-
}); },
|
|
287
|
-
magenta: function (theme) { return ({
|
|
288
|
-
color: theme.alias.color.magenta.foreground2,
|
|
289
|
-
background: theme.alias.color.magenta.background2,
|
|
290
|
-
}); },
|
|
291
|
-
plum: function (theme) { return ({
|
|
292
|
-
color: theme.alias.color.plum.foreground2,
|
|
293
|
-
background: theme.alias.color.plum.background2,
|
|
294
|
-
}); },
|
|
295
|
-
beige: function (theme) { return ({
|
|
296
|
-
color: theme.alias.color.beige.foreground2,
|
|
297
|
-
background: theme.alias.color.beige.background2,
|
|
298
|
-
}); },
|
|
299
|
-
mink: function (theme) { return ({
|
|
300
|
-
color: theme.alias.color.mink.foreground2,
|
|
301
|
-
background: theme.alias.color.mink.background2,
|
|
302
|
-
}); },
|
|
303
|
-
platinum: function (theme) { return ({
|
|
304
|
-
color: theme.alias.color.platinum.foreground2,
|
|
305
|
-
background: theme.alias.color.platinum.background2,
|
|
306
|
-
}); },
|
|
307
|
-
anchor: function (theme) { return ({
|
|
308
|
-
color: theme.alias.color.anchor.foreground2,
|
|
309
|
-
background: theme.alias.color.anchor.background2,
|
|
310
|
-
}); },
|
|
311
|
-
});
|
|
312
|
-
var useAvatarStyles = function (state) {
|
|
313
|
-
var size = state.size, square = state.square, active = state.active, activeDisplay = state.activeDisplay;
|
|
314
|
-
// 'colorful' should have been replaced with a color name by useAvatar, but if not default to darkRed
|
|
315
|
-
var color = state.color === 'colorful' ? 'darkRed' : state.color;
|
|
316
|
-
var styles = useStyles();
|
|
317
|
-
var sizeStyles = useSizeStyles();
|
|
318
|
-
var colorStyles = useColorStyles();
|
|
319
|
-
var rootClasses = [styles.root, sizeStyles[size], colorStyles[color]];
|
|
320
|
-
if (size <= 24) {
|
|
321
|
-
rootClasses.push(styles.textCaption2);
|
|
322
|
-
}
|
|
323
|
-
else if (size <= 28) {
|
|
324
|
-
rootClasses.push(styles.textCaption1Strong);
|
|
325
|
-
}
|
|
326
|
-
else if (size <= 40) {
|
|
327
|
-
rootClasses.push(styles.textBody1Strong);
|
|
328
|
-
}
|
|
329
|
-
else if (size <= 56) {
|
|
330
|
-
rootClasses.push(styles.textSubtitle2);
|
|
331
|
-
}
|
|
332
|
-
else if (size <= 96) {
|
|
333
|
-
rootClasses.push(styles.textSubtitle1);
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
rootClasses.push(styles.textTitle);
|
|
337
|
-
}
|
|
338
|
-
if (square) {
|
|
339
|
-
if (size <= 24) {
|
|
340
|
-
rootClasses.push(styles.squareSmall);
|
|
341
|
-
}
|
|
342
|
-
else if (size <= 48) {
|
|
343
|
-
rootClasses.push(styles.squareMedium);
|
|
344
|
-
}
|
|
345
|
-
else if (size <= 72) {
|
|
346
|
-
rootClasses.push(styles.squareLarge);
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
rootClasses.push(styles.squareXLarge);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (active === 'active' || active === 'inactive') {
|
|
353
|
-
rootClasses.push(styles.activeOrInactive);
|
|
354
|
-
if (activeDisplay.includes('ring')) {
|
|
355
|
-
rootClasses.push(styles.ring);
|
|
356
|
-
if (size <= 48) {
|
|
357
|
-
rootClasses.push(styles.ringThick);
|
|
358
|
-
}
|
|
359
|
-
else if (size <= 64) {
|
|
360
|
-
rootClasses.push(styles.ringThicker);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
rootClasses.push(styles.ringThickest);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
if (activeDisplay.includes('shadow')) {
|
|
367
|
-
if (size <= 28) {
|
|
368
|
-
rootClasses.push(styles.shadow4);
|
|
369
|
-
}
|
|
370
|
-
else if (size <= 48) {
|
|
371
|
-
rootClasses.push(styles.shadow8);
|
|
372
|
-
}
|
|
373
|
-
else if (size <= 64) {
|
|
374
|
-
rootClasses.push(styles.shadow16);
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
rootClasses.push(styles.shadow28);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (activeDisplay.includes('glow')) {
|
|
381
|
-
if (size <= 28) {
|
|
382
|
-
rootClasses.push(styles.glow4);
|
|
383
|
-
}
|
|
384
|
-
else if (size <= 48) {
|
|
385
|
-
rootClasses.push(styles.glow8);
|
|
386
|
-
}
|
|
387
|
-
else if (size <= 64) {
|
|
388
|
-
rootClasses.push(styles.glow16);
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
rootClasses.push(styles.glow28);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
// Note: The inactive style overrides some of the activeDisplay styles and must be applied after them
|
|
395
|
-
if (active === 'inactive') {
|
|
396
|
-
rootClasses.push(styles.inactive);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
state.className = react_make_styles_1.mergeClasses.apply(void 0, tslib_1.__spreadArrays(rootClasses, [state.className]));
|
|
400
|
-
if (state.badge) {
|
|
401
|
-
state.badge.className = react_make_styles_1.mergeClasses(styles.badge, size >= 64 && styles.badgeLarge, state.badge.className);
|
|
402
|
-
}
|
|
403
|
-
if (state.image) {
|
|
404
|
-
state.image.className = react_make_styles_1.mergeClasses(styles.image, state.image.className);
|
|
405
|
-
}
|
|
406
|
-
if (state.label) {
|
|
407
|
-
state.label.className = react_make_styles_1.mergeClasses(styles.iconLabel, state.label.className);
|
|
408
|
-
}
|
|
409
|
-
if (state.icon) {
|
|
410
|
-
state.icon.className = react_make_styles_1.mergeClasses(styles.iconLabel, state.icon.className);
|
|
411
|
-
}
|
|
412
|
-
return state;
|
|
413
|
-
};
|
|
414
|
-
exports.useAvatarStyles = useAvatarStyles;
|
|
415
|
-
});
|
|
416
|
-
//# sourceMappingURL=useAvatarStyles.js.map
|