@zendeskgarden/react-avatars 9.0.0-next.0 → 9.0.0-next.10
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 +22 -38
- package/package.json +6 -6
- 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.10'
|
|
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.10'
|
|
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.10'
|
|
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.10'
|
|
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.10'
|
|
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.10'
|
|
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.10'
|
|
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 };
|