@zendeskgarden/react-avatars 9.0.0-next.2 → 9.0.0-next.21
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 +101 -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 +59 -0
- package/dist/esm/styled/StyledStatusIndicatorBase.js +53 -0
- package/dist/esm/styled/StyledText.js +22 -0
- package/dist/esm/styled/utility.js +93 -0
- package/dist/esm/types/index.js +10 -0
- package/dist/index.cjs.js +160 -105
- package/dist/typings/styled/StyledAvatar.d.ts +7 -2
- package/dist/typings/styled/StyledStatusIndicator.d.ts +4 -2
- package/dist/typings/styled/utility.d.ts +3 -3
- package/package.json +9 -8
- 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 { getColor } 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
|
+
const StatusColorParams = {
|
|
14
|
+
active: {
|
|
15
|
+
hue: 'crimson',
|
|
16
|
+
light: {
|
|
17
|
+
shade: 700
|
|
18
|
+
},
|
|
19
|
+
dark: {
|
|
20
|
+
shade: 600
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
available: {
|
|
24
|
+
hue: 'mint',
|
|
25
|
+
light: {
|
|
26
|
+
shade: 500
|
|
27
|
+
},
|
|
28
|
+
dark: {
|
|
29
|
+
shade: 400
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
away: {
|
|
33
|
+
hue: 'orange',
|
|
34
|
+
light: {
|
|
35
|
+
shade: 500
|
|
36
|
+
},
|
|
37
|
+
dark: {
|
|
38
|
+
shade: 400
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
transfers: {
|
|
42
|
+
hue: 'azure',
|
|
43
|
+
light: {
|
|
44
|
+
shade: 500
|
|
45
|
+
},
|
|
46
|
+
dark: {
|
|
47
|
+
shade: 400
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
offline: {
|
|
51
|
+
hue: 'grey',
|
|
52
|
+
light: {
|
|
53
|
+
shade: 500
|
|
54
|
+
},
|
|
55
|
+
dark: {
|
|
56
|
+
shade: 400
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function getStatusColor(theme, type) {
|
|
61
|
+
if (type === undefined) {
|
|
62
|
+
return 'transparent';
|
|
63
|
+
}
|
|
64
|
+
const colorArgs = StatusColorParams[type];
|
|
65
|
+
return colorArgs ? getColor({
|
|
66
|
+
...colorArgs,
|
|
67
|
+
theme
|
|
68
|
+
}) : 'transparent';
|
|
69
|
+
}
|
|
70
|
+
function getStatusBorderOffset(props) {
|
|
71
|
+
return props.$size === xxs ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
72
|
+
}
|
|
73
|
+
function getStatusSize(props, offset) {
|
|
74
|
+
const isActive = props.$type === 'active';
|
|
75
|
+
switch (props.$size) {
|
|
76
|
+
case xxs:
|
|
77
|
+
return math(`${props.theme.space.base}px - ${offset}`);
|
|
78
|
+
case xs:
|
|
79
|
+
return math(`${props.theme.space.base * 2}px - (${offset} * 2)`);
|
|
80
|
+
case s:
|
|
81
|
+
return math(`${props.theme.space.base * 3}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
82
|
+
case m:
|
|
83
|
+
case l:
|
|
84
|
+
return math(`${props.theme.space.base * 4}px ${isActive ? '' : `- (${offset} * 2)`}`);
|
|
85
|
+
default:
|
|
86
|
+
return '0';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function includes(array, element) {
|
|
90
|
+
return array.includes(element);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
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,23 +36,8 @@ 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
|
-
function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (
|
|
40
|
+
function _extends$3() { return _extends$3 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$3.apply(null, arguments); }
|
|
57
41
|
var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
58
42
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3({
|
|
59
43
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -77,7 +61,7 @@ var SvgClockStroke$1 = function SvgClockStroke(props) {
|
|
|
77
61
|
};
|
|
78
62
|
|
|
79
63
|
var _g;
|
|
80
|
-
function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (
|
|
64
|
+
function _extends$2() { return _extends$2 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$2.apply(null, arguments); }
|
|
81
65
|
var SvgClockStroke = function SvgClockStroke(props) {
|
|
82
66
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
|
|
83
67
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -101,7 +85,7 @@ var SvgClockStroke = function SvgClockStroke(props) {
|
|
|
101
85
|
};
|
|
102
86
|
|
|
103
87
|
var _path$1;
|
|
104
|
-
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (
|
|
88
|
+
function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
|
|
105
89
|
var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
|
|
106
90
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
107
91
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -117,7 +101,7 @@ var SvgArrowLeftSmStroke$1 = function SvgArrowLeftSmStroke(props) {
|
|
|
117
101
|
};
|
|
118
102
|
|
|
119
103
|
var _path;
|
|
120
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
104
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
121
105
|
var SvgArrowLeftSmStroke = function SvgArrowLeftSmStroke(props) {
|
|
122
106
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
123
107
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -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.21'
|
|
142
126
|
}).withConfig({
|
|
143
127
|
displayName: "StyledText",
|
|
144
128
|
componentId: "sc-1a6hivh-0"
|
|
@@ -149,28 +133,69 @@ StyledText.defaultProps = {
|
|
|
149
133
|
|
|
150
134
|
const [xxs$1, xs$1, s$1, m$1, l$1] = SIZE;
|
|
151
135
|
const TRANSITION_DURATION = 0.25;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
136
|
+
const StatusColorParams = {
|
|
137
|
+
active: {
|
|
138
|
+
hue: 'crimson',
|
|
139
|
+
light: {
|
|
140
|
+
shade: 700
|
|
141
|
+
},
|
|
142
|
+
dark: {
|
|
143
|
+
shade: 600
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
available: {
|
|
147
|
+
hue: 'mint',
|
|
148
|
+
light: {
|
|
149
|
+
shade: 500
|
|
150
|
+
},
|
|
151
|
+
dark: {
|
|
152
|
+
shade: 400
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
away: {
|
|
156
|
+
hue: 'orange',
|
|
157
|
+
light: {
|
|
158
|
+
shade: 500
|
|
159
|
+
},
|
|
160
|
+
dark: {
|
|
161
|
+
shade: 400
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
transfers: {
|
|
165
|
+
hue: 'azure',
|
|
166
|
+
light: {
|
|
167
|
+
shade: 500
|
|
168
|
+
},
|
|
169
|
+
dark: {
|
|
170
|
+
shade: 400
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
offline: {
|
|
174
|
+
hue: 'grey',
|
|
175
|
+
light: {
|
|
176
|
+
shade: 500
|
|
177
|
+
},
|
|
178
|
+
dark: {
|
|
179
|
+
shade: 400
|
|
180
|
+
}
|
|
166
181
|
}
|
|
182
|
+
};
|
|
183
|
+
function getStatusColor(theme, type) {
|
|
184
|
+
if (type === undefined) {
|
|
185
|
+
return 'transparent';
|
|
186
|
+
}
|
|
187
|
+
const colorArgs = StatusColorParams[type];
|
|
188
|
+
return colorArgs ? reactTheming.getColor({
|
|
189
|
+
...colorArgs,
|
|
190
|
+
theme
|
|
191
|
+
}) : 'transparent';
|
|
167
192
|
}
|
|
168
193
|
function getStatusBorderOffset(props) {
|
|
169
|
-
return props
|
|
194
|
+
return props.$size === xxs$1 ? polished.math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
|
|
170
195
|
}
|
|
171
196
|
function getStatusSize(props, offset) {
|
|
172
|
-
const isActive = props
|
|
173
|
-
switch (props
|
|
197
|
+
const isActive = props.$type === 'active';
|
|
198
|
+
switch (props.$size) {
|
|
174
199
|
case xxs$1:
|
|
175
200
|
return polished.math(`${props.theme.space.base}px - ${offset}`);
|
|
176
201
|
case xs$1:
|
|
@@ -195,63 +220,83 @@ const sizeStyles$3 = props => {
|
|
|
195
220
|
const size = getStatusSize(props, offset);
|
|
196
221
|
return styled.css(["border:", " ", ";border-radius:", ";width:", ";min-width:", ";height:", ";line-height:", ";& > svg{position:absolute;top:-", ";left:-", ";transform-origin:50% 50%;animation:", " ", "s;max-height:unset;&[data-icon-status='transfers']{transform:scale(", ",1);}&[data-icon-status='away'] circle{display:none;}}"], offset, props.theme.borderStyles.solid, size, size, size, size, size, offset, offset, iconFadeIn, TRANSITION_DURATION, props.theme.rtl ? -1 : 1);
|
|
197
222
|
};
|
|
198
|
-
const colorStyles$2 =
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
const colorStyles$2 = _ref => {
|
|
224
|
+
let {
|
|
225
|
+
theme,
|
|
226
|
+
$type
|
|
227
|
+
} = _ref;
|
|
228
|
+
const foregroundColor = reactTheming.getColor({
|
|
229
|
+
variable: 'foreground.onEmphasis',
|
|
230
|
+
theme
|
|
231
|
+
});
|
|
232
|
+
let backgroundColor;
|
|
233
|
+
let borderColor;
|
|
234
|
+
if ($type === 'offline') {
|
|
235
|
+
borderColor = getStatusColor(theme, $type);
|
|
236
|
+
backgroundColor = reactTheming.getColor({
|
|
237
|
+
variable: 'background.default',
|
|
238
|
+
theme
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
backgroundColor = getStatusColor(theme, $type);
|
|
242
|
+
borderColor = backgroundColor;
|
|
204
243
|
}
|
|
205
|
-
return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor,
|
|
244
|
+
return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, foregroundColor);
|
|
206
245
|
};
|
|
207
246
|
const StyledStatusIndicatorBase = styled__default.default.div.attrs({
|
|
208
247
|
'data-garden-id': COMPONENT_ID$5,
|
|
209
|
-
'data-garden-version': '9.0.0-next.
|
|
248
|
+
'data-garden-version': '9.0.0-next.21'
|
|
210
249
|
}).withConfig({
|
|
211
250
|
displayName: "StyledStatusIndicatorBase",
|
|
212
251
|
componentId: "sc-1rininy-0"
|
|
213
252
|
})(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
214
253
|
StyledStatusIndicatorBase.defaultProps = {
|
|
215
254
|
theme: reactTheming.DEFAULT_THEME,
|
|
216
|
-
size: 'small'
|
|
255
|
+
$size: 'small'
|
|
217
256
|
};
|
|
218
257
|
|
|
219
258
|
const COMPONENT_ID$4 = 'avatars.status_indicator';
|
|
220
259
|
const [xxs, xs, s, m, l] = SIZE;
|
|
221
260
|
const sizeStyles$2 = props => {
|
|
222
|
-
const isVisible = !includes([xxs, xs], props
|
|
261
|
+
const isVisible = !includes([xxs, xs], props.$size);
|
|
223
262
|
const borderWidth = getStatusBorderOffset(props);
|
|
224
263
|
let padding = '0';
|
|
225
|
-
if (props
|
|
264
|
+
if (props.$size === s) {
|
|
226
265
|
padding = polished.math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
|
|
227
|
-
} else if (includes([m, l], props
|
|
266
|
+
} else if (includes([m, l], props.$size)) {
|
|
228
267
|
padding = polished.math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
|
|
229
268
|
}
|
|
230
269
|
return styled.css(["max-width:calc(2em + (", " * 3));box-sizing:content-box;overflow:hidden;text-align:center;text-overflow:ellipsis;white-space:nowrap;font-size:", ";font-weight:", ";& > span{display:", ";padding:0 ", ";max-width:2em;overflow:inherit;text-align:inherit;text-overflow:inherit;white-space:inherit;}& > svg{", "}"], borderWidth, props.theme.fontSizes.xs, props.theme.fontWeights.semibold, isVisible ? 'inline-block' : 'none', padding, !isVisible && 'display: none;');
|
|
231
270
|
};
|
|
232
|
-
const colorStyles$1 =
|
|
233
|
-
|
|
271
|
+
const colorStyles$1 = _ref => {
|
|
272
|
+
let {
|
|
234
273
|
theme,
|
|
235
|
-
type,
|
|
236
|
-
size,
|
|
237
|
-
borderColor,
|
|
238
|
-
surfaceColor
|
|
239
|
-
} =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
274
|
+
$type,
|
|
275
|
+
$size,
|
|
276
|
+
$borderColor,
|
|
277
|
+
$surfaceColor
|
|
278
|
+
} = _ref;
|
|
279
|
+
const shadowSize = $size === xxs ? 'xs' : 'sm';
|
|
280
|
+
let boxShadow;
|
|
281
|
+
if ($type) {
|
|
282
|
+
boxShadow = theme.shadows[shadowSize]($surfaceColor || reactTheming.getColor({
|
|
283
|
+
theme,
|
|
284
|
+
variable: 'background.default'
|
|
285
|
+
}));
|
|
286
|
+
} else {
|
|
287
|
+
boxShadow = theme.shadows[shadowSize]($surfaceColor || theme.palette.white);
|
|
243
288
|
}
|
|
244
|
-
return styled.css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
|
|
289
|
+
return styled.css(["border-color:", ";box-shadow:", ";"], $borderColor, boxShadow);
|
|
245
290
|
};
|
|
246
291
|
const StyledStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
|
|
247
292
|
'data-garden-id': COMPONENT_ID$4,
|
|
248
|
-
'data-garden-version': '9.0.0-next.
|
|
293
|
+
'data-garden-version': '9.0.0-next.21'
|
|
249
294
|
}).withConfig({
|
|
250
295
|
displayName: "StyledStatusIndicator",
|
|
251
296
|
componentId: "sc-16t9if3-0"
|
|
252
297
|
})(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
253
298
|
StyledStatusIndicator.defaultProps = {
|
|
254
|
-
size: 'medium',
|
|
299
|
+
$size: 'medium',
|
|
255
300
|
theme: reactTheming.DEFAULT_THEME
|
|
256
301
|
};
|
|
257
302
|
|
|
@@ -259,7 +304,7 @@ const COMPONENT_ID$3 = 'avatars.avatar';
|
|
|
259
304
|
const badgeStyles = props => {
|
|
260
305
|
const [xxs, xs, s, m, l] = SIZE;
|
|
261
306
|
let position = `${props.theme.space.base * -1}px`;
|
|
262
|
-
switch (props
|
|
307
|
+
switch (props.$size) {
|
|
263
308
|
case s:
|
|
264
309
|
case m:
|
|
265
310
|
position = polished.math(`${position} + 2`);
|
|
@@ -271,14 +316,24 @@ const badgeStyles = props => {
|
|
|
271
316
|
break;
|
|
272
317
|
}
|
|
273
318
|
const animation = styled.keyframes(["0%{transform:scale(.1);}"]);
|
|
274
|
-
return styled.css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props
|
|
319
|
+
return styled.css(["position:absolute;", ":", ";bottom:", ";transition:all ", "s ease-in-out;", ""], props.theme.rtl ? 'left' : 'right', position, position, TRANSITION_DURATION, props.$status === 'active' && styled.css(["animation:", " ", "s ease-in-out;"], animation, TRANSITION_DURATION * 1.5));
|
|
275
320
|
};
|
|
276
|
-
const colorStyles =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
321
|
+
const colorStyles = _ref => {
|
|
322
|
+
let {
|
|
323
|
+
theme,
|
|
324
|
+
$foregroundColor,
|
|
325
|
+
$surfaceColor,
|
|
326
|
+
$backgroundColor,
|
|
327
|
+
$status
|
|
328
|
+
} = _ref;
|
|
329
|
+
const statusColor = getStatusColor(theme, $status);
|
|
330
|
+
const backgroundColor = $backgroundColor || 'transparent';
|
|
331
|
+
const foregroundColor = $foregroundColor || theme.palette.white;
|
|
332
|
+
const surfaceColor = $status ? $surfaceColor || reactTheming.getColor({
|
|
333
|
+
variable: 'background.default',
|
|
334
|
+
theme
|
|
335
|
+
}) : 'transparent';
|
|
336
|
+
return styled.css(["box-shadow:", ";background-color:", ";&&{color:", ";}& > svg,& ", "{color:", ";}"], theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
|
|
282
337
|
};
|
|
283
338
|
const sizeStyles$1 = props => {
|
|
284
339
|
let boxShadow;
|
|
@@ -286,33 +341,33 @@ const sizeStyles$1 = props => {
|
|
|
286
341
|
let size;
|
|
287
342
|
let fontSize;
|
|
288
343
|
let svgSize;
|
|
289
|
-
if (props
|
|
344
|
+
if (props.$size === 'extraextrasmall') {
|
|
290
345
|
boxShadow = `0 0 0 ${polished.math(`${props.theme.shadowWidths.sm} - 1`)}`;
|
|
291
|
-
borderRadius = props
|
|
346
|
+
borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
292
347
|
size = `${props.theme.space.base * 4}px`;
|
|
293
348
|
fontSize = 0;
|
|
294
349
|
svgSize = `${props.theme.space.base * 3}px`;
|
|
295
|
-
} else if (props
|
|
350
|
+
} else if (props.$size === 'extrasmall') {
|
|
296
351
|
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
297
|
-
borderRadius = props
|
|
352
|
+
borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
298
353
|
size = `${props.theme.space.base * 6}px`;
|
|
299
354
|
fontSize = props.theme.fontSizes.sm;
|
|
300
355
|
svgSize = `${props.theme.space.base * 3}px`;
|
|
301
|
-
} else if (props
|
|
356
|
+
} else if (props.$size === 'small') {
|
|
302
357
|
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
303
|
-
borderRadius = props
|
|
358
|
+
borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
|
|
304
359
|
size = `${props.theme.space.base * 8}px`;
|
|
305
360
|
fontSize = props.theme.fontSizes.md;
|
|
306
361
|
svgSize = `${props.theme.space.base * 3}px`;
|
|
307
|
-
} else if (props
|
|
362
|
+
} else if (props.$size === 'large') {
|
|
308
363
|
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
309
|
-
borderRadius = props
|
|
364
|
+
borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} + 1`) : '50%';
|
|
310
365
|
size = `${props.theme.space.base * 12}px`;
|
|
311
366
|
fontSize = props.theme.fontSizes.xl;
|
|
312
367
|
svgSize = `${props.theme.space.base * 6}px`;
|
|
313
368
|
} else {
|
|
314
369
|
boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
|
|
315
|
-
borderRadius = props
|
|
370
|
+
borderRadius = props.$isSystem ? props.theme.borderRadii.md : '50%';
|
|
316
371
|
size = `${props.theme.space.base * 10}px`;
|
|
317
372
|
fontSize = props.theme.fontSizes.lg;
|
|
318
373
|
svgSize = `${props.theme.space.base * 4}px`;
|
|
@@ -321,20 +376,20 @@ const sizeStyles$1 = props => {
|
|
|
321
376
|
};
|
|
322
377
|
const StyledAvatar = styled__default.default.figure.attrs({
|
|
323
378
|
'data-garden-id': COMPONENT_ID$3,
|
|
324
|
-
'data-garden-version': '9.0.0-next.
|
|
379
|
+
'data-garden-version': '9.0.0-next.21'
|
|
325
380
|
}).withConfig({
|
|
326
381
|
displayName: "StyledAvatar",
|
|
327
382
|
componentId: "sc-608m04-0"
|
|
328
383
|
})(["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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
329
384
|
StyledAvatar.defaultProps = {
|
|
330
|
-
size: 'medium',
|
|
385
|
+
$size: 'medium',
|
|
331
386
|
theme: reactTheming.DEFAULT_THEME
|
|
332
387
|
};
|
|
333
388
|
|
|
334
389
|
const COMPONENT_ID$2 = 'avatars.status-indicator.status';
|
|
335
390
|
const StyledStandaloneStatus = styled__default.default.figure.attrs({
|
|
336
391
|
'data-garden-id': COMPONENT_ID$2,
|
|
337
|
-
'data-garden-version': '9.0.0-next.
|
|
392
|
+
'data-garden-version': '9.0.0-next.21'
|
|
338
393
|
}).withConfig({
|
|
339
394
|
displayName: "StyledStandaloneStatus",
|
|
340
395
|
componentId: "sc-1ow4nfj-0"
|
|
@@ -350,7 +405,7 @@ function sizeStyles(props) {
|
|
|
350
405
|
}
|
|
351
406
|
const StyledStandaloneStatusCaption = styled__default.default.figcaption.attrs({
|
|
352
407
|
'data-garden-id': COMPONENT_ID$1,
|
|
353
|
-
'data-garden-version': '9.0.0-next.
|
|
408
|
+
'data-garden-version': '9.0.0-next.21'
|
|
354
409
|
}).withConfig({
|
|
355
410
|
displayName: "StyledStandaloneStatusCaption",
|
|
356
411
|
componentId: "sc-aalyk1-0"
|
|
@@ -362,17 +417,17 @@ StyledStandaloneStatusCaption.defaultProps = {
|
|
|
362
417
|
const COMPONENT_ID = 'avatars.status-indicator.indicator';
|
|
363
418
|
const StyledStandaloneStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
|
|
364
419
|
'data-garden-id': COMPONENT_ID,
|
|
365
|
-
'data-garden-version': '9.0.0-next.
|
|
420
|
+
'data-garden-version': '9.0.0-next.21'
|
|
366
421
|
}).withConfig({
|
|
367
422
|
displayName: "StyledStandaloneStatusIndicator",
|
|
368
423
|
componentId: "sc-1xt1heq-0"
|
|
369
424
|
})(["position:relative;box-sizing:content-box;margin-top:", ";", ";"], props => `calc((${props.theme.lineHeights.md} - ${getStatusSize(props, '0')}) / 2)`, props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
|
|
370
425
|
StyledStandaloneStatusIndicator.defaultProps = {
|
|
371
|
-
type: 'offline',
|
|
426
|
+
$type: 'offline',
|
|
372
427
|
theme: reactTheming.DEFAULT_THEME
|
|
373
428
|
};
|
|
374
429
|
|
|
375
|
-
const TextComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledText,
|
|
430
|
+
const TextComponent = React.forwardRef((props, ref) => React__namespace.default.createElement(StyledText, Object.assign({
|
|
376
431
|
ref: ref
|
|
377
432
|
}, props)));
|
|
378
433
|
TextComponent.displayName = 'Avatar.Text';
|
|
@@ -407,20 +462,20 @@ const AvatarComponent = React.forwardRef((_ref, ref) => {
|
|
|
407
462
|
}, [computedStatus, badge]);
|
|
408
463
|
const shouldValidate = computedStatus !== undefined;
|
|
409
464
|
const statusLabel = reactTheming.useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
|
|
410
|
-
return React__namespace.default.createElement(StyledAvatar,
|
|
465
|
+
return React__namespace.default.createElement(StyledAvatar, Object.assign({
|
|
411
466
|
ref: ref,
|
|
412
|
-
isSystem: isSystem,
|
|
413
|
-
size: size,
|
|
414
|
-
status: computedStatus,
|
|
415
|
-
surfaceColor: surfaceColor,
|
|
416
|
-
backgroundColor: backgroundColor,
|
|
417
|
-
foregroundColor: foregroundColor,
|
|
467
|
+
$isSystem: isSystem,
|
|
468
|
+
$size: size,
|
|
469
|
+
$status: computedStatus,
|
|
470
|
+
$surfaceColor: surfaceColor,
|
|
471
|
+
$backgroundColor: backgroundColor,
|
|
472
|
+
$foregroundColor: foregroundColor,
|
|
418
473
|
"aria-atomic": "true",
|
|
419
474
|
"aria-live": "polite"
|
|
420
475
|
}, props), React.Children.only(children), computedStatus && React__namespace.default.createElement(StyledStatusIndicator, {
|
|
421
|
-
size: size,
|
|
422
|
-
type: computedStatus,
|
|
423
|
-
surfaceColor: surfaceColor,
|
|
476
|
+
$size: size,
|
|
477
|
+
$type: computedStatus,
|
|
478
|
+
$surfaceColor: surfaceColor,
|
|
424
479
|
"aria-label": statusLabel,
|
|
425
480
|
as: "figcaption"
|
|
426
481
|
}, computedStatus === 'active' ? React__namespace.default.createElement("span", {
|
|
@@ -467,13 +522,13 @@ const StatusIndicator = React.forwardRef((_ref, ref) => {
|
|
|
467
522
|
'aria-label': label
|
|
468
523
|
}, 'aria-label', defaultLabel);
|
|
469
524
|
return (
|
|
470
|
-
React__namespace.default.createElement(StyledStandaloneStatus,
|
|
525
|
+
React__namespace.default.createElement(StyledStandaloneStatus, Object.assign({
|
|
471
526
|
role: "status",
|
|
472
527
|
ref: ref
|
|
473
528
|
}, props), React__namespace.default.createElement(StyledStandaloneStatusIndicator, {
|
|
474
529
|
role: "img",
|
|
475
|
-
type: type,
|
|
476
|
-
size: isCompact ? 'small' : 'medium',
|
|
530
|
+
$type: type,
|
|
531
|
+
$size: isCompact ? 'small' : 'medium',
|
|
477
532
|
"aria-label": ariaLabel
|
|
478
533
|
}, type === 'away' ? React__namespace.default.createElement(ClockIcon, {
|
|
479
534
|
"data-icon-status": type,
|
|
@@ -6,8 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { DefaultTheme } from 'styled-components';
|
|
8
8
|
import { IAvatarProps } from '../types';
|
|
9
|
-
export interface IStyledAvatarProps
|
|
10
|
-
status?: IAvatarProps['status'] | 'active';
|
|
9
|
+
export interface IStyledAvatarProps {
|
|
10
|
+
$status?: IAvatarProps['status'] | 'active';
|
|
11
|
+
$backgroundColor?: IAvatarProps['backgroundColor'];
|
|
12
|
+
$foregroundColor?: IAvatarProps['foregroundColor'];
|
|
13
|
+
$surfaceColor?: IAvatarProps['surfaceColor'];
|
|
14
|
+
$isSystem?: IAvatarProps['isSystem'];
|
|
15
|
+
$size?: IAvatarProps['size'];
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* Accepts all `<figure>` props
|
|
@@ -8,8 +8,10 @@ import { DefaultTheme } from 'styled-components';
|
|
|
8
8
|
import { IAvatarProps } from '../types';
|
|
9
9
|
import { IStyledStatusIndicatorProps } from './utility';
|
|
10
10
|
export interface IStatusIndicatorProps extends Omit<IAvatarProps, 'badge' | 'isSystem' | 'status'> {
|
|
11
|
-
readonly type?: IStyledStatusIndicatorProps['type'];
|
|
12
|
-
borderColor?: string;
|
|
11
|
+
readonly $type?: IStyledStatusIndicatorProps['$type'];
|
|
12
|
+
$borderColor?: string;
|
|
13
|
+
$surfaceColor?: IAvatarProps['surfaceColor'];
|
|
14
|
+
$size?: IAvatarProps['size'];
|
|
13
15
|
}
|
|
14
16
|
export declare const StyledStatusIndicator: import("styled-components").StyledComponent<"div", DefaultTheme, {
|
|
15
17
|
'data-garden-id': string;
|
|
@@ -8,10 +8,10 @@ import { ThemeProps, DefaultTheme } from 'styled-components';
|
|
|
8
8
|
import { IAvatarProps } from '../types';
|
|
9
9
|
export declare const TRANSITION_DURATION = 0.25;
|
|
10
10
|
export interface IStyledStatusIndicatorProps extends ThemeProps<DefaultTheme> {
|
|
11
|
-
readonly size?: IAvatarProps['size'];
|
|
12
|
-
readonly type?: IAvatarProps['status'] | 'active';
|
|
11
|
+
readonly $size?: IAvatarProps['size'];
|
|
12
|
+
readonly $type?: IAvatarProps['status'] | 'active';
|
|
13
13
|
}
|
|
14
|
-
export declare function getStatusColor(
|
|
14
|
+
export declare function getStatusColor(theme: IStyledStatusIndicatorProps['theme'], type?: IStyledStatusIndicatorProps['$type']): string;
|
|
15
15
|
export declare function getStatusBorderOffset(props: IStyledStatusIndicatorProps): string;
|
|
16
16
|
export declare function getStatusSize(props: IStyledStatusIndicatorProps, offset: string): string;
|
|
17
17
|
export declare function includes<T extends U, U>(array: readonly T[], element: U): element is T;
|
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.21",
|
|
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
|
],
|
|
@@ -21,18 +21,19 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"polished": "^4.
|
|
24
|
+
"polished": "^4.3.1",
|
|
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
|
-
"styled-components": "^5.1
|
|
31
|
+
"styled-components": "^5.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@zendeskgarden/react-
|
|
35
|
-
"@zendeskgarden/
|
|
34
|
+
"@zendeskgarden/react-dropdowns": "^9.0.0-next.21",
|
|
35
|
+
"@zendeskgarden/react-theming": "^9.0.0-next.21",
|
|
36
|
+
"@zendeskgarden/svg-icons": "7.1.1"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
38
39
|
"components",
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"access": "public"
|
|
45
46
|
},
|
|
46
47
|
"zendeskgarden:src": "src/index.ts",
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a245ce2b794ea65142174a6a1f855a111b2677a2"
|
|
48
49
|
}
|