@zendeskgarden/react-avatars 8.56.0 → 8.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.cjs.js +197 -101
- package/dist/index.esm.js +199 -104
- package/dist/typings/elements/StatusIndicator.d.ts +12 -0
- package/dist/typings/index.d.ts +2 -1
- package/dist/typings/styled/StyledStandaloneStatus.d.ts +11 -0
- package/dist/typings/styled/StyledStandaloneStatusCaption.d.ts +11 -0
- package/dist/typings/styled/StyledStandaloneStatusIndicator.d.ts +14 -0
- package/dist/typings/styled/StyledStatusIndicator.d.ts +5 -1
- package/dist/typings/styled/StyledStatusIndicatorBase.d.ts +11 -0
- package/dist/typings/styled/index.d.ts +3 -0
- package/dist/typings/styled/utility.d.ts +11 -2
- package/dist/typings/types/index.d.ts +6 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install react react-dom styled-components @zendeskgarden/react-theming
|
|
|
16
16
|
|
|
17
17
|
```jsx
|
|
18
18
|
import { ThemeProvider } from '@zendeskgarden/react-theming';
|
|
19
|
-
import { Avatar } from '@zendeskgarden/react-avatars';
|
|
19
|
+
import { Avatar, StatusIndicator } from '@zendeskgarden/react-avatars';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Place a `ThemeProvider` at the root of your React application
|
|
@@ -25,5 +25,9 @@ import { Avatar } from '@zendeskgarden/react-avatars';
|
|
|
25
25
|
<Avatar>
|
|
26
26
|
<img src="images/user.png" alt="Example Avatar" />
|
|
27
27
|
</Avatar>
|
|
28
|
+
|
|
29
|
+
<StatusIndicator type="available" aria-label="status: online">
|
|
30
|
+
Available
|
|
31
|
+
</StatusIndicator>
|
|
28
32
|
</ThemeProvider>;
|
|
29
33
|
```
|
package/dist/index.cjs.js
CHANGED
|
@@ -97,22 +97,10 @@ function _slicedToArray(arr, i) {
|
|
|
97
97
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function _toConsumableArray(arr) {
|
|
101
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _arrayWithoutHoles(arr) {
|
|
105
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
100
|
function _arrayWithHoles(arr) {
|
|
109
101
|
if (Array.isArray(arr)) return arr;
|
|
110
102
|
}
|
|
111
103
|
|
|
112
|
-
function _iterableToArray(iter) {
|
|
113
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
104
|
function _iterableToArrayLimit(arr, i) {
|
|
117
105
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
118
106
|
|
|
@@ -160,10 +148,6 @@ function _arrayLikeToArray(arr, len) {
|
|
|
160
148
|
return arr2;
|
|
161
149
|
}
|
|
162
150
|
|
|
163
|
-
function _nonIterableSpread() {
|
|
164
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
151
|
function _nonIterableRest() {
|
|
168
152
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
169
153
|
}
|
|
@@ -259,125 +243,143 @@ var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
|
259
243
|
var SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
260
244
|
var STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
261
245
|
|
|
262
|
-
var COMPONENT_ID$
|
|
246
|
+
var COMPONENT_ID$6 = 'avatars.text';
|
|
263
247
|
var StyledText = styled__default["default"].span.attrs({
|
|
264
|
-
'data-garden-id': COMPONENT_ID$
|
|
265
|
-
'data-garden-version': '8.
|
|
248
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
249
|
+
'data-garden-version': '8.57.1'
|
|
266
250
|
}).withConfig({
|
|
267
251
|
displayName: "StyledText",
|
|
268
252
|
componentId: "sc-1a6hivh-0"
|
|
269
253
|
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], function (props) {
|
|
270
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
254
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
271
255
|
});
|
|
272
256
|
StyledText.defaultProps = {
|
|
273
257
|
theme: reactTheming.DEFAULT_THEME
|
|
274
258
|
};
|
|
275
259
|
|
|
276
|
-
var
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
switch (
|
|
285
|
-
case active
|
|
260
|
+
var _SIZE$1 = _slicedToArray(SIZE, 5),
|
|
261
|
+
xxs$1 = _SIZE$1[0],
|
|
262
|
+
xs$1 = _SIZE$1[1],
|
|
263
|
+
s$1 = _SIZE$1[2],
|
|
264
|
+
m$1 = _SIZE$1[3],
|
|
265
|
+
l$1 = _SIZE$1[4];
|
|
266
|
+
var TRANSITION_DURATION = 0.25;
|
|
267
|
+
function getStatusColor(type, theme) {
|
|
268
|
+
switch (type) {
|
|
269
|
+
case 'active':
|
|
286
270
|
return reactTheming.getColor('crimson', 400, theme);
|
|
287
|
-
case available
|
|
271
|
+
case 'available':
|
|
288
272
|
return reactTheming.getColor('mint', 400, theme);
|
|
289
|
-
case away
|
|
273
|
+
case 'away':
|
|
290
274
|
return reactTheming.getColor('orange', 400, theme);
|
|
291
|
-
case transfers
|
|
275
|
+
case 'transfers':
|
|
292
276
|
return reactTheming.getColor('azure', 400, theme);
|
|
293
|
-
case offline
|
|
277
|
+
case 'offline':
|
|
294
278
|
return reactTheming.getColor('grey', 500, theme);
|
|
295
279
|
default:
|
|
296
280
|
return 'transparent';
|
|
297
281
|
}
|
|
298
282
|
}
|
|
283
|
+
function getStatusBorderOffset(props) {
|
|
284
|
+
return props.size === xxs$1 ? polished.math("".concat(props.theme.shadowWidths.sm, " - 1")) : props.theme.shadowWidths.sm;
|
|
285
|
+
}
|
|
286
|
+
function getStatusSize(props, offset) {
|
|
287
|
+
var isActive = props.type === 'active';
|
|
288
|
+
switch (props.size) {
|
|
289
|
+
case xxs$1:
|
|
290
|
+
return polished.math("".concat(props.theme.space.base, "px - ").concat(offset));
|
|
291
|
+
case xs$1:
|
|
292
|
+
return polished.math("".concat(props.theme.space.base * 2, "px - (").concat(offset, " * 2)"));
|
|
293
|
+
case s$1:
|
|
294
|
+
return polished.math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
|
|
295
|
+
case m$1:
|
|
296
|
+
case l$1:
|
|
297
|
+
return polished.math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
|
|
298
|
+
default:
|
|
299
|
+
return '0';
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function includes(array, element) {
|
|
303
|
+
return array.includes(element);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
var COMPONENT_ID$5 = 'avatars.status-indicator.base';
|
|
307
|
+
var iconFadeIn = styled.keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
308
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
309
|
+
var offset = getStatusBorderOffset(props);
|
|
310
|
+
var size = getStatusSize(props, offset);
|
|
311
|
+
return styled.css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
|
|
312
|
+
};
|
|
313
|
+
var colorStyles$2 = function colorStyles(props) {
|
|
314
|
+
var backgroundColor = getStatusColor(props.type, props.theme);
|
|
315
|
+
var borderColor = backgroundColor;
|
|
316
|
+
if (props.type === 'offline') {
|
|
317
|
+
borderColor = getStatusColor(props.type, props.theme);
|
|
318
|
+
backgroundColor = props.theme.palette.white;
|
|
319
|
+
}
|
|
320
|
+
return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
321
|
+
};
|
|
322
|
+
var StyledStatusIndicatorBase = styled__default["default"].div.attrs({
|
|
323
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
324
|
+
'data-garden-version': '8.57.1'
|
|
325
|
+
}).withConfig({
|
|
326
|
+
displayName: "StyledStatusIndicatorBase",
|
|
327
|
+
componentId: "sc-1rininy-0"
|
|
328
|
+
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, function (props) {
|
|
329
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
330
|
+
});
|
|
331
|
+
StyledStatusIndicatorBase.defaultProps = {
|
|
332
|
+
theme: reactTheming.DEFAULT_THEME,
|
|
333
|
+
size: 'small'
|
|
334
|
+
};
|
|
299
335
|
|
|
300
|
-
var COMPONENT_ID$
|
|
336
|
+
var COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
301
337
|
var _SIZE = _slicedToArray(SIZE, 5),
|
|
302
338
|
xxs = _SIZE[0],
|
|
303
339
|
xs = _SIZE[1],
|
|
304
340
|
s = _SIZE[2],
|
|
305
341
|
m = _SIZE[3],
|
|
306
342
|
l = _SIZE[4];
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
away = _ref[2],
|
|
311
|
-
transfers = _ref[3],
|
|
312
|
-
offline = _ref[4];
|
|
313
|
-
var sizeStyles$1 = function sizeStyles(props) {
|
|
314
|
-
var isActive = props.status === 'active';
|
|
315
|
-
var isVisible = true;
|
|
316
|
-
var height = '0';
|
|
343
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
344
|
+
var isVisible = !includes([xxs, xs], props.size);
|
|
345
|
+
var borderWidth = getStatusBorderOffset(props);
|
|
317
346
|
var padding = '0';
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
borderWidth = polished.math("".concat(borderWidth, " - 1"));
|
|
323
|
-
height = polished.math("".concat(props.theme.space.base, "px - ").concat(borderWidth));
|
|
324
|
-
break;
|
|
325
|
-
case xs:
|
|
326
|
-
isVisible = false;
|
|
327
|
-
height = polished.math("".concat(props.theme.space.base * 2, "px - (").concat(borderWidth, " * 2)"));
|
|
328
|
-
break;
|
|
329
|
-
case s:
|
|
330
|
-
height = polished.math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
|
|
331
|
-
padding = polished.math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
|
|
332
|
-
break;
|
|
333
|
-
case m:
|
|
334
|
-
case l:
|
|
335
|
-
height = polished.math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
|
|
336
|
-
padding = polished.math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
|
|
337
|
-
break;
|
|
347
|
+
if (props.size === s) {
|
|
348
|
+
padding = polished.math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
|
|
349
|
+
} else if (includes([m, l], props.size)) {
|
|
350
|
+
padding = polished.math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
|
|
338
351
|
}
|
|
339
|
-
return styled.css(["
|
|
352
|
+
return styled.css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
|
|
340
353
|
};
|
|
341
354
|
var colorStyles$1 = function colorStyles(props) {
|
|
342
|
-
var
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
case active:
|
|
353
|
-
case away:
|
|
354
|
-
case transfers:
|
|
355
|
-
backgroundColor = getStatusColor(props.status, props.theme);
|
|
356
|
-
borderColor = backgroundColor;
|
|
357
|
-
break;
|
|
358
|
-
case offline:
|
|
359
|
-
borderColor = getStatusColor(props.status, props.theme);
|
|
360
|
-
backgroundColor = props.theme.palette.white;
|
|
361
|
-
break;
|
|
355
|
+
var theme = props.theme,
|
|
356
|
+
type = props.type,
|
|
357
|
+
size = props.size,
|
|
358
|
+
foregroundColor = props.foregroundColor,
|
|
359
|
+
backgroundColor = props.backgroundColor,
|
|
360
|
+
borderColor = props.borderColor,
|
|
361
|
+
surfaceColor = props.surfaceColor;
|
|
362
|
+
var boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
|
|
363
|
+
if (size === xxs) {
|
|
364
|
+
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
362
365
|
}
|
|
363
366
|
return styled.css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, boxShadow, backgroundColor, foregroundColor);
|
|
364
367
|
};
|
|
365
|
-
var StyledStatusIndicator = styled__default["default"].
|
|
366
|
-
'data-garden-id': COMPONENT_ID$
|
|
367
|
-
'data-garden-version': '8.
|
|
368
|
+
var StyledStatusIndicator = styled__default["default"](StyledStatusIndicatorBase).attrs({
|
|
369
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
370
|
+
'data-garden-version': '8.57.1'
|
|
368
371
|
}).withConfig({
|
|
369
372
|
displayName: "StyledStatusIndicator",
|
|
370
373
|
componentId: "sc-16t9if3-0"
|
|
371
|
-
})(["", " ", "
|
|
372
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
374
|
+
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, function (props) {
|
|
375
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
373
376
|
});
|
|
374
377
|
StyledStatusIndicator.defaultProps = {
|
|
375
378
|
size: 'medium',
|
|
376
379
|
theme: reactTheming.DEFAULT_THEME
|
|
377
380
|
};
|
|
378
381
|
|
|
379
|
-
var COMPONENT_ID = 'avatars.avatar';
|
|
380
|
-
var TRANSITION_DURATION = 0.25;
|
|
382
|
+
var COMPONENT_ID$3 = 'avatars.avatar';
|
|
381
383
|
var badgeStyles = function badgeStyles(props) {
|
|
382
384
|
var _SIZE = _slicedToArray(SIZE, 5),
|
|
383
385
|
xxs = _SIZE[0],
|
|
@@ -407,7 +409,7 @@ var colorStyles = function colorStyles(props) {
|
|
|
407
409
|
var surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
|
|
408
410
|
return styled.css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
409
411
|
};
|
|
410
|
-
var sizeStyles = function sizeStyles(props) {
|
|
412
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
411
413
|
var boxShadow;
|
|
412
414
|
var borderRadius;
|
|
413
415
|
var size;
|
|
@@ -447,23 +449,72 @@ var sizeStyles = function sizeStyles(props) {
|
|
|
447
449
|
return styled.css(["border-radius:", ";width:", " !important;height:", " !important;::before{box-shadow:", ";}& > svg{font-size:", ";}& ", "{line-height:", ";font-size:", ";}"], borderRadius, size, size, boxShadow, svgSize, StyledText, size, fontSize);
|
|
448
450
|
};
|
|
449
451
|
var StyledAvatar = styled__default["default"].figure.attrs({
|
|
450
|
-
'data-garden-id': COMPONENT_ID,
|
|
451
|
-
'data-garden-version': '8.
|
|
452
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
453
|
+
'data-garden-version': '8.57.1'
|
|
452
454
|
}).withConfig({
|
|
453
455
|
displayName: "StyledAvatar",
|
|
454
456
|
componentId: "sc-608m04-0"
|
|
455
457
|
})(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION, function (props) {
|
|
456
|
-
return sizeStyles(props);
|
|
458
|
+
return sizeStyles$1(props);
|
|
457
459
|
}, function (props) {
|
|
458
460
|
return colorStyles(props);
|
|
459
461
|
}, TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, function (props) {
|
|
460
|
-
return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
|
|
462
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
461
463
|
});
|
|
462
464
|
StyledAvatar.defaultProps = {
|
|
463
465
|
size: 'medium',
|
|
464
466
|
theme: reactTheming.DEFAULT_THEME
|
|
465
467
|
};
|
|
466
468
|
|
|
469
|
+
var COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
470
|
+
var StyledStandaloneStatus = styled__default["default"].figure.attrs({
|
|
471
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
472
|
+
'data-garden-version': '8.57.1'
|
|
473
|
+
}).withConfig({
|
|
474
|
+
displayName: "StyledStandaloneStatus",
|
|
475
|
+
componentId: "sc-1ow4nfj-0"
|
|
476
|
+
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, function (props) {
|
|
477
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
478
|
+
});
|
|
479
|
+
StyledStandaloneStatus.defaultProps = {
|
|
480
|
+
theme: reactTheming.DEFAULT_THEME
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
var COMPONENT_ID$1 = 'avatars.status-indicator.caption';
|
|
484
|
+
function sizeStyles(props) {
|
|
485
|
+
var marginRule = "margin-".concat(props.theme.rtl ? 'right' : 'left', ": ").concat(props.theme.space.base * 2, "px;");
|
|
486
|
+
return styled.css(["", " line-height:", ";font-size:", ";"], marginRule, reactTheming.getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
487
|
+
}
|
|
488
|
+
var StyledStandaloneStatusCaption = styled__default["default"].figcaption.attrs({
|
|
489
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
490
|
+
'data-garden-version': '8.57.1'
|
|
491
|
+
}).withConfig({
|
|
492
|
+
displayName: "StyledStandaloneStatusCaption",
|
|
493
|
+
componentId: "sc-aalyk1-0"
|
|
494
|
+
})(["", " ", ";"], sizeStyles, function (props) {
|
|
495
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
496
|
+
});
|
|
497
|
+
StyledStandaloneStatusCaption.defaultProps = {
|
|
498
|
+
theme: reactTheming.DEFAULT_THEME
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
var COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
502
|
+
var StyledStandaloneStatusIndicator = styled__default["default"](StyledStatusIndicatorBase).attrs({
|
|
503
|
+
'data-garden-id': COMPONENT_ID,
|
|
504
|
+
'data-garden-version': '8.57.1'
|
|
505
|
+
}).withConfig({
|
|
506
|
+
displayName: "StyledStandaloneStatusIndicator",
|
|
507
|
+
componentId: "sc-1xt1heq-0"
|
|
508
|
+
})(["position:relative;margin-top:", ";", ";"], function (props) {
|
|
509
|
+
return "calc((".concat(props.theme.lineHeights.md, " - ").concat(getStatusSize(props, '0'), ") / 2)");
|
|
510
|
+
}, function (props) {
|
|
511
|
+
return reactTheming.retrieveComponentStyles(COMPONENT_ID, props);
|
|
512
|
+
});
|
|
513
|
+
StyledStandaloneStatusIndicator.defaultProps = {
|
|
514
|
+
type: 'offline',
|
|
515
|
+
theme: reactTheming.DEFAULT_THEME
|
|
516
|
+
};
|
|
517
|
+
|
|
467
518
|
var TextComponent = React.forwardRef(function (props, ref) {
|
|
468
519
|
return React__default["default"].createElement(StyledText, _extends$4({
|
|
469
520
|
ref: ref
|
|
@@ -472,7 +523,7 @@ var TextComponent = React.forwardRef(function (props, ref) {
|
|
|
472
523
|
TextComponent.displayName = 'Avatar.Text';
|
|
473
524
|
var Text = TextComponent;
|
|
474
525
|
|
|
475
|
-
var _excluded = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
|
|
526
|
+
var _excluded$1 = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
|
|
476
527
|
var AvatarComponent = React.forwardRef(function (_ref, ref) {
|
|
477
528
|
var isSystem = _ref.isSystem,
|
|
478
529
|
size = _ref.size,
|
|
@@ -482,7 +533,7 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
|
|
|
482
533
|
surfaceColor = _ref.surfaceColor,
|
|
483
534
|
backgroundColor = _ref.backgroundColor,
|
|
484
535
|
foregroundColor = _ref.foregroundColor,
|
|
485
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
536
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
486
537
|
var computedStatus = badge === undefined ? status : 'active';
|
|
487
538
|
var ClockIcon = SvgClockStroke$1;
|
|
488
539
|
var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
@@ -511,7 +562,7 @@ var AvatarComponent = React.forwardRef(function (_ref, ref) {
|
|
|
511
562
|
"aria-live": "polite"
|
|
512
563
|
}, props), React.Children.only(children), computedStatus && React__default["default"].createElement(StyledStatusIndicator, {
|
|
513
564
|
size: size,
|
|
514
|
-
|
|
565
|
+
type: computedStatus,
|
|
515
566
|
backgroundColor: backgroundColor,
|
|
516
567
|
foregroundColor: foregroundColor,
|
|
517
568
|
surfaceColor: surfaceColor,
|
|
@@ -542,4 +593,49 @@ AvatarComponent.defaultProps = {
|
|
|
542
593
|
var Avatar = AvatarComponent;
|
|
543
594
|
Avatar.Text = Text;
|
|
544
595
|
|
|
596
|
+
var _excluded = ["children", "type", "isCompact", "aria-label"];
|
|
597
|
+
var StatusIndicator = React.forwardRef(function (_ref, ref) {
|
|
598
|
+
var children = _ref.children,
|
|
599
|
+
type = _ref.type,
|
|
600
|
+
isCompact = _ref.isCompact,
|
|
601
|
+
label = _ref['aria-label'],
|
|
602
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
603
|
+
var ClockIcon = SvgClockStroke;
|
|
604
|
+
var ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
605
|
+
if (isCompact) {
|
|
606
|
+
ClockIcon = SvgClockStroke$1;
|
|
607
|
+
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
608
|
+
}
|
|
609
|
+
var defaultLabel = React.useMemo(function () {
|
|
610
|
+
return ['status'].concat(type || []).join(': ');
|
|
611
|
+
}, [type]);
|
|
612
|
+
var ariaLabel = reactTheming.useText(StatusIndicator, {
|
|
613
|
+
'aria-label': label
|
|
614
|
+
}, 'aria-label', defaultLabel);
|
|
615
|
+
return React__default["default"].createElement(StyledStandaloneStatus, _extends$4({
|
|
616
|
+
role: "status",
|
|
617
|
+
ref: ref
|
|
618
|
+
}, props), React__default["default"].createElement(StyledStandaloneStatusIndicator, {
|
|
619
|
+
role: "img",
|
|
620
|
+
type: type,
|
|
621
|
+
size: isCompact ? 'small' : 'medium',
|
|
622
|
+
"aria-label": ariaLabel
|
|
623
|
+
}, type === 'away' ? React__default["default"].createElement(ClockIcon, {
|
|
624
|
+
"data-icon-status": type,
|
|
625
|
+
"aria-hidden": "true"
|
|
626
|
+
}) : null, type === 'transfers' ? React__default["default"].createElement(ArrowLeftIcon, {
|
|
627
|
+
"data-icon-status": type,
|
|
628
|
+
"aria-hidden": "true"
|
|
629
|
+
}) : null), children && React__default["default"].createElement(StyledStandaloneStatusCaption, null, children));
|
|
630
|
+
});
|
|
631
|
+
StatusIndicator.displayName = 'StatusIndicator';
|
|
632
|
+
StatusIndicator.propTypes = {
|
|
633
|
+
type: PropTypes__default["default"].oneOf(STATUS),
|
|
634
|
+
isCompact: PropTypes__default["default"].bool
|
|
635
|
+
};
|
|
636
|
+
StatusIndicator.defaultProps = {
|
|
637
|
+
type: 'offline'
|
|
638
|
+
};
|
|
639
|
+
|
|
545
640
|
exports.Avatar = Avatar;
|
|
641
|
+
exports.StatusIndicator = StatusIndicator;
|
package/dist/index.esm.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import React__default, { forwardRef, useMemo, Children } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import { retrieveComponentStyles, DEFAULT_THEME, getColor, useText } from '@zendeskgarden/react-theming';
|
|
12
|
-
import styled, {
|
|
11
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor, getLineHeight, useText } from '@zendeskgarden/react-theming';
|
|
12
|
+
import styled, { keyframes, css } from 'styled-components';
|
|
13
13
|
import { math } from 'polished';
|
|
14
14
|
|
|
15
15
|
function _extends$4() {
|
|
@@ -69,22 +69,10 @@ function _slicedToArray(arr, i) {
|
|
|
69
69
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function _toConsumableArray(arr) {
|
|
73
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function _arrayWithoutHoles(arr) {
|
|
77
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
72
|
function _arrayWithHoles(arr) {
|
|
81
73
|
if (Array.isArray(arr)) return arr;
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
function _iterableToArray(iter) {
|
|
85
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
76
|
function _iterableToArrayLimit(arr, i) {
|
|
89
77
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
90
78
|
|
|
@@ -132,10 +120,6 @@ function _arrayLikeToArray(arr, len) {
|
|
|
132
120
|
return arr2;
|
|
133
121
|
}
|
|
134
122
|
|
|
135
|
-
function _nonIterableSpread() {
|
|
136
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
123
|
function _nonIterableRest() {
|
|
140
124
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
141
125
|
}
|
|
@@ -231,125 +215,143 @@ var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
|
231
215
|
var SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
232
216
|
var STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
233
217
|
|
|
234
|
-
var COMPONENT_ID$
|
|
218
|
+
var COMPONENT_ID$6 = 'avatars.text';
|
|
235
219
|
var StyledText = styled.span.attrs({
|
|
236
|
-
'data-garden-id': COMPONENT_ID$
|
|
237
|
-
'data-garden-version': '8.
|
|
220
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
221
|
+
'data-garden-version': '8.57.1'
|
|
238
222
|
}).withConfig({
|
|
239
223
|
displayName: "StyledText",
|
|
240
224
|
componentId: "sc-1a6hivh-0"
|
|
241
225
|
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], function (props) {
|
|
242
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
226
|
+
return retrieveComponentStyles(COMPONENT_ID$6, props);
|
|
243
227
|
});
|
|
244
228
|
StyledText.defaultProps = {
|
|
245
229
|
theme: DEFAULT_THEME
|
|
246
230
|
};
|
|
247
231
|
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
switch (
|
|
257
|
-
case active
|
|
232
|
+
var _SIZE$1 = _slicedToArray(SIZE, 5),
|
|
233
|
+
xxs$1 = _SIZE$1[0],
|
|
234
|
+
xs$1 = _SIZE$1[1],
|
|
235
|
+
s$1 = _SIZE$1[2],
|
|
236
|
+
m$1 = _SIZE$1[3],
|
|
237
|
+
l$1 = _SIZE$1[4];
|
|
238
|
+
var TRANSITION_DURATION = 0.25;
|
|
239
|
+
function getStatusColor(type, theme) {
|
|
240
|
+
switch (type) {
|
|
241
|
+
case 'active':
|
|
258
242
|
return getColor('crimson', 400, theme);
|
|
259
|
-
case available
|
|
243
|
+
case 'available':
|
|
260
244
|
return getColor('mint', 400, theme);
|
|
261
|
-
case away
|
|
245
|
+
case 'away':
|
|
262
246
|
return getColor('orange', 400, theme);
|
|
263
|
-
case transfers
|
|
247
|
+
case 'transfers':
|
|
264
248
|
return getColor('azure', 400, theme);
|
|
265
|
-
case offline
|
|
249
|
+
case 'offline':
|
|
266
250
|
return getColor('grey', 500, theme);
|
|
267
251
|
default:
|
|
268
252
|
return 'transparent';
|
|
269
253
|
}
|
|
270
254
|
}
|
|
255
|
+
function getStatusBorderOffset(props) {
|
|
256
|
+
return props.size === xxs$1 ? math("".concat(props.theme.shadowWidths.sm, " - 1")) : props.theme.shadowWidths.sm;
|
|
257
|
+
}
|
|
258
|
+
function getStatusSize(props, offset) {
|
|
259
|
+
var isActive = props.type === 'active';
|
|
260
|
+
switch (props.size) {
|
|
261
|
+
case xxs$1:
|
|
262
|
+
return math("".concat(props.theme.space.base, "px - ").concat(offset));
|
|
263
|
+
case xs$1:
|
|
264
|
+
return math("".concat(props.theme.space.base * 2, "px - (").concat(offset, " * 2)"));
|
|
265
|
+
case s$1:
|
|
266
|
+
return math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
|
|
267
|
+
case m$1:
|
|
268
|
+
case l$1:
|
|
269
|
+
return math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(offset, " * 2)")));
|
|
270
|
+
default:
|
|
271
|
+
return '0';
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function includes(array, element) {
|
|
275
|
+
return array.includes(element);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
var COMPONENT_ID$5 = 'avatars.status-indicator.base';
|
|
279
|
+
var iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
280
|
+
var sizeStyles$3 = function sizeStyles(props) {
|
|
281
|
+
var offset = getStatusBorderOffset(props);
|
|
282
|
+
var size = getStatusSize(props, offset);
|
|
283
|
+
return css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
|
|
284
|
+
};
|
|
285
|
+
var colorStyles$2 = function colorStyles(props) {
|
|
286
|
+
var backgroundColor = getStatusColor(props.type, props.theme);
|
|
287
|
+
var borderColor = backgroundColor;
|
|
288
|
+
if (props.type === 'offline') {
|
|
289
|
+
borderColor = getStatusColor(props.type, props.theme);
|
|
290
|
+
backgroundColor = props.theme.palette.white;
|
|
291
|
+
}
|
|
292
|
+
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
293
|
+
};
|
|
294
|
+
var StyledStatusIndicatorBase = styled.div.attrs({
|
|
295
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
296
|
+
'data-garden-version': '8.57.1'
|
|
297
|
+
}).withConfig({
|
|
298
|
+
displayName: "StyledStatusIndicatorBase",
|
|
299
|
+
componentId: "sc-1rininy-0"
|
|
300
|
+
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, function (props) {
|
|
301
|
+
return retrieveComponentStyles(COMPONENT_ID$5, props);
|
|
302
|
+
});
|
|
303
|
+
StyledStatusIndicatorBase.defaultProps = {
|
|
304
|
+
theme: DEFAULT_THEME,
|
|
305
|
+
size: 'small'
|
|
306
|
+
};
|
|
271
307
|
|
|
272
|
-
var COMPONENT_ID$
|
|
308
|
+
var COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
273
309
|
var _SIZE = _slicedToArray(SIZE, 5),
|
|
274
310
|
xxs = _SIZE[0],
|
|
275
311
|
xs = _SIZE[1],
|
|
276
312
|
s = _SIZE[2],
|
|
277
313
|
m = _SIZE[3],
|
|
278
314
|
l = _SIZE[4];
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
away = _ref[2],
|
|
283
|
-
transfers = _ref[3],
|
|
284
|
-
offline = _ref[4];
|
|
285
|
-
var sizeStyles$1 = function sizeStyles(props) {
|
|
286
|
-
var isActive = props.status === 'active';
|
|
287
|
-
var isVisible = true;
|
|
288
|
-
var height = '0';
|
|
315
|
+
var sizeStyles$2 = function sizeStyles(props) {
|
|
316
|
+
var isVisible = !includes([xxs, xs], props.size);
|
|
317
|
+
var borderWidth = getStatusBorderOffset(props);
|
|
289
318
|
var padding = '0';
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
borderWidth = math("".concat(borderWidth, " - 1"));
|
|
295
|
-
height = math("".concat(props.theme.space.base, "px - ").concat(borderWidth));
|
|
296
|
-
break;
|
|
297
|
-
case xs:
|
|
298
|
-
isVisible = false;
|
|
299
|
-
height = math("".concat(props.theme.space.base * 2, "px - (").concat(borderWidth, " * 2)"));
|
|
300
|
-
break;
|
|
301
|
-
case s:
|
|
302
|
-
height = math("".concat(props.theme.space.base * 3, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
|
|
303
|
-
padding = math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
|
|
304
|
-
break;
|
|
305
|
-
case m:
|
|
306
|
-
case l:
|
|
307
|
-
height = math("".concat(props.theme.space.base * 4, "px ").concat(isActive ? '' : "- (".concat(borderWidth, " * 2)")));
|
|
308
|
-
padding = math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
|
|
309
|
-
break;
|
|
319
|
+
if (props.size === s) {
|
|
320
|
+
padding = math("".concat(props.theme.space.base + 1, "px - (").concat(borderWidth, " * 2)"));
|
|
321
|
+
} else if (includes([m, l], props.size)) {
|
|
322
|
+
padding = math("".concat(props.theme.space.base + 3, "px - (").concat(borderWidth, " * 2)"));
|
|
310
323
|
}
|
|
311
|
-
return css(["
|
|
324
|
+
return css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
|
|
312
325
|
};
|
|
313
326
|
var colorStyles$1 = function colorStyles(props) {
|
|
314
|
-
var
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
case active:
|
|
325
|
-
case away:
|
|
326
|
-
case transfers:
|
|
327
|
-
backgroundColor = getStatusColor(props.status, props.theme);
|
|
328
|
-
borderColor = backgroundColor;
|
|
329
|
-
break;
|
|
330
|
-
case offline:
|
|
331
|
-
borderColor = getStatusColor(props.status, props.theme);
|
|
332
|
-
backgroundColor = props.theme.palette.white;
|
|
333
|
-
break;
|
|
327
|
+
var theme = props.theme,
|
|
328
|
+
type = props.type,
|
|
329
|
+
size = props.size,
|
|
330
|
+
foregroundColor = props.foregroundColor,
|
|
331
|
+
backgroundColor = props.backgroundColor,
|
|
332
|
+
borderColor = props.borderColor,
|
|
333
|
+
surfaceColor = props.surfaceColor;
|
|
334
|
+
var boxShadow = theme.shadows.sm(surfaceColor || (type ? theme.colors.background : theme.palette.white));
|
|
335
|
+
if (size === xxs) {
|
|
336
|
+
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
334
337
|
}
|
|
335
338
|
return css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, boxShadow, backgroundColor, foregroundColor);
|
|
336
339
|
};
|
|
337
|
-
var StyledStatusIndicator = styled.
|
|
338
|
-
'data-garden-id': COMPONENT_ID$
|
|
339
|
-
'data-garden-version': '8.
|
|
340
|
+
var StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
341
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
342
|
+
'data-garden-version': '8.57.1'
|
|
340
343
|
}).withConfig({
|
|
341
344
|
displayName: "StyledStatusIndicator",
|
|
342
345
|
componentId: "sc-16t9if3-0"
|
|
343
|
-
})(["", " ", "
|
|
344
|
-
return retrieveComponentStyles(COMPONENT_ID$
|
|
346
|
+
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, function (props) {
|
|
347
|
+
return retrieveComponentStyles(COMPONENT_ID$4, props);
|
|
345
348
|
});
|
|
346
349
|
StyledStatusIndicator.defaultProps = {
|
|
347
350
|
size: 'medium',
|
|
348
351
|
theme: DEFAULT_THEME
|
|
349
352
|
};
|
|
350
353
|
|
|
351
|
-
var COMPONENT_ID = 'avatars.avatar';
|
|
352
|
-
var TRANSITION_DURATION = 0.25;
|
|
354
|
+
var COMPONENT_ID$3 = 'avatars.avatar';
|
|
353
355
|
var badgeStyles = function badgeStyles(props) {
|
|
354
356
|
var _SIZE = _slicedToArray(SIZE, 5),
|
|
355
357
|
xxs = _SIZE[0],
|
|
@@ -379,7 +381,7 @@ var colorStyles = function colorStyles(props) {
|
|
|
379
381
|
var surfaceColor = props.status ? props.surfaceColor || props.theme.colors.background : 'transparent';
|
|
380
382
|
return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
381
383
|
};
|
|
382
|
-
var sizeStyles = function sizeStyles(props) {
|
|
384
|
+
var sizeStyles$1 = function sizeStyles(props) {
|
|
383
385
|
var boxShadow;
|
|
384
386
|
var borderRadius;
|
|
385
387
|
var size;
|
|
@@ -419,23 +421,72 @@ var sizeStyles = function sizeStyles(props) {
|
|
|
419
421
|
return css(["border-radius:", ";width:", " !important;height:", " !important;::before{box-shadow:", ";}& > svg{font-size:", ";}& ", "{line-height:", ";font-size:", ";}"], borderRadius, size, size, boxShadow, svgSize, StyledText, size, fontSize);
|
|
420
422
|
};
|
|
421
423
|
var StyledAvatar = styled.figure.attrs({
|
|
422
|
-
'data-garden-id': COMPONENT_ID,
|
|
423
|
-
'data-garden-version': '8.
|
|
424
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
425
|
+
'data-garden-version': '8.57.1'
|
|
424
426
|
}).withConfig({
|
|
425
427
|
displayName: "StyledAvatar",
|
|
426
428
|
componentId: "sc-608m04-0"
|
|
427
429
|
})(["display:inline-flex;position:relative;align-items:center;justify-content:center;transition:box-shadow ", "s ease-in-out,color 0.1s ease-in-out;margin:0;vertical-align:middle;box-sizing:border-box;", ";", ";&::before{position:absolute;top:0;left:0;transition:box-shadow ", "s ease-in-out;content:'';}&::before,&& > img{border-radius:inherit;width:100%;height:100%;}&& > img{box-sizing:inherit;vertical-align:bottom;object-fit:cover;}&& > svg{width:1em;height:1em;}& > ", "{", ";}", ";"], TRANSITION_DURATION, function (props) {
|
|
428
|
-
return sizeStyles(props);
|
|
430
|
+
return sizeStyles$1(props);
|
|
429
431
|
}, function (props) {
|
|
430
432
|
return colorStyles(props);
|
|
431
433
|
}, TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, function (props) {
|
|
432
|
-
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
434
|
+
return retrieveComponentStyles(COMPONENT_ID$3, props);
|
|
433
435
|
});
|
|
434
436
|
StyledAvatar.defaultProps = {
|
|
435
437
|
size: 'medium',
|
|
436
438
|
theme: DEFAULT_THEME
|
|
437
439
|
};
|
|
438
440
|
|
|
441
|
+
var COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
442
|
+
var StyledStandaloneStatus = styled.figure.attrs({
|
|
443
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
444
|
+
'data-garden-version': '8.57.1'
|
|
445
|
+
}).withConfig({
|
|
446
|
+
displayName: "StyledStandaloneStatus",
|
|
447
|
+
componentId: "sc-1ow4nfj-0"
|
|
448
|
+
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, function (props) {
|
|
449
|
+
return retrieveComponentStyles(COMPONENT_ID$2, props);
|
|
450
|
+
});
|
|
451
|
+
StyledStandaloneStatus.defaultProps = {
|
|
452
|
+
theme: DEFAULT_THEME
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
var COMPONENT_ID$1 = 'avatars.status-indicator.caption';
|
|
456
|
+
function sizeStyles(props) {
|
|
457
|
+
var marginRule = "margin-".concat(props.theme.rtl ? 'right' : 'left', ": ").concat(props.theme.space.base * 2, "px;");
|
|
458
|
+
return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
459
|
+
}
|
|
460
|
+
var StyledStandaloneStatusCaption = styled.figcaption.attrs({
|
|
461
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
462
|
+
'data-garden-version': '8.57.1'
|
|
463
|
+
}).withConfig({
|
|
464
|
+
displayName: "StyledStandaloneStatusCaption",
|
|
465
|
+
componentId: "sc-aalyk1-0"
|
|
466
|
+
})(["", " ", ";"], sizeStyles, function (props) {
|
|
467
|
+
return retrieveComponentStyles(COMPONENT_ID$1, props);
|
|
468
|
+
});
|
|
469
|
+
StyledStandaloneStatusCaption.defaultProps = {
|
|
470
|
+
theme: DEFAULT_THEME
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
var COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
474
|
+
var StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
475
|
+
'data-garden-id': COMPONENT_ID,
|
|
476
|
+
'data-garden-version': '8.57.1'
|
|
477
|
+
}).withConfig({
|
|
478
|
+
displayName: "StyledStandaloneStatusIndicator",
|
|
479
|
+
componentId: "sc-1xt1heq-0"
|
|
480
|
+
})(["position:relative;margin-top:", ";", ";"], function (props) {
|
|
481
|
+
return "calc((".concat(props.theme.lineHeights.md, " - ").concat(getStatusSize(props, '0'), ") / 2)");
|
|
482
|
+
}, function (props) {
|
|
483
|
+
return retrieveComponentStyles(COMPONENT_ID, props);
|
|
484
|
+
});
|
|
485
|
+
StyledStandaloneStatusIndicator.defaultProps = {
|
|
486
|
+
type: 'offline',
|
|
487
|
+
theme: DEFAULT_THEME
|
|
488
|
+
};
|
|
489
|
+
|
|
439
490
|
var TextComponent = forwardRef(function (props, ref) {
|
|
440
491
|
return React__default.createElement(StyledText, _extends$4({
|
|
441
492
|
ref: ref
|
|
@@ -444,7 +495,7 @@ var TextComponent = forwardRef(function (props, ref) {
|
|
|
444
495
|
TextComponent.displayName = 'Avatar.Text';
|
|
445
496
|
var Text = TextComponent;
|
|
446
497
|
|
|
447
|
-
var _excluded = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
|
|
498
|
+
var _excluded$1 = ["isSystem", "size", "status", "children", "badge", "surfaceColor", "backgroundColor", "foregroundColor"];
|
|
448
499
|
var AvatarComponent = forwardRef(function (_ref, ref) {
|
|
449
500
|
var isSystem = _ref.isSystem,
|
|
450
501
|
size = _ref.size,
|
|
@@ -454,7 +505,7 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
|
|
|
454
505
|
surfaceColor = _ref.surfaceColor,
|
|
455
506
|
backgroundColor = _ref.backgroundColor,
|
|
456
507
|
foregroundColor = _ref.foregroundColor,
|
|
457
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
508
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
458
509
|
var computedStatus = badge === undefined ? status : 'active';
|
|
459
510
|
var ClockIcon = SvgClockStroke$1;
|
|
460
511
|
var ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
@@ -483,7 +534,7 @@ var AvatarComponent = forwardRef(function (_ref, ref) {
|
|
|
483
534
|
"aria-live": "polite"
|
|
484
535
|
}, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
|
|
485
536
|
size: size,
|
|
486
|
-
|
|
537
|
+
type: computedStatus,
|
|
487
538
|
backgroundColor: backgroundColor,
|
|
488
539
|
foregroundColor: foregroundColor,
|
|
489
540
|
surfaceColor: surfaceColor,
|
|
@@ -514,4 +565,48 @@ AvatarComponent.defaultProps = {
|
|
|
514
565
|
var Avatar = AvatarComponent;
|
|
515
566
|
Avatar.Text = Text;
|
|
516
567
|
|
|
517
|
-
|
|
568
|
+
var _excluded = ["children", "type", "isCompact", "aria-label"];
|
|
569
|
+
var StatusIndicator = forwardRef(function (_ref, ref) {
|
|
570
|
+
var children = _ref.children,
|
|
571
|
+
type = _ref.type,
|
|
572
|
+
isCompact = _ref.isCompact,
|
|
573
|
+
label = _ref['aria-label'],
|
|
574
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
575
|
+
var ClockIcon = SvgClockStroke;
|
|
576
|
+
var ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
577
|
+
if (isCompact) {
|
|
578
|
+
ClockIcon = SvgClockStroke$1;
|
|
579
|
+
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
580
|
+
}
|
|
581
|
+
var defaultLabel = useMemo(function () {
|
|
582
|
+
return ['status'].concat(type || []).join(': ');
|
|
583
|
+
}, [type]);
|
|
584
|
+
var ariaLabel = useText(StatusIndicator, {
|
|
585
|
+
'aria-label': label
|
|
586
|
+
}, 'aria-label', defaultLabel);
|
|
587
|
+
return React__default.createElement(StyledStandaloneStatus, _extends$4({
|
|
588
|
+
role: "status",
|
|
589
|
+
ref: ref
|
|
590
|
+
}, props), React__default.createElement(StyledStandaloneStatusIndicator, {
|
|
591
|
+
role: "img",
|
|
592
|
+
type: type,
|
|
593
|
+
size: isCompact ? 'small' : 'medium',
|
|
594
|
+
"aria-label": ariaLabel
|
|
595
|
+
}, type === 'away' ? React__default.createElement(ClockIcon, {
|
|
596
|
+
"data-icon-status": type,
|
|
597
|
+
"aria-hidden": "true"
|
|
598
|
+
}) : null, type === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
599
|
+
"data-icon-status": type,
|
|
600
|
+
"aria-hidden": "true"
|
|
601
|
+
}) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children));
|
|
602
|
+
});
|
|
603
|
+
StatusIndicator.displayName = 'StatusIndicator';
|
|
604
|
+
StatusIndicator.propTypes = {
|
|
605
|
+
type: PropTypes.oneOf(STATUS),
|
|
606
|
+
isCompact: PropTypes.bool
|
|
607
|
+
};
|
|
608
|
+
StatusIndicator.defaultProps = {
|
|
609
|
+
type: 'offline'
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
export { Avatar, StatusIndicator };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { IStatusIndicatorProps } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* @extends HTMLAttributes<HTMLElement>
|
|
11
|
+
*/
|
|
12
|
+
export declare const StatusIndicator: React.ForwardRefExoticComponent<IStatusIndicatorProps & React.RefAttributes<HTMLElement>>;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
export { Avatar } from './elements/Avatar';
|
|
8
|
-
export
|
|
8
|
+
export { StatusIndicator } from './elements/StatusIndicator';
|
|
9
|
+
export type { IAvatarProps, IStatusIndicatorProps } from './types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
8
|
+
export declare const StyledStandaloneStatus: import("styled-components").StyledComponent<"figure", DefaultTheme, {
|
|
9
|
+
'data-garden-id': string;
|
|
10
|
+
'data-garden-version': string;
|
|
11
|
+
} & ThemeProps<DefaultTheme>, "data-garden-id" | "data-garden-version">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
8
|
+
export declare const StyledStandaloneStatusCaption: import("styled-components").StyledComponent<"figcaption", DefaultTheme, {
|
|
9
|
+
'data-garden-id': string;
|
|
10
|
+
'data-garden-version': string;
|
|
11
|
+
} & ThemeProps<DefaultTheme>, "data-garden-id" | "data-garden-version">;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { IStyledStatusIndicatorProps } from './utility';
|
|
8
|
+
export declare const StyledStandaloneStatusIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
9
|
+
'data-garden-id': string;
|
|
10
|
+
'data-garden-version': string;
|
|
11
|
+
} & IStyledStatusIndicatorProps & {
|
|
12
|
+
'data-garden-id': string;
|
|
13
|
+
'data-garden-version': string;
|
|
14
|
+
}, "data-garden-id" | "data-garden-version">;
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { DefaultTheme } from 'styled-components';
|
|
8
8
|
import { IAvatarProps } from '../types';
|
|
9
|
+
import { IStyledStatusIndicatorProps } from './utility';
|
|
9
10
|
export interface IStatusIndicatorProps extends Omit<IAvatarProps, 'badge' | 'isSystem' | 'status'> {
|
|
10
|
-
readonly
|
|
11
|
+
readonly type?: IStyledStatusIndicatorProps['type'];
|
|
11
12
|
borderColor?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare const StyledStatusIndicator: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
14
15
|
'data-garden-id': string;
|
|
15
16
|
'data-garden-version': string;
|
|
17
|
+
} & IStyledStatusIndicatorProps & {
|
|
18
|
+
'data-garden-id': string;
|
|
19
|
+
'data-garden-version': string;
|
|
16
20
|
} & IStatusIndicatorProps, "data-garden-id" | "data-garden-version">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { IStyledStatusIndicatorProps } from './utility';
|
|
8
|
+
export declare const StyledStatusIndicatorBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
9
|
+
'data-garden-id': string;
|
|
10
|
+
'data-garden-version': string;
|
|
11
|
+
} & IStyledStatusIndicatorProps, "data-garden-id" | "data-garden-version">;
|
|
@@ -5,5 +5,8 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
export * from './StyledAvatar';
|
|
8
|
+
export * from './StyledStandaloneStatus';
|
|
9
|
+
export * from './StyledStandaloneStatusCaption';
|
|
10
|
+
export * from './StyledStandaloneStatusIndicator';
|
|
8
11
|
export * from './StyledStatusIndicator';
|
|
9
12
|
export * from './StyledText';
|
|
@@ -4,5 +4,14 @@
|
|
|
4
4
|
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
8
|
+
import { IAvatarProps } from '../types';
|
|
9
|
+
export declare const TRANSITION_DURATION = 0.25;
|
|
10
|
+
export interface IStyledStatusIndicatorProps extends ThemeProps<DefaultTheme> {
|
|
11
|
+
readonly size?: IAvatarProps['size'];
|
|
12
|
+
readonly type?: IAvatarProps['status'] | 'active';
|
|
13
|
+
}
|
|
14
|
+
export declare function getStatusColor(type?: IStyledStatusIndicatorProps['type'], theme?: IStyledStatusIndicatorProps['theme']): string;
|
|
15
|
+
export declare function getStatusBorderOffset(props: IStyledStatusIndicatorProps): string;
|
|
16
|
+
export declare function getStatusSize(props: IStyledStatusIndicatorProps, offset: string): string;
|
|
17
|
+
export declare function includes<T extends U, U>(array: readonly T[], element: U): element is T;
|
|
@@ -25,3 +25,9 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
|
|
|
25
25
|
/** Sets the badge text and applies active styling */
|
|
26
26
|
badge?: string | number;
|
|
27
27
|
}
|
|
28
|
+
export interface IStatusIndicatorProps extends HTMLAttributes<HTMLElement> {
|
|
29
|
+
/** Applies status type for styling and default aria-label */
|
|
30
|
+
type?: typeof STATUS[number];
|
|
31
|
+
/** Applies compact styling */
|
|
32
|
+
isCompact?: boolean;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-avatars",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.57.1",
|
|
4
4
|
"description": "Components relating to avatars in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"styled-components": "^4.2.0 || ^5.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@zendeskgarden/react-theming": "^8.
|
|
34
|
+
"@zendeskgarden/react-theming": "^8.57.1",
|
|
35
35
|
"@zendeskgarden/svg-icons": "6.33.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"zendeskgarden:src": "src/index.ts",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "3e903f3c7013221ef01d3f81a50489505490be7b"
|
|
48
48
|
}
|