@sproutsocial/racine 23.2.0 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/__flow__/Avatar/Avatar.flow.js +0 -2
- package/commonjs/Avatar/Avatar.js +11 -17
- package/commonjs/Badge/Badge.js +5 -3
- package/commonjs/Message/styles.js +1 -3
- package/dist/types/Avatar/Avatar.d.ts +2 -2
- package/dist/types/Avatar/Avatar.d.ts.map +1 -1
- package/dist/types/Avatar/AvatarTypes.d.ts +5 -10
- package/dist/types/Avatar/AvatarTypes.d.ts.map +1 -1
- package/dist/types/Message/styles.d.ts.map +1 -1
- package/lib/Avatar/Avatar.js +11 -17
- package/lib/Badge/Badge.js +5 -3
- package/lib/Message/styles.js +1 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 24.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- e8cb094: Remove negative margin in Message.Footer to allow web-app-core to control this style.
|
|
8
|
+
- 7e82fee: Removes deprecated `variant` prop from Avatar
|
|
9
|
+
- The `variant` prop has been deprecated for over a year, and is no longer necessary due to built-in theme support in the Avatar component.
|
|
10
|
+
- This change removes all references to the `variant` prop from the Avatar component and its documentation.
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 7e82fee: Adds `initials` prop to Avatar
|
|
15
|
+
- The new prop allows consumers to manually define the initials displayed on the Avatar component when an image is not provided or fails to load.
|
|
16
|
+
- The existing automatic initials generation (which uses the first character of the first 1-2 words of the `name` prop) will still be used if an `initials` prop is not provided.
|
|
17
|
+
- Also adds test cases for the new prop to ensure it functions as expected.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 7e82fee: Removes background color while Avatar image is loading
|
|
22
|
+
- Before this change, an Avatar's background color would briefly appear while an Image-based Avatar was loading.
|
|
23
|
+
- After this change, an Avatar will not have its background color set until the image has failed to load, or if no `src` prop is provided.
|
|
24
|
+
|
|
25
|
+
## 23.2.1
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- dc8e3f6: Fix Badge component so that it now allows overriding the data-qa props
|
|
30
|
+
|
|
3
31
|
## 23.2.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -8,8 +8,6 @@ export type TypeAvatarProps = {
|
|
|
8
8
|
/** URL of the avatar image. If a URL is not provided, the component will fall back to showing the user's initials */
|
|
9
9
|
src?: string,
|
|
10
10
|
type?: "neutral" | "purple" | "green" | "blue" | "yellow" | "red" | "orange",
|
|
11
|
-
/** @deprecated Avatar now uses the theme by default and using `variant` is no longer needed */
|
|
12
|
-
variant?: "dark" | "light",
|
|
13
11
|
bg?: string,
|
|
14
12
|
color?: string,
|
|
15
13
|
size?: string,
|
|
@@ -8,13 +8,12 @@ exports.getAvatarColor = exports.default = exports.Avatar = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var React = _react;
|
|
10
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
11
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
13
12
|
var _Image = _interopRequireDefault(require("../Image"));
|
|
14
13
|
var _Text = _interopRequireDefault(require("../Text"));
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
15
|
var _excluded = ["fontSize"],
|
|
17
|
-
_excluded2 = ["appearance", "name", "src", "
|
|
16
|
+
_excluded2 = ["appearance", "name", "src", "type", "size", "bg", "color", "initials"];
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -54,12 +53,11 @@ var Container = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
|
54
53
|
componentId: "sc-1ffu253-1"
|
|
55
54
|
})(["", ""], function (_ref3) {
|
|
56
55
|
var theme = _ref3.theme,
|
|
57
|
-
type = _ref3
|
|
56
|
+
$type = _ref3.$type,
|
|
58
57
|
bg = _ref3.bg,
|
|
59
|
-
$src = _ref3.$src,
|
|
60
58
|
borderColor = _ref3.borderColor,
|
|
61
|
-
|
|
62
|
-
return (0, _styledComponents.css)(["background:", ";border:", ";border-color:", ";color:", ";"], bg ? bg : theme.colors.container.background.decorative[type], $
|
|
59
|
+
$displayFallback = _ref3.$displayFallback;
|
|
60
|
+
return (0, _styledComponents.css)(["background:", ";border:", ";border-color:", ";color:", ";"], $displayFallback ? bg ? bg : theme.colors.container.background.decorative[$type] : "none", $displayFallback ? "1px solid" : "none", borderColor ? borderColor : theme.colors.container.border.decorative[$type], theme.colors.text.decorative[$type]);
|
|
63
61
|
});
|
|
64
62
|
var getInitials = function getInitials(name) {
|
|
65
63
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "?";
|
|
@@ -92,23 +90,22 @@ var Avatar = exports.Avatar = function Avatar(_ref4) {
|
|
|
92
90
|
_ref4$name = _ref4.name,
|
|
93
91
|
name = _ref4$name === void 0 ? "" : _ref4$name,
|
|
94
92
|
src = _ref4.src,
|
|
95
|
-
_ref4$variant = _ref4.variant,
|
|
96
|
-
variant = _ref4$variant === void 0 ? "light" : _ref4$variant,
|
|
97
93
|
_ref4$type = _ref4.type,
|
|
98
94
|
type = _ref4$type === void 0 ? defaultType : _ref4$type,
|
|
99
95
|
_ref4$size = _ref4.size,
|
|
100
96
|
size = _ref4$size === void 0 ? "40px" : _ref4$size,
|
|
101
97
|
bg = _ref4.bg,
|
|
102
98
|
color = _ref4.color,
|
|
99
|
+
initials = _ref4.initials,
|
|
103
100
|
rest = _objectWithoutProperties(_ref4, _excluded2);
|
|
104
101
|
var colorType = getAvatarColor(name, type);
|
|
105
102
|
var _useState = (0, _react.useState)(false),
|
|
106
103
|
_useState2 = _slicedToArray(_useState, 2),
|
|
107
104
|
imageFailedLoading = _useState2[0],
|
|
108
105
|
setImageFailedLoading = _useState2[1];
|
|
109
|
-
var
|
|
110
|
-
return getInitials(name);
|
|
111
|
-
}, [name]);
|
|
106
|
+
var displayInitials = (0, _react.useMemo)(function () {
|
|
107
|
+
return initials || getInitials(name);
|
|
108
|
+
}, [initials, name]);
|
|
112
109
|
var handleError = (0, _react.useCallback)(function () {
|
|
113
110
|
setImageFailedLoading(true);
|
|
114
111
|
}, [setImageFailedLoading]);
|
|
@@ -116,7 +113,6 @@ var Avatar = exports.Avatar = function Avatar(_ref4) {
|
|
|
116
113
|
// Font size for initials is half the size of the avatar, rounded down.
|
|
117
114
|
var fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
|
|
118
115
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Container, _objectSpread(_objectSpread({
|
|
119
|
-
className: (0, _classnames.default)(variant),
|
|
120
116
|
size: size,
|
|
121
117
|
overflow: "hidden",
|
|
122
118
|
borderRadius: appearance === "leaf" ? "40% 0 40% 0" : "50%",
|
|
@@ -127,11 +123,9 @@ var Avatar = exports.Avatar = function Avatar(_ref4) {
|
|
|
127
123
|
alignItems: "center",
|
|
128
124
|
title: name,
|
|
129
125
|
bg: bg,
|
|
130
|
-
|
|
131
|
-
type: colorType,
|
|
126
|
+
$type: colorType,
|
|
132
127
|
"data-qa-user-avatar": name,
|
|
133
|
-
$
|
|
134
|
-
imageFailedLoading: imageFailedLoading
|
|
128
|
+
$displayFallback: !src || imageFailedLoading
|
|
135
129
|
}, rest), {}, {
|
|
136
130
|
children: !src || imageFailedLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AvatarText, {
|
|
137
131
|
lineHeight: size,
|
|
@@ -139,7 +133,7 @@ var Avatar = exports.Avatar = function Avatar(_ref4) {
|
|
|
139
133
|
fontSize: fontSize,
|
|
140
134
|
type: colorType,
|
|
141
135
|
color: color,
|
|
142
|
-
children:
|
|
136
|
+
children: displayInitials
|
|
143
137
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
|
|
144
138
|
alt: name,
|
|
145
139
|
width: "auto",
|
package/commonjs/Badge/Badge.js
CHANGED
|
@@ -36,8 +36,9 @@ var Badge = function Badge(_ref) {
|
|
|
36
36
|
if (children && text) {
|
|
37
37
|
throw new Error("can't use both `children` and `text` props. Text is deprecated, consider using children.");
|
|
38
38
|
}
|
|
39
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.default
|
|
40
|
-
|
|
39
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.default
|
|
40
|
+
// size previously included default, which currently maps to small. Once consumers have updated this can be simplified.
|
|
41
|
+
, _objectSpread(_objectSpread({
|
|
41
42
|
size: size === "default" ? "large" : size,
|
|
42
43
|
badgeColor: badgeColor,
|
|
43
44
|
"data-tip": tip,
|
|
@@ -49,7 +50,8 @@ var Badge = function Badge(_ref) {
|
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
51
|
// @ts-ignore
|
|
51
52
|
,
|
|
52
|
-
color: color
|
|
53
|
+
color: color
|
|
54
|
+
}, rest), {}, {
|
|
53
55
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
54
56
|
display: "flex",
|
|
55
57
|
alignItems: "center",
|
|
@@ -87,7 +87,7 @@ var MessageBody = exports.MessageBody = (0, _styledComponents.default)(_Box.defa
|
|
|
87
87
|
var MessageFooter = exports.MessageFooter = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
88
88
|
displayName: "styles__MessageFooter",
|
|
89
89
|
componentId: "sc-161ezbx-3"
|
|
90
|
-
})(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", "
|
|
90
|
+
})(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";"], function (props) {
|
|
91
91
|
return props.density === _constants.MESSAGE_DENSITIES.CONDENSED ? 0 : props.theme.space[300];
|
|
92
92
|
}, function (props) {
|
|
93
93
|
return getContentPadding(props);
|
|
@@ -99,8 +99,6 @@ var MessageFooter = exports.MessageFooter = (0, _styledComponents.default)(_Box.
|
|
|
99
99
|
return props.theme.radii.outer;
|
|
100
100
|
}, function (props) {
|
|
101
101
|
return props.density === _constants.MESSAGE_DENSITIES.CONDENSED ? "nowrap" : "wrap";
|
|
102
|
-
}, function (props) {
|
|
103
|
-
return props.theme.space[350];
|
|
104
102
|
});
|
|
105
103
|
var MessageMeta = exports.MessageMeta = (0, _styledComponents.default)(_Box.default).withConfig({
|
|
106
104
|
displayName: "styles__MessageMeta",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { TypeAvatarProps, TypeAvatarType } from "./AvatarTypes";
|
|
3
3
|
export declare const getAvatarColor: (name: string, type: TypeAvatarType) => TypeAvatarType;
|
|
4
|
-
export declare const Avatar: ({ appearance, name, src,
|
|
5
|
-
declare const _default: React.MemoExoticComponent<({ appearance, name, src,
|
|
4
|
+
export declare const Avatar: ({ appearance, name, src, type, size, bg, color, initials, ...rest }: TypeAvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const _default: React.MemoExoticComponent<({ appearance, name, src, type, size, bg, color, initials, ...rest }: TypeAvatarProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
6
|
export default _default;
|
|
7
7
|
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EACV,eAAe,EAEf,cAAc,EACf,MAAM,eAAe,CAAC;AAoCvB,eAAO,MAAM,cAAc,SACnB,MAAM,QACN,cAAc,KACnB,cAuBF,CAAC;AAEF,eAAO,MAAM,MAAM,wEAUhB,eAAe,4CAqDjB,CAAC;wHArDC,eAAe;AAsDlB,wBAA4B"}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import { TypeContainerProps as TypeBoxContainerProps } from "../Box";
|
|
2
2
|
import { AvatarColorOptions } from "./constants";
|
|
3
3
|
export type TypeAvatarType = keyof typeof AvatarColorOptions;
|
|
4
|
-
export type TypeAvatarVariant = "dark" | "light";
|
|
5
4
|
export interface TypeAvatarProps extends TypeBoxContainerProps {
|
|
6
5
|
/** Circles are used for social profile avatars, leaf is for internal Sprout user avatars */
|
|
7
6
|
appearance?: "circle" | "leaf";
|
|
8
7
|
/** The name of the user that the avatar represents */
|
|
9
8
|
name?: string;
|
|
9
|
+
/** The initials of the user that the avatar represents.
|
|
10
|
+
* If not provided, the first letter of the first 1-2 words of the `name` prop will be used. */
|
|
11
|
+
initials?: string;
|
|
10
12
|
/** URL of the avatar image. If a URL is not provided, the component will fall back to showing the user's initials */
|
|
11
13
|
src?: string;
|
|
12
14
|
type?: TypeAvatarType;
|
|
13
|
-
/** @deprecated Avatar now uses the theme by default and using `variant` is no longer needed */
|
|
14
|
-
variant?: TypeAvatarVariant;
|
|
15
|
-
bg?: string;
|
|
16
|
-
color?: string;
|
|
17
15
|
size?: string;
|
|
18
16
|
}
|
|
19
17
|
export interface TypeAvatarContainerProps extends TypeBoxContainerProps {
|
|
20
|
-
type: TypeAvatarType;
|
|
21
|
-
|
|
22
|
-
bg?: string;
|
|
23
|
-
$src?: TypeAvatarProps["src"];
|
|
24
|
-
imageFailedLoading?: boolean;
|
|
18
|
+
$type: TypeAvatarType;
|
|
19
|
+
$displayFallback: boolean;
|
|
25
20
|
}
|
|
26
21
|
//# sourceMappingURL=AvatarTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarTypes.d.ts","sourceRoot":"","sources":["../../../src/Avatar/AvatarTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AvatarTypes.d.ts","sourceRoot":"","sources":["../../../src/Avatar/AvatarTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAG7D,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,4FAA4F;IAC5F,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE/B,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;oGACgG;IAChG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qHAAqH;IACrH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAyB,SAAQ,qBAAqB;IACrE,KAAK,EAAE,cAAc,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Message/styles.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,QAAA,MAAM,SAAS;QACT,MAAM;SASX,CAAC;AAIF,eAAO,MAAM,aAAa,8RAgBxB,CAAC;AAiDH,eAAO,MAAM,WAAW,yPASvB,CAAC;AAEF,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Message/styles.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,QAAA,MAAM,SAAS;QACT,MAAM;SASX,CAAC;AAIF,eAAO,MAAM,aAAa,8RAgBxB,CAAC;AAiDH,eAAO,MAAM,WAAW,yPASvB,CAAC;AAEF,eAAO,MAAM,aAAa,yPAazB,CAAC;AAEF,eAAO,MAAM,WAAW,yPAsBvB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/lib/Avatar/Avatar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
var _excluded = ["fontSize"],
|
|
3
|
-
_excluded2 = ["appearance", "name", "src", "
|
|
3
|
+
_excluded2 = ["appearance", "name", "src", "type", "size", "bg", "color", "initials"];
|
|
4
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
5
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
6
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -17,7 +17,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
17
17
|
import * as React from "react";
|
|
18
18
|
import { useState, useCallback, useMemo, memo } from "react";
|
|
19
19
|
import styled, { css } from "styled-components";
|
|
20
|
-
import classnames from "classnames";
|
|
21
20
|
import Box from "../Box";
|
|
22
21
|
import Image from "../Image";
|
|
23
22
|
import Text from "../Text";
|
|
@@ -45,12 +44,11 @@ var Container = styled(Box).withConfig({
|
|
|
45
44
|
componentId: "sc-1ffu253-1"
|
|
46
45
|
})(["", ""], function (_ref3) {
|
|
47
46
|
var theme = _ref3.theme,
|
|
48
|
-
type = _ref3
|
|
47
|
+
$type = _ref3.$type,
|
|
49
48
|
bg = _ref3.bg,
|
|
50
|
-
$src = _ref3.$src,
|
|
51
49
|
borderColor = _ref3.borderColor,
|
|
52
|
-
|
|
53
|
-
return css(["background:", ";border:", ";border-color:", ";color:", ";"], bg ? bg : theme.colors.container.background.decorative[type], $
|
|
50
|
+
$displayFallback = _ref3.$displayFallback;
|
|
51
|
+
return css(["background:", ";border:", ";border-color:", ";color:", ";"], $displayFallback ? bg ? bg : theme.colors.container.background.decorative[$type] : "none", $displayFallback ? "1px solid" : "none", borderColor ? borderColor : theme.colors.container.border.decorative[$type], theme.colors.text.decorative[$type]);
|
|
54
52
|
});
|
|
55
53
|
var getInitials = function getInitials(name) {
|
|
56
54
|
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "?";
|
|
@@ -83,23 +81,22 @@ export var Avatar = function Avatar(_ref4) {
|
|
|
83
81
|
_ref4$name = _ref4.name,
|
|
84
82
|
name = _ref4$name === void 0 ? "" : _ref4$name,
|
|
85
83
|
src = _ref4.src,
|
|
86
|
-
_ref4$variant = _ref4.variant,
|
|
87
|
-
variant = _ref4$variant === void 0 ? "light" : _ref4$variant,
|
|
88
84
|
_ref4$type = _ref4.type,
|
|
89
85
|
type = _ref4$type === void 0 ? defaultType : _ref4$type,
|
|
90
86
|
_ref4$size = _ref4.size,
|
|
91
87
|
size = _ref4$size === void 0 ? "40px" : _ref4$size,
|
|
92
88
|
bg = _ref4.bg,
|
|
93
89
|
color = _ref4.color,
|
|
90
|
+
initials = _ref4.initials,
|
|
94
91
|
rest = _objectWithoutProperties(_ref4, _excluded2);
|
|
95
92
|
var colorType = getAvatarColor(name, type);
|
|
96
93
|
var _useState = useState(false),
|
|
97
94
|
_useState2 = _slicedToArray(_useState, 2),
|
|
98
95
|
imageFailedLoading = _useState2[0],
|
|
99
96
|
setImageFailedLoading = _useState2[1];
|
|
100
|
-
var
|
|
101
|
-
return getInitials(name);
|
|
102
|
-
}, [name]);
|
|
97
|
+
var displayInitials = useMemo(function () {
|
|
98
|
+
return initials || getInitials(name);
|
|
99
|
+
}, [initials, name]);
|
|
103
100
|
var handleError = useCallback(function () {
|
|
104
101
|
setImageFailedLoading(true);
|
|
105
102
|
}, [setImageFailedLoading]);
|
|
@@ -107,7 +104,6 @@ export var Avatar = function Avatar(_ref4) {
|
|
|
107
104
|
// Font size for initials is half the size of the avatar, rounded down.
|
|
108
105
|
var fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
|
|
109
106
|
return /*#__PURE__*/_jsx(Container, _objectSpread(_objectSpread({
|
|
110
|
-
className: classnames(variant),
|
|
111
107
|
size: size,
|
|
112
108
|
overflow: "hidden",
|
|
113
109
|
borderRadius: appearance === "leaf" ? "40% 0 40% 0" : "50%",
|
|
@@ -118,11 +114,9 @@ export var Avatar = function Avatar(_ref4) {
|
|
|
118
114
|
alignItems: "center",
|
|
119
115
|
title: name,
|
|
120
116
|
bg: bg,
|
|
121
|
-
|
|
122
|
-
type: colorType,
|
|
117
|
+
$type: colorType,
|
|
123
118
|
"data-qa-user-avatar": name,
|
|
124
|
-
$
|
|
125
|
-
imageFailedLoading: imageFailedLoading
|
|
119
|
+
$displayFallback: !src || imageFailedLoading
|
|
126
120
|
}, rest), {}, {
|
|
127
121
|
children: !src || imageFailedLoading ? /*#__PURE__*/_jsx(AvatarText, {
|
|
128
122
|
lineHeight: size,
|
|
@@ -130,7 +124,7 @@ export var Avatar = function Avatar(_ref4) {
|
|
|
130
124
|
fontSize: fontSize,
|
|
131
125
|
type: colorType,
|
|
132
126
|
color: color,
|
|
133
|
-
children:
|
|
127
|
+
children: displayInitials
|
|
134
128
|
}) : /*#__PURE__*/_jsx(Image, {
|
|
135
129
|
alt: name,
|
|
136
130
|
width: "auto",
|
package/lib/Badge/Badge.js
CHANGED
|
@@ -28,8 +28,9 @@ var Badge = function Badge(_ref) {
|
|
|
28
28
|
if (children && text) {
|
|
29
29
|
throw new Error("can't use both `children` and `text` props. Text is deprecated, consider using children.");
|
|
30
30
|
}
|
|
31
|
-
return /*#__PURE__*/_jsx(Container
|
|
32
|
-
|
|
31
|
+
return /*#__PURE__*/_jsx(Container
|
|
32
|
+
// size previously included default, which currently maps to small. Once consumers have updated this can be simplified.
|
|
33
|
+
, _objectSpread(_objectSpread({
|
|
33
34
|
size: size === "default" ? "large" : size,
|
|
34
35
|
badgeColor: badgeColor,
|
|
35
36
|
"data-tip": tip,
|
|
@@ -41,7 +42,8 @@ var Badge = function Badge(_ref) {
|
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
43
|
// @ts-ignore
|
|
43
44
|
,
|
|
44
|
-
color: color
|
|
45
|
+
color: color
|
|
46
|
+
}, rest), {}, {
|
|
45
47
|
children: /*#__PURE__*/_jsxs(Box, {
|
|
46
48
|
display: "flex",
|
|
47
49
|
alignItems: "center",
|
package/lib/Message/styles.js
CHANGED
|
@@ -80,7 +80,7 @@ export var MessageBody = styled(Box).withConfig({
|
|
|
80
80
|
export var MessageFooter = styled(Box).withConfig({
|
|
81
81
|
displayName: "styles__MessageFooter",
|
|
82
82
|
componentId: "sc-161ezbx-3"
|
|
83
|
-
})(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", "
|
|
83
|
+
})(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";"], function (props) {
|
|
84
84
|
return props.density === MESSAGE_DENSITIES.CONDENSED ? 0 : props.theme.space[300];
|
|
85
85
|
}, function (props) {
|
|
86
86
|
return getContentPadding(props);
|
|
@@ -92,8 +92,6 @@ export var MessageFooter = styled(Box).withConfig({
|
|
|
92
92
|
return props.theme.radii.outer;
|
|
93
93
|
}, function (props) {
|
|
94
94
|
return props.density === MESSAGE_DENSITIES.CONDENSED ? "nowrap" : "wrap";
|
|
95
|
-
}, function (props) {
|
|
96
|
-
return props.theme.space[350];
|
|
97
95
|
});
|
|
98
96
|
export var MessageMeta = styled(Box).withConfig({
|
|
99
97
|
displayName: "styles__MessageMeta",
|