@zendeskgarden/react-avatars 9.0.0-next.7 → 9.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/elements/Avatar.js +93 -0
- package/dist/esm/elements/StatusIndicator.js +67 -0
- package/dist/esm/elements/components/Text.js +21 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/arrow-left-sm-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/clock-stroke.svg.js +33 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/arrow-left-sm-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/clock-stroke.svg.js +33 -0
- package/dist/esm/styled/StyledAvatar.js +91 -0
- package/dist/esm/styled/StyledStandaloneStatus.js +23 -0
- package/dist/esm/styled/StyledStandaloneStatusCaption.js +26 -0
- package/dist/esm/styled/StyledStandaloneStatusIndicator.js +25 -0
- package/dist/esm/styled/StyledStatusIndicator.js +53 -0
- package/dist/esm/styled/StyledStatusIndicatorBase.js +39 -0
- package/dist/esm/styled/StyledText.js +22 -0
- package/dist/esm/styled/utility.js +52 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/index.cjs.js +15 -31
- package/package.json +5 -5
- package/dist/index.esm.js +0 -471
|
@@ -0,0 +1,93 @@
|
|
|
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__default, { forwardRef, useMemo, Children } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { useText } from '@zendeskgarden/react-theming';
|
|
10
|
+
import SvgClockStroke from '../node_modules/@zendeskgarden/svg-icons/src/12/clock-stroke.svg.js';
|
|
11
|
+
import SvgClockStroke$1 from '../node_modules/@zendeskgarden/svg-icons/src/16/clock-stroke.svg.js';
|
|
12
|
+
import SvgArrowLeftSmStroke from '../node_modules/@zendeskgarden/svg-icons/src/12/arrow-left-sm-stroke.svg.js';
|
|
13
|
+
import SvgArrowLeftSmStroke$1 from '../node_modules/@zendeskgarden/svg-icons/src/16/arrow-left-sm-stroke.svg.js';
|
|
14
|
+
import { SIZE, STATUS } from '../types/index.js';
|
|
15
|
+
import { StyledAvatar } from '../styled/StyledAvatar.js';
|
|
16
|
+
import '../styled/StyledStandaloneStatus.js';
|
|
17
|
+
import '../styled/StyledStandaloneStatusCaption.js';
|
|
18
|
+
import '../styled/StyledStandaloneStatusIndicator.js';
|
|
19
|
+
import { StyledStatusIndicator } from '../styled/StyledStatusIndicator.js';
|
|
20
|
+
import '../styled/StyledText.js';
|
|
21
|
+
import { Text } from './components/Text.js';
|
|
22
|
+
|
|
23
|
+
const AvatarComponent = forwardRef((_ref, ref) => {
|
|
24
|
+
let {
|
|
25
|
+
isSystem,
|
|
26
|
+
size,
|
|
27
|
+
status,
|
|
28
|
+
children,
|
|
29
|
+
badge,
|
|
30
|
+
surfaceColor,
|
|
31
|
+
backgroundColor,
|
|
32
|
+
foregroundColor,
|
|
33
|
+
...props
|
|
34
|
+
} = _ref;
|
|
35
|
+
const computedStatus = badge === undefined ? status : 'active';
|
|
36
|
+
let ClockIcon = SvgClockStroke;
|
|
37
|
+
let ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
38
|
+
if (['large', 'medium'].includes(size)) {
|
|
39
|
+
ClockIcon = SvgClockStroke$1;
|
|
40
|
+
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
41
|
+
}
|
|
42
|
+
const defaultStatusLabel = useMemo(() => {
|
|
43
|
+
let statusMessage = computedStatus;
|
|
44
|
+
if (computedStatus === 'active') {
|
|
45
|
+
const count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
|
|
46
|
+
statusMessage = `active. ${count > 0 ? `${count} notification${count > 1 ? 's' : ''}` : 'no notifications'}`;
|
|
47
|
+
}
|
|
48
|
+
return ['status'].concat(statusMessage || []).join(': ');
|
|
49
|
+
}, [computedStatus, badge]);
|
|
50
|
+
const shouldValidate = computedStatus !== undefined;
|
|
51
|
+
const statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
|
|
52
|
+
return React__default.createElement(StyledAvatar, Object.assign({
|
|
53
|
+
ref: ref,
|
|
54
|
+
isSystem: isSystem,
|
|
55
|
+
size: size,
|
|
56
|
+
status: computedStatus,
|
|
57
|
+
surfaceColor: surfaceColor,
|
|
58
|
+
backgroundColor: backgroundColor,
|
|
59
|
+
foregroundColor: foregroundColor,
|
|
60
|
+
"aria-atomic": "true",
|
|
61
|
+
"aria-live": "polite"
|
|
62
|
+
}, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
|
|
63
|
+
size: size,
|
|
64
|
+
type: computedStatus,
|
|
65
|
+
surfaceColor: surfaceColor,
|
|
66
|
+
"aria-label": statusLabel,
|
|
67
|
+
as: "figcaption"
|
|
68
|
+
}, computedStatus === 'active' ? React__default.createElement("span", {
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
}, badge) : React__default.createElement(React__default.Fragment, null, computedStatus === 'away' ? React__default.createElement(ClockIcon, {
|
|
71
|
+
"data-icon-status": computedStatus
|
|
72
|
+
}) : null, computedStatus === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
73
|
+
"data-icon-status": computedStatus
|
|
74
|
+
}) : null)));
|
|
75
|
+
});
|
|
76
|
+
AvatarComponent.displayName = 'Avatar';
|
|
77
|
+
AvatarComponent.propTypes = {
|
|
78
|
+
backgroundColor: PropTypes.string,
|
|
79
|
+
foregroundColor: PropTypes.string,
|
|
80
|
+
surfaceColor: PropTypes.string,
|
|
81
|
+
isSystem: PropTypes.bool,
|
|
82
|
+
badge: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
83
|
+
size: PropTypes.oneOf(SIZE),
|
|
84
|
+
status: PropTypes.oneOf(STATUS),
|
|
85
|
+
statusLabel: PropTypes.string
|
|
86
|
+
};
|
|
87
|
+
AvatarComponent.defaultProps = {
|
|
88
|
+
size: 'medium'
|
|
89
|
+
};
|
|
90
|
+
const Avatar = AvatarComponent;
|
|
91
|
+
Avatar.Text = Text;
|
|
92
|
+
|
|
93
|
+
export { Avatar };
|
|
@@ -0,0 +1,67 @@
|
|
|
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__default, { forwardRef, useMemo } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { useText } from '@zendeskgarden/react-theming';
|
|
10
|
+
import SvgClockStroke$1 from '../node_modules/@zendeskgarden/svg-icons/src/12/clock-stroke.svg.js';
|
|
11
|
+
import SvgClockStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/clock-stroke.svg.js';
|
|
12
|
+
import SvgArrowLeftSmStroke$1 from '../node_modules/@zendeskgarden/svg-icons/src/12/arrow-left-sm-stroke.svg.js';
|
|
13
|
+
import SvgArrowLeftSmStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/arrow-left-sm-stroke.svg.js';
|
|
14
|
+
import { STATUS } from '../types/index.js';
|
|
15
|
+
import '../styled/StyledAvatar.js';
|
|
16
|
+
import { StyledStandaloneStatus } from '../styled/StyledStandaloneStatus.js';
|
|
17
|
+
import { StyledStandaloneStatusCaption } from '../styled/StyledStandaloneStatusCaption.js';
|
|
18
|
+
import { StyledStandaloneStatusIndicator } from '../styled/StyledStandaloneStatusIndicator.js';
|
|
19
|
+
import '../styled/StyledStatusIndicator.js';
|
|
20
|
+
import '../styled/StyledText.js';
|
|
21
|
+
|
|
22
|
+
const StatusIndicator = forwardRef((_ref, ref) => {
|
|
23
|
+
let {
|
|
24
|
+
children,
|
|
25
|
+
type,
|
|
26
|
+
isCompact,
|
|
27
|
+
'aria-label': label,
|
|
28
|
+
...props
|
|
29
|
+
} = _ref;
|
|
30
|
+
let ClockIcon = SvgClockStroke;
|
|
31
|
+
let ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
32
|
+
if (isCompact) {
|
|
33
|
+
ClockIcon = SvgClockStroke$1;
|
|
34
|
+
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
35
|
+
}
|
|
36
|
+
const defaultLabel = useMemo(() => ['status'].concat(type || []).join(': '), [type]);
|
|
37
|
+
const ariaLabel = useText(StatusIndicator, {
|
|
38
|
+
'aria-label': label
|
|
39
|
+
}, 'aria-label', defaultLabel);
|
|
40
|
+
return (
|
|
41
|
+
React__default.createElement(StyledStandaloneStatus, Object.assign({
|
|
42
|
+
role: "status",
|
|
43
|
+
ref: ref
|
|
44
|
+
}, props), React__default.createElement(StyledStandaloneStatusIndicator, {
|
|
45
|
+
role: "img",
|
|
46
|
+
type: type,
|
|
47
|
+
size: isCompact ? 'small' : 'medium',
|
|
48
|
+
"aria-label": ariaLabel
|
|
49
|
+
}, type === 'away' ? React__default.createElement(ClockIcon, {
|
|
50
|
+
"data-icon-status": type,
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}) : null, type === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
53
|
+
"data-icon-status": type,
|
|
54
|
+
"aria-hidden": "true"
|
|
55
|
+
}) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children))
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
StatusIndicator.displayName = 'StatusIndicator';
|
|
59
|
+
StatusIndicator.propTypes = {
|
|
60
|
+
type: PropTypes.oneOf(STATUS),
|
|
61
|
+
isCompact: PropTypes.bool
|
|
62
|
+
};
|
|
63
|
+
StatusIndicator.defaultProps = {
|
|
64
|
+
type: 'offline'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { StatusIndicator };
|
|
@@ -0,0 +1,21 @@
|
|
|
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__default, { forwardRef } from 'react';
|
|
8
|
+
import '../../styled/StyledAvatar.js';
|
|
9
|
+
import '../../styled/StyledStandaloneStatus.js';
|
|
10
|
+
import '../../styled/StyledStandaloneStatusCaption.js';
|
|
11
|
+
import '../../styled/StyledStandaloneStatusIndicator.js';
|
|
12
|
+
import '../../styled/StyledStatusIndicator.js';
|
|
13
|
+
import { StyledText } from '../../styled/StyledText.js';
|
|
14
|
+
|
|
15
|
+
const TextComponent = forwardRef((props, ref) => React__default.createElement(StyledText, Object.assign({
|
|
16
|
+
ref: ref
|
|
17
|
+
}, props)));
|
|
18
|
+
TextComponent.displayName = 'Avatar.Text';
|
|
19
|
+
const Text = TextComponent;
|
|
20
|
+
|
|
21
|
+
export { Text };
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export { Avatar } from './elements/Avatar.js';
|
|
8
|
+
export { StatusIndicator } from './elements/StatusIndicator.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 12,
|
|
15
|
+
height: 12,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 12 12",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
d: "M2.146 6.854a.5.5 0 0 1 0-.708l2-2a.5.5 0 1 1 .708.708L3.707 6H9.5a.5.5 0 0 1 0 1H3.707l1.147 1.146a.5.5 0 1 1-.708.708l-2-2Z"
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { SvgArrowLeftSmStroke as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _g;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgClockStroke = function SvgClockStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 12,
|
|
15
|
+
height: 12,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 12 12",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
20
|
+
fill: "none",
|
|
21
|
+
stroke: "currentColor"
|
|
22
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
23
|
+
cx: 6,
|
|
24
|
+
cy: 6,
|
|
25
|
+
r: 5.5
|
|
26
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
d: "M5.5 3v3.5H8"
|
|
30
|
+
}))));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { SvgClockStroke as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _path;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 16,
|
|
15
|
+
height: 16,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
fill: "currentColor",
|
|
21
|
+
d: "M3.146 8.854a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L4.707 8H12.5a.5.5 0 0 1 0 1H4.707l2.147 2.146a.5.5 0 1 1-.708.707l-3-3Z"
|
|
22
|
+
})));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { SvgArrowLeftSmStroke as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
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 * as React from 'react';
|
|
8
|
+
|
|
9
|
+
var _g;
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
var SvgClockStroke = function SvgClockStroke(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
width: 16,
|
|
15
|
+
height: 16,
|
|
16
|
+
focusable: "false",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
20
|
+
fill: "none",
|
|
21
|
+
stroke: "currentColor"
|
|
22
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
23
|
+
cx: 8,
|
|
24
|
+
cy: 8,
|
|
25
|
+
r: 7.5
|
|
26
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
d: "M7.5 3v5.5H11"
|
|
30
|
+
}))));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { SvgClockStroke as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
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 styled, { keyframes, css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { math } from 'polished';
|
|
10
|
+
import { SIZE } from '../types/index.js';
|
|
11
|
+
import { StyledText } from './StyledText.js';
|
|
12
|
+
import { StyledStatusIndicator } from './StyledStatusIndicator.js';
|
|
13
|
+
import { TRANSITION_DURATION, getStatusColor } from './utility.js';
|
|
14
|
+
|
|
15
|
+
const COMPONENT_ID = 'avatars.avatar';
|
|
16
|
+
const badgeStyles = props => {
|
|
17
|
+
const [xxs, xs, s, m, l] = SIZE;
|
|
18
|
+
let position = `${props.theme.space.base * -1}px`;
|
|
19
|
+
switch (props.size) {
|
|
20
|
+
case s:
|
|
21
|
+
case m:
|
|
22
|
+
position = math(`${position} + 2`);
|
|
23
|
+
break;
|
|
24
|
+
case xxs:
|
|
25
|
+
case xs:
|
|
26
|
+
case l:
|
|
27
|
+
position = math(`${position} + 3`);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
const animation = keyframes(["0%{transform:scale(.1);}"]);
|
|
31
|
+
return css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props.status === 'active' && css(["animation:", " ", "s ease-in-out;"], animation, TRANSITION_DURATION * 1.5));
|
|
32
|
+
};
|
|
33
|
+
const colorStyles = props => {
|
|
34
|
+
const statusColor = getStatusColor(props.status, props.theme);
|
|
35
|
+
const backgroundColor = props.backgroundColor || 'transparent';
|
|
36
|
+
const foregroundColor = props.foregroundColor || props.theme.palette.white;
|
|
37
|
+
const surfaceColor = props.status ? props.surfaceColor || getColorV8('background', 600 , props.theme) : 'transparent';
|
|
38
|
+
return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
39
|
+
};
|
|
40
|
+
const sizeStyles = props => {
|
|
41
|
+
let boxShadow;
|
|
42
|
+
let borderRadius;
|
|
43
|
+
let size;
|
|
44
|
+
let fontSize;
|
|
45
|
+
let svgSize;
|
|
46
|
+
if (props.size === 'extraextrasmall') {
|
|
47
|
+
boxShadow = `0 0 0 ${math(`${props.theme.shadowWidths.sm} - 1`)}`;
|
|
48
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
49
|
+
size = `${props.theme.space.base * 4}px`;
|
|
50
|
+
fontSize = 0;
|
|
51
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
52
|
+
} else if (props.size === 'extrasmall') {
|
|
53
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
54
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
55
|
+
size = `${props.theme.space.base * 6}px`;
|
|
56
|
+
fontSize = props.theme.fontSizes.sm;
|
|
57
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
58
|
+
} else if (props.size === 'small') {
|
|
59
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
60
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
61
|
+
size = `${props.theme.space.base * 8}px`;
|
|
62
|
+
fontSize = props.theme.fontSizes.md;
|
|
63
|
+
svgSize = `${props.theme.space.base * 3}px`;
|
|
64
|
+
} else if (props.size === 'large') {
|
|
65
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
66
|
+
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
|
|
67
|
+
size = `${props.theme.space.base * 12}px`;
|
|
68
|
+
fontSize = props.theme.fontSizes.xl;
|
|
69
|
+
svgSize = `${props.theme.space.base * 6}px`;
|
|
70
|
+
} else {
|
|
71
|
+
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
72
|
+
borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
|
|
73
|
+
size = `${props.theme.space.base * 10}px`;
|
|
74
|
+
fontSize = props.theme.fontSizes.lg;
|
|
75
|
+
svgSize = `${props.theme.space.base * 4}px`;
|
|
76
|
+
}
|
|
77
|
+
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);
|
|
78
|
+
};
|
|
79
|
+
const StyledAvatar = styled.figure.attrs({
|
|
80
|
+
'data-garden-id': COMPONENT_ID,
|
|
81
|
+
'data-garden-version': '9.0.0-next.8'
|
|
82
|
+
}).withConfig({
|
|
83
|
+
displayName: "StyledAvatar",
|
|
84
|
+
componentId: "sc-608m04-0"
|
|
85
|
+
})(["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, props => sizeStyles(props), props => colorStyles(props), TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
86
|
+
StyledAvatar.defaultProps = {
|
|
87
|
+
size: 'medium',
|
|
88
|
+
theme: DEFAULT_THEME
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export { StyledAvatar };
|
|
@@ -0,0 +1,23 @@
|
|
|
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 styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { TRANSITION_DURATION } from './utility.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'avatars.status-indicator.status';
|
|
12
|
+
const StyledStandaloneStatus = styled.figure.attrs({
|
|
13
|
+
'data-garden-id': COMPONENT_ID,
|
|
14
|
+
'data-garden-version': '9.0.0-next.8'
|
|
15
|
+
}).withConfig({
|
|
16
|
+
displayName: "StyledStandaloneStatus",
|
|
17
|
+
componentId: "sc-1ow4nfj-0"
|
|
18
|
+
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
19
|
+
StyledStandaloneStatus.defaultProps = {
|
|
20
|
+
theme: DEFAULT_THEME
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { StyledStandaloneStatus };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getLineHeight } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'avatars.status-indicator.caption';
|
|
11
|
+
function sizeStyles(props) {
|
|
12
|
+
const marginRule = `margin-${props.theme.rtl ? 'right' : 'left'}: ${props.theme.space.base * 2}px;`;
|
|
13
|
+
return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
14
|
+
}
|
|
15
|
+
const StyledStandaloneStatusCaption = styled.figcaption.attrs({
|
|
16
|
+
'data-garden-id': COMPONENT_ID,
|
|
17
|
+
'data-garden-version': '9.0.0-next.8'
|
|
18
|
+
}).withConfig({
|
|
19
|
+
displayName: "StyledStandaloneStatusCaption",
|
|
20
|
+
componentId: "sc-aalyk1-0"
|
|
21
|
+
})(["", " ", ";"], sizeStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
22
|
+
StyledStandaloneStatusCaption.defaultProps = {
|
|
23
|
+
theme: DEFAULT_THEME
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { StyledStandaloneStatusCaption };
|
|
@@ -0,0 +1,25 @@
|
|
|
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 styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { getStatusSize } from './utility.js';
|
|
10
|
+
import { StyledStatusIndicatorBase } from './StyledStatusIndicatorBase.js';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
13
|
+
const StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
14
|
+
'data-garden-id': COMPONENT_ID,
|
|
15
|
+
'data-garden-version': '9.0.0-next.8'
|
|
16
|
+
}).withConfig({
|
|
17
|
+
displayName: "StyledStandaloneStatusIndicator",
|
|
18
|
+
componentId: "sc-1xt1heq-0"
|
|
19
|
+
})(["position:relative;box-sizing:content-box;margin-top:", ";", ";"], props => `calc((${props.theme.lineHeights.md} - ${getStatusSize(props, '0')}) / 2)`, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
20
|
+
StyledStandaloneStatusIndicator.defaultProps = {
|
|
21
|
+
type: 'offline',
|
|
22
|
+
theme: DEFAULT_THEME
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { StyledStandaloneStatusIndicator };
|
|
@@ -0,0 +1,53 @@
|
|
|
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 styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { math } from 'polished';
|
|
10
|
+
import { SIZE } from '../types/index.js';
|
|
11
|
+
import { StyledStatusIndicatorBase } from './StyledStatusIndicatorBase.js';
|
|
12
|
+
import { includes, getStatusBorderOffset } from './utility.js';
|
|
13
|
+
|
|
14
|
+
const COMPONENT_ID = 'avatars.status_indicator';
|
|
15
|
+
const [xxs, xs, s, m, l] = SIZE;
|
|
16
|
+
const sizeStyles = props => {
|
|
17
|
+
const isVisible = !includes([xxs, xs], props.size);
|
|
18
|
+
const borderWidth = getStatusBorderOffset(props);
|
|
19
|
+
let padding = '0';
|
|
20
|
+
if (props.size === s) {
|
|
21
|
+
padding = math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
|
|
22
|
+
} else if (includes([m, l], props.size)) {
|
|
23
|
+
padding = math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
|
|
24
|
+
}
|
|
25
|
+
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;');
|
|
26
|
+
};
|
|
27
|
+
const colorStyles = props => {
|
|
28
|
+
const {
|
|
29
|
+
theme,
|
|
30
|
+
type,
|
|
31
|
+
size,
|
|
32
|
+
borderColor,
|
|
33
|
+
surfaceColor
|
|
34
|
+
} = props;
|
|
35
|
+
let boxShadow = theme.shadows.sm(surfaceColor || (type ? getColorV8('background', 600 , theme) : theme.palette.white));
|
|
36
|
+
if (size === xxs) {
|
|
37
|
+
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
38
|
+
}
|
|
39
|
+
return css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
|
|
40
|
+
};
|
|
41
|
+
const StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
42
|
+
'data-garden-id': COMPONENT_ID,
|
|
43
|
+
'data-garden-version': '9.0.0-next.8'
|
|
44
|
+
}).withConfig({
|
|
45
|
+
displayName: "StyledStatusIndicator",
|
|
46
|
+
componentId: "sc-16t9if3-0"
|
|
47
|
+
})(["", " ", " ", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
48
|
+
StyledStatusIndicator.defaultProps = {
|
|
49
|
+
size: 'medium',
|
|
50
|
+
theme: DEFAULT_THEME
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { StyledStatusIndicator };
|
|
@@ -0,0 +1,39 @@
|
|
|
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 styled, { keyframes, css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { getStatusBorderOffset, getStatusSize, TRANSITION_DURATION, getStatusColor } from './utility.js';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'avatars.status-indicator.base';
|
|
12
|
+
const iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
13
|
+
const sizeStyles = props => {
|
|
14
|
+
const offset = getStatusBorderOffset(props);
|
|
15
|
+
const size = getStatusSize(props, offset);
|
|
16
|
+
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);
|
|
17
|
+
};
|
|
18
|
+
const colorStyles = props => {
|
|
19
|
+
let backgroundColor = getStatusColor(props.type, props.theme);
|
|
20
|
+
let borderColor = backgroundColor;
|
|
21
|
+
if (props.type === 'offline') {
|
|
22
|
+
borderColor = getStatusColor(props.type, props.theme);
|
|
23
|
+
backgroundColor = props.theme.palette.white;
|
|
24
|
+
}
|
|
25
|
+
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
26
|
+
};
|
|
27
|
+
const StyledStatusIndicatorBase = styled.div.attrs({
|
|
28
|
+
'data-garden-id': COMPONENT_ID,
|
|
29
|
+
'data-garden-version': '9.0.0-next.8'
|
|
30
|
+
}).withConfig({
|
|
31
|
+
displayName: "StyledStatusIndicatorBase",
|
|
32
|
+
componentId: "sc-1rininy-0"
|
|
33
|
+
})(["transition:inherit;", " ", " ", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
34
|
+
StyledStatusIndicatorBase.defaultProps = {
|
|
35
|
+
theme: DEFAULT_THEME,
|
|
36
|
+
size: 'small'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { StyledStatusIndicatorBase };
|
|
@@ -0,0 +1,22 @@
|
|
|
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 styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'avatars.text';
|
|
11
|
+
const StyledText = styled.span.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.8'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledText",
|
|
16
|
+
componentId: "sc-1a6hivh-0"
|
|
17
|
+
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledText.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledText };
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { getColorV8 } from '@zendeskgarden/react-theming';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { SIZE } from '../types/index.js';
|
|
10
|
+
|
|
11
|
+
const [xxs, xs, s, m, l] = SIZE;
|
|
12
|
+
const TRANSITION_DURATION = 0.25;
|
|
13
|
+
function getStatusColor(type, theme) {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case 'active':
|
|
16
|
+
return getColorV8('crimson', 400, theme);
|
|
17
|
+
case 'available':
|
|
18
|
+
return getColorV8('mint', 400, theme);
|
|
19
|
+
case 'away':
|
|
20
|
+
return getColorV8('orange', 400, theme);
|
|
21
|
+
case 'transfers':
|
|
22
|
+
return getColorV8('azure', 400, theme);
|
|
23
|
+
case 'offline':
|
|
24
|
+
return getColorV8('grey', 500, theme);
|
|
25
|
+
default:
|
|
26
|
+
return 'transparent';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function getStatusBorderOffset(props) {
|
|
30
|
+
return props.size === xxs ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
31
|
+
}
|
|
32
|
+
function getStatusSize(props, offset) {
|
|
33
|
+
const isActive = props.type === 'active';
|
|
34
|
+
switch (props.size) {
|
|
35
|
+
case xxs:
|
|
36
|
+
return math(`${props.theme.space.base}px - ${offset}`);
|
|
37
|
+
case xs:
|
|
38
|
+
return math(`${props.theme.space.base * 2}px - (${offset} * 2)`);
|
|
39
|
+
case s:
|
|
40
|
+
return math(`${props.theme.space.base * 3}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
41
|
+
case m:
|
|
42
|
+
case l:
|
|
43
|
+
return math(`${props.theme.space.base * 4}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
44
|
+
default:
|
|
45
|
+
return '0';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function includes(array, element) {
|
|
49
|
+
return array.includes(element);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { TRANSITION_DURATION, getStatusBorderOffset, getStatusColor, getStatusSize, includes };
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
8
|
+
const STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
9
|
+
|
|
10
|
+
export { SIZE, STATUS };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
*/
|
|
8
7
|
'use strict';
|
|
9
8
|
|
|
10
9
|
var React = require('react');
|
|
@@ -37,21 +36,6 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
37
36
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
38
37
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
39
38
|
|
|
40
|
-
function _extends$4() {
|
|
41
|
-
_extends$4 = Object.assign ? Object.assign.bind() : function (target) {
|
|
42
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
43
|
-
var source = arguments[i];
|
|
44
|
-
for (var key in source) {
|
|
45
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
46
|
-
target[key] = source[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return target;
|
|
51
|
-
};
|
|
52
|
-
return _extends$4.apply(this, arguments);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
39
|
var _g$1;
|
|
56
40
|
function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
|
|
57
41
|
var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
@@ -138,7 +122,7 @@ const STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
|
138
122
|
const COMPONENT_ID$6 = 'avatars.text';
|
|
139
123
|
const StyledText = styled__default.default.span.attrs({
|
|
140
124
|
'data-garden-id': COMPONENT_ID$6,
|
|
141
|
-
'data-garden-version': '9.0.0-next.
|
|
125
|
+
'data-garden-version': '9.0.0-next.8'
|
|
142
126
|
}).withConfig({
|
|
143
127
|
displayName: "StyledText",
|
|
144
128
|
componentId: "sc-1a6hivh-0"
|
|
@@ -206,7 +190,7 @@ const colorStyles$2 = props => {
|
|
|
206
190
|
};
|
|
207
191
|
const StyledStatusIndicatorBase = styled__default.default.div.attrs({
|
|
208
192
|
'data-garden-id': COMPONENT_ID$5,
|
|
209
|
-
'data-garden-version': '9.0.0-next.
|
|
193
|
+
'data-garden-version': '9.0.0-next.8'
|
|
210
194
|
}).withConfig({
|
|
211
195
|
displayName: "StyledStatusIndicatorBase",
|
|
212
196
|
componentId: "sc-1rininy-0"
|
|
@@ -245,7 +229,7 @@ const colorStyles$1 = props => {
|
|
|
245
229
|
};
|
|
246
230
|
const StyledStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
|
|
247
231
|
'data-garden-id': COMPONENT_ID$4,
|
|
248
|
-
'data-garden-version': '9.0.0-next.
|
|
232
|
+
'data-garden-version': '9.0.0-next.8'
|
|
249
233
|
}).withConfig({
|
|
250
234
|
displayName: "StyledStatusIndicator",
|
|
251
235
|
componentId: "sc-16t9if3-0"
|
|
@@ -321,7 +305,7 @@ const sizeStyles$1 = props => {
|
|
|
321
305
|
};
|
|
322
306
|
const StyledAvatar = styled__default.default.figure.attrs({
|
|
323
307
|
'data-garden-id': COMPONENT_ID$3,
|
|
324
|
-
'data-garden-version': '9.0.0-next.
|
|
308
|
+
'data-garden-version': '9.0.0-next.8'
|
|
325
309
|
}).withConfig({
|
|
326
310
|
displayName: "StyledAvatar",
|
|
327
311
|
componentId: "sc-608m04-0"
|
|
@@ -334,7 +318,7 @@ StyledAvatar.defaultProps = {
|
|
|
334
318
|
const COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
335
319
|
const StyledStandaloneStatus = styled__default.default.figure.attrs({
|
|
336
320
|
'data-garden-id': COMPONENT_ID$2,
|
|
337
|
-
'data-garden-version': '9.0.0-next.
|
|
321
|
+
'data-garden-version': '9.0.0-next.8'
|
|
338
322
|
}).withConfig({
|
|
339
323
|
displayName: "StyledStandaloneStatus",
|
|
340
324
|
componentId: "sc-1ow4nfj-0"
|
|
@@ -350,7 +334,7 @@ function sizeStyles(props) {
|
|
|
350
334
|
}
|
|
351
335
|
const StyledStandaloneStatusCaption = styled__default.default.figcaption.attrs({
|
|
352
336
|
'data-garden-id': COMPONENT_ID$1,
|
|
353
|
-
'data-garden-version': '9.0.0-next.
|
|
337
|
+
'data-garden-version': '9.0.0-next.8'
|
|
354
338
|
}).withConfig({
|
|
355
339
|
displayName: "StyledStandaloneStatusCaption",
|
|
356
340
|
componentId: "sc-aalyk1-0"
|
|
@@ -362,7 +346,7 @@ StyledStandaloneStatusCaption.defaultProps = {
|
|
|
362
346
|
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
363
347
|
const StyledStandaloneStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
|
|
364
348
|
'data-garden-id': COMPONENT_ID,
|
|
365
|
-
'data-garden-version': '9.0.0-next.
|
|
349
|
+
'data-garden-version': '9.0.0-next.8'
|
|
366
350
|
}).withConfig({
|
|
367
351
|
displayName: "StyledStandaloneStatusIndicator",
|
|
368
352
|
componentId: "sc-1xt1heq-0"
|
|
@@ -372,7 +356,7 @@ StyledStandaloneStatusIndicator.defaultProps = {
|
|
|
372
356
|
theme: reactTheming.DEFAULT_THEME
|
|
373
357
|
};
|
|
374
358
|
|
|
375
|
-
const TextComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledText,
|
|
359
|
+
const TextComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledText, Object.assign({
|
|
376
360
|
ref: ref
|
|
377
361
|
}, props)));
|
|
378
362
|
TextComponent.displayName = 'Avatar.Text';
|
|
@@ -407,7 +391,7 @@ const AvatarComponent = React.forwardRef((_ref, ref) => {
|
|
|
407
391
|
}, [computedStatus, badge]);
|
|
408
392
|
const shouldValidate = computedStatus !== undefined;
|
|
409
393
|
const statusLabel = reactTheming.useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
|
|
410
|
-
return React__namespace.default.createElement(StyledAvatar,
|
|
394
|
+
return React__namespace.default.createElement(StyledAvatar, Object.assign({
|
|
411
395
|
ref: ref,
|
|
412
396
|
isSystem: isSystem,
|
|
413
397
|
size: size,
|
|
@@ -467,7 +451,7 @@ const StatusIndicator = React.forwardRef((_ref, ref) => {
|
|
|
467
451
|
'aria-label': label
|
|
468
452
|
}, 'aria-label', defaultLabel);
|
|
469
453
|
return (
|
|
470
|
-
React__namespace.default.createElement(StyledStandaloneStatus,
|
|
454
|
+
React__namespace.default.createElement(StyledStandaloneStatus, Object.assign({
|
|
471
455
|
role: "status",
|
|
472
456
|
ref: ref
|
|
473
457
|
}, props), React__namespace.default.createElement(StyledStandaloneStatusIndicator, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-avatars",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.8",
|
|
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>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/zendeskgarden/react-components/issues"
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.cjs.js",
|
|
13
|
-
"module": "dist/index.
|
|
13
|
+
"module": "dist/esm/index.js",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"prop-types": "^15.5.7"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@zendeskgarden/react-theming": "
|
|
28
|
+
"@zendeskgarden/react-theming": ">=9.0.0-next",
|
|
29
29
|
"react": ">=16.8.0",
|
|
30
30
|
"react-dom": ">=16.8.0",
|
|
31
31
|
"styled-components": "^5.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@zendeskgarden/react-theming": "^9.0.0-next.
|
|
34
|
+
"@zendeskgarden/react-theming": "^9.0.0-next.8",
|
|
35
35
|
"@zendeskgarden/svg-icons": "7.0.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": "a3d6534843d5a4f5cb60b52bc67264f3230f2da0"
|
|
48
48
|
}
|
package/dist/index.esm.js
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import React__default, { forwardRef, useMemo, Children } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8, getLineHeight, useText } from '@zendeskgarden/react-theming';
|
|
12
|
-
import styled, { keyframes, css } from 'styled-components';
|
|
13
|
-
import { math } from 'polished';
|
|
14
|
-
|
|
15
|
-
function _extends$4() {
|
|
16
|
-
_extends$4 = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends$4.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var _g$1;
|
|
31
|
-
function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
|
|
32
|
-
var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
33
|
-
return /*#__PURE__*/React.createElement("svg", _extends$3({
|
|
34
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
-
width: 12,
|
|
36
|
-
height: 12,
|
|
37
|
-
focusable: "false",
|
|
38
|
-
viewBox: "0 0 12 12",
|
|
39
|
-
"aria-hidden": "true"
|
|
40
|
-
}, props), _g$1 || (_g$1 = /*#__PURE__*/React.createElement("g", {
|
|
41
|
-
fill: "none",
|
|
42
|
-
stroke: "currentColor"
|
|
43
|
-
}, /*#__PURE__*/React.createElement("circle", {
|
|
44
|
-
cx: 6,
|
|
45
|
-
cy: 6,
|
|
46
|
-
r: 5.5
|
|
47
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
48
|
-
strokeLinecap: "round",
|
|
49
|
-
strokeLinejoin: "round",
|
|
50
|
-
d: "M5.5 3v3.5H8"
|
|
51
|
-
}))));
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var _g;
|
|
55
|
-
function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
56
|
-
var SvgClockStroke = function SvgClockStroke(props) {
|
|
57
|
-
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
58
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
-
width: 16,
|
|
60
|
-
height: 16,
|
|
61
|
-
focusable: "false",
|
|
62
|
-
viewBox: "0 0 16 16",
|
|
63
|
-
"aria-hidden": "true"
|
|
64
|
-
}, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
|
|
65
|
-
fill: "none",
|
|
66
|
-
stroke: "currentColor"
|
|
67
|
-
}, /*#__PURE__*/React.createElement("circle", {
|
|
68
|
-
cx: 8,
|
|
69
|
-
cy: 8,
|
|
70
|
-
r: 7.5
|
|
71
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
72
|
-
strokeLinecap: "round",
|
|
73
|
-
strokeLinejoin: "round",
|
|
74
|
-
d: "M7.5 3v5.5H11"
|
|
75
|
-
}))));
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
var _path$1;
|
|
79
|
-
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
80
|
-
var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
|
|
81
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
82
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
-
width: 12,
|
|
84
|
-
height: 12,
|
|
85
|
-
focusable: "false",
|
|
86
|
-
viewBox: "0 0 12 12",
|
|
87
|
-
"aria-hidden": "true"
|
|
88
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
89
|
-
fill: "currentColor",
|
|
90
|
-
d: "M2.146 6.854a.5.5 0 0 1 0-.708l2-2a.5.5 0 1 1 .708.708L3.707 6H9.5a.5.5 0 0 1 0 1H3.707l1.147 1.146a.5.5 0 1 1-.708.708l-2-2Z"
|
|
91
|
-
})));
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var _path;
|
|
95
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
96
|
-
var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
97
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
98
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
99
|
-
width: 16,
|
|
100
|
-
height: 16,
|
|
101
|
-
focusable: "false",
|
|
102
|
-
viewBox: "0 0 16 16",
|
|
103
|
-
"aria-hidden": "true"
|
|
104
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
105
|
-
fill: "currentColor",
|
|
106
|
-
d: "M3.146 8.854a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L4.707 8H12.5a.5.5 0 0 1 0 1H4.707l2.147 2.146a.5.5 0 1 1-.708.707l-3-3Z"
|
|
107
|
-
})));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const SIZE = ['extraextrasmall', 'extrasmall', 'small', 'medium', 'large'];
|
|
111
|
-
const STATUS = ['available', 'away', 'transfers', 'offline'];
|
|
112
|
-
|
|
113
|
-
const COMPONENT_ID$6 = 'avatars.text';
|
|
114
|
-
const StyledText = styled.span.attrs({
|
|
115
|
-
'data-garden-id': COMPONENT_ID$6,
|
|
116
|
-
'data-garden-version': '9.0.0-next.7'
|
|
117
|
-
}).withConfig({
|
|
118
|
-
displayName: "StyledText",
|
|
119
|
-
componentId: "sc-1a6hivh-0"
|
|
120
|
-
})(["overflow:hidden;text-align:center;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
121
|
-
StyledText.defaultProps = {
|
|
122
|
-
theme: DEFAULT_THEME
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const [xxs$1, xs$1, s$1, m$1, l$1] = SIZE;
|
|
126
|
-
const TRANSITION_DURATION = 0.25;
|
|
127
|
-
function getStatusColor(type, theme) {
|
|
128
|
-
switch (type) {
|
|
129
|
-
case 'active':
|
|
130
|
-
return getColorV8('crimson', 400, theme);
|
|
131
|
-
case 'available':
|
|
132
|
-
return getColorV8('mint', 400, theme);
|
|
133
|
-
case 'away':
|
|
134
|
-
return getColorV8('orange', 400, theme);
|
|
135
|
-
case 'transfers':
|
|
136
|
-
return getColorV8('azure', 400, theme);
|
|
137
|
-
case 'offline':
|
|
138
|
-
return getColorV8('grey', 500, theme);
|
|
139
|
-
default:
|
|
140
|
-
return 'transparent';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function getStatusBorderOffset(props) {
|
|
144
|
-
return props.size === xxs$1 ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
145
|
-
}
|
|
146
|
-
function getStatusSize(props, offset) {
|
|
147
|
-
const isActive = props.type === 'active';
|
|
148
|
-
switch (props.size) {
|
|
149
|
-
case xxs$1:
|
|
150
|
-
return math(`${props.theme.space.base}px - ${offset}`);
|
|
151
|
-
case xs$1:
|
|
152
|
-
return math(`${props.theme.space.base * 2}px - (${offset} * 2)`);
|
|
153
|
-
case s$1:
|
|
154
|
-
return math(`${props.theme.space.base * 3}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
155
|
-
case m$1:
|
|
156
|
-
case l$1:
|
|
157
|
-
return math(`${props.theme.space.base * 4}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
158
|
-
default:
|
|
159
|
-
return '0';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function includes(array, element) {
|
|
163
|
-
return array.includes(element);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const COMPONENT_ID$5 = 'avatars.status-indicator.base';
|
|
167
|
-
const iconFadeIn = keyframes(["0%{opacity:0;}100%{opacity:1;}"]);
|
|
168
|
-
const sizeStyles$3 = props => {
|
|
169
|
-
const offset = getStatusBorderOffset(props);
|
|
170
|
-
const size = getStatusSize(props, offset);
|
|
171
|
-
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);
|
|
172
|
-
};
|
|
173
|
-
const colorStyles$2 = props => {
|
|
174
|
-
let backgroundColor = getStatusColor(props.type, props.theme);
|
|
175
|
-
let borderColor = backgroundColor;
|
|
176
|
-
if (props.type === 'offline') {
|
|
177
|
-
borderColor = getStatusColor(props.type, props.theme);
|
|
178
|
-
backgroundColor = props.theme.palette.white;
|
|
179
|
-
}
|
|
180
|
-
return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
|
|
181
|
-
};
|
|
182
|
-
const StyledStatusIndicatorBase = styled.div.attrs({
|
|
183
|
-
'data-garden-id': COMPONENT_ID$5,
|
|
184
|
-
'data-garden-version': '9.0.0-next.7'
|
|
185
|
-
}).withConfig({
|
|
186
|
-
displayName: "StyledStatusIndicatorBase",
|
|
187
|
-
componentId: "sc-1rininy-0"
|
|
188
|
-
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
189
|
-
StyledStatusIndicatorBase.defaultProps = {
|
|
190
|
-
theme: DEFAULT_THEME,
|
|
191
|
-
size: 'small'
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
195
|
-
const [xxs, xs, s, m, l] = SIZE;
|
|
196
|
-
const sizeStyles$2 = props => {
|
|
197
|
-
const isVisible = !includes([xxs, xs], props.size);
|
|
198
|
-
const borderWidth = getStatusBorderOffset(props);
|
|
199
|
-
let padding = '0';
|
|
200
|
-
if (props.size === s) {
|
|
201
|
-
padding = math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
|
|
202
|
-
} else if (includes([m, l], props.size)) {
|
|
203
|
-
padding = math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
|
|
204
|
-
}
|
|
205
|
-
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;');
|
|
206
|
-
};
|
|
207
|
-
const colorStyles$1 = props => {
|
|
208
|
-
const {
|
|
209
|
-
theme,
|
|
210
|
-
type,
|
|
211
|
-
size,
|
|
212
|
-
borderColor,
|
|
213
|
-
surfaceColor
|
|
214
|
-
} = props;
|
|
215
|
-
let boxShadow = theme.shadows.sm(surfaceColor || (type ? getColorV8('background', 600 , theme) : theme.palette.white));
|
|
216
|
-
if (size === xxs) {
|
|
217
|
-
boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
|
|
218
|
-
}
|
|
219
|
-
return css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
|
|
220
|
-
};
|
|
221
|
-
const StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
222
|
-
'data-garden-id': COMPONENT_ID$4,
|
|
223
|
-
'data-garden-version': '9.0.0-next.7'
|
|
224
|
-
}).withConfig({
|
|
225
|
-
displayName: "StyledStatusIndicator",
|
|
226
|
-
componentId: "sc-16t9if3-0"
|
|
227
|
-
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
228
|
-
StyledStatusIndicator.defaultProps = {
|
|
229
|
-
size: 'medium',
|
|
230
|
-
theme: DEFAULT_THEME
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const COMPONENT_ID$3 = 'avatars.avatar';
|
|
234
|
-
const badgeStyles = props => {
|
|
235
|
-
const [xxs, xs, s, m, l] = SIZE;
|
|
236
|
-
let position = `${props.theme.space.base * -1}px`;
|
|
237
|
-
switch (props.size) {
|
|
238
|
-
case s:
|
|
239
|
-
case m:
|
|
240
|
-
position = math(`${position} + 2`);
|
|
241
|
-
break;
|
|
242
|
-
case xxs:
|
|
243
|
-
case xs:
|
|
244
|
-
case l:
|
|
245
|
-
position = math(`${position} + 3`);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
const animation = keyframes(["0%{transform:scale(.1);}"]);
|
|
249
|
-
return css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props.status === 'active' && css(["animation:", " ", "s ease-in-out;"], animation, TRANSITION_DURATION * 1.5));
|
|
250
|
-
};
|
|
251
|
-
const colorStyles = props => {
|
|
252
|
-
const statusColor = getStatusColor(props.status, props.theme);
|
|
253
|
-
const backgroundColor = props.backgroundColor || 'transparent';
|
|
254
|
-
const foregroundColor = props.foregroundColor || props.theme.palette.white;
|
|
255
|
-
const surfaceColor = props.status ? props.surfaceColor || getColorV8('background', 600 , props.theme) : 'transparent';
|
|
256
|
-
return css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
257
|
-
};
|
|
258
|
-
const sizeStyles$1 = props => {
|
|
259
|
-
let boxShadow;
|
|
260
|
-
let borderRadius;
|
|
261
|
-
let size;
|
|
262
|
-
let fontSize;
|
|
263
|
-
let svgSize;
|
|
264
|
-
if (props.size === 'extraextrasmall') {
|
|
265
|
-
boxShadow = `0 0 0 ${math(`${props.theme.shadowWidths.sm} - 1`)}`;
|
|
266
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
267
|
-
size = `${props.theme.space.base * 4}px`;
|
|
268
|
-
fontSize = 0;
|
|
269
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
270
|
-
} else if (props.size === 'extrasmall') {
|
|
271
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
272
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
273
|
-
size = `${props.theme.space.base * 6}px`;
|
|
274
|
-
fontSize = props.theme.fontSizes.sm;
|
|
275
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
276
|
-
} else if (props.size === 'small') {
|
|
277
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
278
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
279
|
-
size = `${props.theme.space.base * 8}px`;
|
|
280
|
-
fontSize = props.theme.fontSizes.md;
|
|
281
|
-
svgSize = `${props.theme.space.base * 3}px`;
|
|
282
|
-
} else if (props.size === 'large') {
|
|
283
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
284
|
-
borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
|
|
285
|
-
size = `${props.theme.space.base * 12}px`;
|
|
286
|
-
fontSize = props.theme.fontSizes.xl;
|
|
287
|
-
svgSize = `${props.theme.space.base * 6}px`;
|
|
288
|
-
} else {
|
|
289
|
-
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
290
|
-
borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
|
|
291
|
-
size = `${props.theme.space.base * 10}px`;
|
|
292
|
-
fontSize = props.theme.fontSizes.lg;
|
|
293
|
-
svgSize = `${props.theme.space.base * 4}px`;
|
|
294
|
-
}
|
|
295
|
-
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);
|
|
296
|
-
};
|
|
297
|
-
const StyledAvatar = styled.figure.attrs({
|
|
298
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
299
|
-
'data-garden-version': '9.0.0-next.7'
|
|
300
|
-
}).withConfig({
|
|
301
|
-
displayName: "StyledAvatar",
|
|
302
|
-
componentId: "sc-608m04-0"
|
|
303
|
-
})(["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, props => sizeStyles$1(props), props => colorStyles(props), TRANSITION_DURATION, StyledStatusIndicator, badgeStyles, props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
304
|
-
StyledAvatar.defaultProps = {
|
|
305
|
-
size: 'medium',
|
|
306
|
-
theme: DEFAULT_THEME
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
310
|
-
const StyledStandaloneStatus = styled.figure.attrs({
|
|
311
|
-
'data-garden-id': COMPONENT_ID$2,
|
|
312
|
-
'data-garden-version': '9.0.0-next.7'
|
|
313
|
-
}).withConfig({
|
|
314
|
-
displayName: "StyledStandaloneStatus",
|
|
315
|
-
componentId: "sc-1ow4nfj-0"
|
|
316
|
-
})(["display:inline-flex;flex-flow:row nowrap;transition:all ", "s ease-in-out;margin:0;box-sizing:content-box;", ";"], TRANSITION_DURATION, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
317
|
-
StyledStandaloneStatus.defaultProps = {
|
|
318
|
-
theme: DEFAULT_THEME
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const COMPONENT_ID$1 = 'avatars.status-indicator.caption';
|
|
322
|
-
function sizeStyles(props) {
|
|
323
|
-
const marginRule = `margin-${props.theme.rtl ? 'right' : 'left'}: ${props.theme.space.base * 2}px;`;
|
|
324
|
-
return css(["", " line-height:", ";font-size:", ";"], marginRule, getLineHeight(props.theme.lineHeights.md, props.theme.fontSizes.md), props.theme.fontSizes.md);
|
|
325
|
-
}
|
|
326
|
-
const StyledStandaloneStatusCaption = styled.figcaption.attrs({
|
|
327
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
328
|
-
'data-garden-version': '9.0.0-next.7'
|
|
329
|
-
}).withConfig({
|
|
330
|
-
displayName: "StyledStandaloneStatusCaption",
|
|
331
|
-
componentId: "sc-aalyk1-0"
|
|
332
|
-
})(["", " ", ";"], sizeStyles, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
333
|
-
StyledStandaloneStatusCaption.defaultProps = {
|
|
334
|
-
theme: DEFAULT_THEME
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
338
|
-
const StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
|
|
339
|
-
'data-garden-id': COMPONENT_ID,
|
|
340
|
-
'data-garden-version': '9.0.0-next.7'
|
|
341
|
-
}).withConfig({
|
|
342
|
-
displayName: "StyledStandaloneStatusIndicator",
|
|
343
|
-
componentId: "sc-1xt1heq-0"
|
|
344
|
-
})(["position:relative;box-sizing:content-box;margin-top:", ";", ";"], props => `calc((${props.theme.lineHeights.md} - ${getStatusSize(props, '0')}) / 2)`, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
345
|
-
StyledStandaloneStatusIndicator.defaultProps = {
|
|
346
|
-
type: 'offline',
|
|
347
|
-
theme: DEFAULT_THEME
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const TextComponent = forwardRef((props, ref) => React__default.createElement(StyledText, _extends$4({
|
|
351
|
-
ref: ref
|
|
352
|
-
}, props)));
|
|
353
|
-
TextComponent.displayName = 'Avatar.Text';
|
|
354
|
-
const Text = TextComponent;
|
|
355
|
-
|
|
356
|
-
const AvatarComponent = forwardRef((_ref, ref) => {
|
|
357
|
-
let {
|
|
358
|
-
isSystem,
|
|
359
|
-
size,
|
|
360
|
-
status,
|
|
361
|
-
children,
|
|
362
|
-
badge,
|
|
363
|
-
surfaceColor,
|
|
364
|
-
backgroundColor,
|
|
365
|
-
foregroundColor,
|
|
366
|
-
...props
|
|
367
|
-
} = _ref;
|
|
368
|
-
const computedStatus = badge === undefined ? status : 'active';
|
|
369
|
-
let ClockIcon = SvgClockStroke$1;
|
|
370
|
-
let ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
371
|
-
if (['large', 'medium'].includes(size)) {
|
|
372
|
-
ClockIcon = SvgClockStroke;
|
|
373
|
-
ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
374
|
-
}
|
|
375
|
-
const defaultStatusLabel = useMemo(() => {
|
|
376
|
-
let statusMessage = computedStatus;
|
|
377
|
-
if (computedStatus === 'active') {
|
|
378
|
-
const count = typeof badge === 'string' ? parseInt(badge, 10) : badge;
|
|
379
|
-
statusMessage = `active. ${count > 0 ? `${count} notification${count > 1 ? 's' : ''}` : 'no notifications'}`;
|
|
380
|
-
}
|
|
381
|
-
return ['status'].concat(statusMessage || []).join(': ');
|
|
382
|
-
}, [computedStatus, badge]);
|
|
383
|
-
const shouldValidate = computedStatus !== undefined;
|
|
384
|
-
const statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
|
|
385
|
-
return React__default.createElement(StyledAvatar, _extends$4({
|
|
386
|
-
ref: ref,
|
|
387
|
-
isSystem: isSystem,
|
|
388
|
-
size: size,
|
|
389
|
-
status: computedStatus,
|
|
390
|
-
surfaceColor: surfaceColor,
|
|
391
|
-
backgroundColor: backgroundColor,
|
|
392
|
-
foregroundColor: foregroundColor,
|
|
393
|
-
"aria-atomic": "true",
|
|
394
|
-
"aria-live": "polite"
|
|
395
|
-
}, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
|
|
396
|
-
size: size,
|
|
397
|
-
type: computedStatus,
|
|
398
|
-
surfaceColor: surfaceColor,
|
|
399
|
-
"aria-label": statusLabel,
|
|
400
|
-
as: "figcaption"
|
|
401
|
-
}, computedStatus === 'active' ? React__default.createElement("span", {
|
|
402
|
-
"aria-hidden": "true"
|
|
403
|
-
}, badge) : React__default.createElement(React__default.Fragment, null, computedStatus === 'away' ? React__default.createElement(ClockIcon, {
|
|
404
|
-
"data-icon-status": computedStatus
|
|
405
|
-
}) : null, computedStatus === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
406
|
-
"data-icon-status": computedStatus
|
|
407
|
-
}) : null)));
|
|
408
|
-
});
|
|
409
|
-
AvatarComponent.displayName = 'Avatar';
|
|
410
|
-
AvatarComponent.propTypes = {
|
|
411
|
-
backgroundColor: PropTypes.string,
|
|
412
|
-
foregroundColor: PropTypes.string,
|
|
413
|
-
surfaceColor: PropTypes.string,
|
|
414
|
-
isSystem: PropTypes.bool,
|
|
415
|
-
badge: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
416
|
-
size: PropTypes.oneOf(SIZE),
|
|
417
|
-
status: PropTypes.oneOf(STATUS),
|
|
418
|
-
statusLabel: PropTypes.string
|
|
419
|
-
};
|
|
420
|
-
AvatarComponent.defaultProps = {
|
|
421
|
-
size: 'medium'
|
|
422
|
-
};
|
|
423
|
-
const Avatar = AvatarComponent;
|
|
424
|
-
Avatar.Text = Text;
|
|
425
|
-
|
|
426
|
-
const StatusIndicator = forwardRef((_ref, ref) => {
|
|
427
|
-
let {
|
|
428
|
-
children,
|
|
429
|
-
type,
|
|
430
|
-
isCompact,
|
|
431
|
-
'aria-label': label,
|
|
432
|
-
...props
|
|
433
|
-
} = _ref;
|
|
434
|
-
let ClockIcon = SvgClockStroke;
|
|
435
|
-
let ArrowLeftIcon = SvgArrowLeftSmStroke;
|
|
436
|
-
if (isCompact) {
|
|
437
|
-
ClockIcon = SvgClockStroke$1;
|
|
438
|
-
ArrowLeftIcon = SvgArrowLeftSmStroke$1;
|
|
439
|
-
}
|
|
440
|
-
const defaultLabel = useMemo(() => ['status'].concat(type || []).join(': '), [type]);
|
|
441
|
-
const ariaLabel = useText(StatusIndicator, {
|
|
442
|
-
'aria-label': label
|
|
443
|
-
}, 'aria-label', defaultLabel);
|
|
444
|
-
return (
|
|
445
|
-
React__default.createElement(StyledStandaloneStatus, _extends$4({
|
|
446
|
-
role: "status",
|
|
447
|
-
ref: ref
|
|
448
|
-
}, props), React__default.createElement(StyledStandaloneStatusIndicator, {
|
|
449
|
-
role: "img",
|
|
450
|
-
type: type,
|
|
451
|
-
size: isCompact ? 'small' : 'medium',
|
|
452
|
-
"aria-label": ariaLabel
|
|
453
|
-
}, type === 'away' ? React__default.createElement(ClockIcon, {
|
|
454
|
-
"data-icon-status": type,
|
|
455
|
-
"aria-hidden": "true"
|
|
456
|
-
}) : null, type === 'transfers' ? React__default.createElement(ArrowLeftIcon, {
|
|
457
|
-
"data-icon-status": type,
|
|
458
|
-
"aria-hidden": "true"
|
|
459
|
-
}) : null), children && React__default.createElement(StyledStandaloneStatusCaption, null, children))
|
|
460
|
-
);
|
|
461
|
-
});
|
|
462
|
-
StatusIndicator.displayName = 'StatusIndicator';
|
|
463
|
-
StatusIndicator.propTypes = {
|
|
464
|
-
type: PropTypes.oneOf(STATUS),
|
|
465
|
-
isCompact: PropTypes.bool
|
|
466
|
-
};
|
|
467
|
-
StatusIndicator.defaultProps = {
|
|
468
|
-
type: 'offline'
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
export { Avatar, StatusIndicator };
|