@zendeskgarden/react-avatars 9.0.0-next.17 → 9.0.0-next.19

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.
@@ -51,18 +51,18 @@ const AvatarComponent = forwardRef((_ref, ref) => {
51
51
  const statusLabel = useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
52
52
  return React__default.createElement(StyledAvatar, Object.assign({
53
53
  ref: ref,
54
- isSystem: isSystem,
55
- size: size,
56
- status: computedStatus,
57
- surfaceColor: surfaceColor,
58
- backgroundColor: backgroundColor,
59
- foregroundColor: foregroundColor,
54
+ $isSystem: isSystem,
55
+ $size: size,
56
+ $status: computedStatus,
57
+ $surfaceColor: surfaceColor,
58
+ $backgroundColor: backgroundColor,
59
+ $foregroundColor: foregroundColor,
60
60
  "aria-atomic": "true",
61
61
  "aria-live": "polite"
62
62
  }, props), Children.only(children), computedStatus && React__default.createElement(StyledStatusIndicator, {
63
- size: size,
64
- type: computedStatus,
65
- surfaceColor: surfaceColor,
63
+ $size: size,
64
+ $type: computedStatus,
65
+ $surfaceColor: surfaceColor,
66
66
  "aria-label": statusLabel,
67
67
  as: "figcaption"
68
68
  }, computedStatus === 'active' ? React__default.createElement("span", {
@@ -43,8 +43,8 @@ const StatusIndicator = forwardRef((_ref, ref) => {
43
43
  ref: ref
44
44
  }, props), React__default.createElement(StyledStandaloneStatusIndicator, {
45
45
  role: "img",
46
- type: type,
47
- size: isCompact ? 'small' : 'medium',
46
+ $type: type,
47
+ $size: isCompact ? 'small' : 'medium',
48
48
  "aria-label": ariaLabel
49
49
  }, type === 'away' ? React__default.createElement(ClockIcon, {
50
50
  "data-icon-status": type,
@@ -5,7 +5,7 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled, { keyframes, css } from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
9
  import { math } from 'polished';
10
10
  import { SIZE } from '../types/index.js';
11
11
  import { StyledText } from './StyledText.js';
@@ -16,7 +16,7 @@ const COMPONENT_ID = 'avatars.avatar';
16
16
  const badgeStyles = props => {
17
17
  const [xxs, xs, s, m, l] = SIZE;
18
18
  let position = `${props.theme.space.base * -1}px`;
19
- switch (props.size) {
19
+ switch (props.$size) {
20
20
  case s:
21
21
  case m:
22
22
  position = math(`${position} + 2`);
@@ -28,14 +28,24 @@ const badgeStyles = props => {
28
28
  break;
29
29
  }
30
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));
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
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);
33
+ const colorStyles = _ref => {
34
+ let {
35
+ theme,
36
+ $foregroundColor,
37
+ $surfaceColor,
38
+ $backgroundColor,
39
+ $status
40
+ } = _ref;
41
+ const statusColor = getStatusColor(theme, $status);
42
+ const backgroundColor = $backgroundColor || 'transparent';
43
+ const foregroundColor = $foregroundColor || theme.palette.white;
44
+ const surfaceColor = $status ? $surfaceColor || getColor({
45
+ variable: 'background.default',
46
+ theme
47
+ }) : 'transparent';
48
+ return css(["box-shadow:", ";background-color:", ";&&{color:", ";}& > svg,& ", "{color:", ";}"], theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
39
49
  };
40
50
  const sizeStyles = props => {
41
51
  let boxShadow;
@@ -43,33 +53,33 @@ const sizeStyles = props => {
43
53
  let size;
44
54
  let fontSize;
45
55
  let svgSize;
46
- if (props.size === 'extraextrasmall') {
56
+ if (props.$size === 'extraextrasmall') {
47
57
  boxShadow = `0 0 0 ${math(`${props.theme.shadowWidths.sm} - 1`)}`;
48
- borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
58
+ borderRadius = props.$isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
49
59
  size = `${props.theme.space.base * 4}px`;
50
60
  fontSize = 0;
51
61
  svgSize = `${props.theme.space.base * 3}px`;
52
- } else if (props.size === 'extrasmall') {
62
+ } else if (props.$size === 'extrasmall') {
53
63
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
54
- borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
64
+ borderRadius = props.$isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
55
65
  size = `${props.theme.space.base * 6}px`;
56
66
  fontSize = props.theme.fontSizes.sm;
57
67
  svgSize = `${props.theme.space.base * 3}px`;
58
- } else if (props.size === 'small') {
68
+ } else if (props.$size === 'small') {
59
69
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
60
- borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
70
+ borderRadius = props.$isSystem ? math(`${props.theme.borderRadii.md} - 1`) : '50%';
61
71
  size = `${props.theme.space.base * 8}px`;
62
72
  fontSize = props.theme.fontSizes.md;
63
73
  svgSize = `${props.theme.space.base * 3}px`;
64
- } else if (props.size === 'large') {
74
+ } else if (props.$size === 'large') {
65
75
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
66
- borderRadius = props.isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
76
+ borderRadius = props.$isSystem ? math(`${props.theme.borderRadii.md} + 1`) : '50%';
67
77
  size = `${props.theme.space.base * 12}px`;
68
78
  fontSize = props.theme.fontSizes.xl;
69
79
  svgSize = `${props.theme.space.base * 6}px`;
70
80
  } else {
71
81
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
72
- borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
82
+ borderRadius = props.$isSystem ? props.theme.borderRadii.md : '50%';
73
83
  size = `${props.theme.space.base * 10}px`;
74
84
  fontSize = props.theme.fontSizes.lg;
75
85
  svgSize = `${props.theme.space.base * 4}px`;
@@ -78,13 +88,13 @@ const sizeStyles = props => {
78
88
  };
79
89
  const StyledAvatar = styled.figure.attrs({
80
90
  'data-garden-id': COMPONENT_ID,
81
- 'data-garden-version': '9.0.0-next.17'
91
+ 'data-garden-version': '9.0.0-next.19'
82
92
  }).withConfig({
83
93
  displayName: "StyledAvatar",
84
94
  componentId: "sc-608m04-0"
85
95
  })(["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
96
  StyledAvatar.defaultProps = {
87
- size: 'medium',
97
+ $size: 'medium',
88
98
  theme: DEFAULT_THEME
89
99
  };
90
100
 
@@ -11,7 +11,7 @@ import { TRANSITION_DURATION } from './utility.js';
11
11
  const COMPONENT_ID = 'avatars.status-indicator.status';
12
12
  const StyledStandaloneStatus = styled.figure.attrs({
13
13
  'data-garden-id': COMPONENT_ID,
14
- 'data-garden-version': '9.0.0-next.17'
14
+ 'data-garden-version': '9.0.0-next.19'
15
15
  }).withConfig({
16
16
  displayName: "StyledStandaloneStatus",
17
17
  componentId: "sc-1ow4nfj-0"
@@ -14,7 +14,7 @@ function sizeStyles(props) {
14
14
  }
15
15
  const StyledStandaloneStatusCaption = styled.figcaption.attrs({
16
16
  'data-garden-id': COMPONENT_ID,
17
- 'data-garden-version': '9.0.0-next.17'
17
+ 'data-garden-version': '9.0.0-next.19'
18
18
  }).withConfig({
19
19
  displayName: "StyledStandaloneStatusCaption",
20
20
  componentId: "sc-aalyk1-0"
@@ -12,13 +12,13 @@ import { StyledStatusIndicatorBase } from './StyledStatusIndicatorBase.js';
12
12
  const COMPONENT_ID = 'avatars.status-indicator.indicator';
13
13
  const StyledStandaloneStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
14
14
  'data-garden-id': COMPONENT_ID,
15
- 'data-garden-version': '9.0.0-next.17'
15
+ 'data-garden-version': '9.0.0-next.19'
16
16
  }).withConfig({
17
17
  displayName: "StyledStandaloneStatusIndicator",
18
18
  componentId: "sc-1xt1heq-0"
19
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
20
  StyledStandaloneStatusIndicator.defaultProps = {
21
- type: 'offline',
21
+ $type: 'offline',
22
22
  theme: DEFAULT_THEME
23
23
  };
24
24
 
@@ -5,7 +5,7 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled, { css } from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
9
  import { math } from 'polished';
10
10
  import { SIZE } from '../types/index.js';
11
11
  import { StyledStatusIndicatorBase } from './StyledStatusIndicatorBase.js';
@@ -14,39 +14,45 @@ import { includes, getStatusBorderOffset } from './utility.js';
14
14
  const COMPONENT_ID = 'avatars.status_indicator';
15
15
  const [xxs, xs, s, m, l] = SIZE;
16
16
  const sizeStyles = props => {
17
- const isVisible = !includes([xxs, xs], props.size);
17
+ const isVisible = !includes([xxs, xs], props.$size);
18
18
  const borderWidth = getStatusBorderOffset(props);
19
19
  let padding = '0';
20
- if (props.size === s) {
20
+ if (props.$size === s) {
21
21
  padding = math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
22
- } else if (includes([m, l], props.size)) {
22
+ } else if (includes([m, l], props.$size)) {
23
23
  padding = math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
24
24
  }
25
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
26
  };
27
- const colorStyles = props => {
28
- const {
27
+ const colorStyles = _ref => {
28
+ let {
29
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');
30
+ $type,
31
+ $size,
32
+ $borderColor,
33
+ $surfaceColor
34
+ } = _ref;
35
+ const shadowSize = $size === xxs ? 'xs' : 'sm';
36
+ let boxShadow;
37
+ if ($type) {
38
+ boxShadow = theme.shadows[shadowSize]($surfaceColor || getColor({
39
+ theme,
40
+ variable: 'background.default'
41
+ }));
42
+ } else {
43
+ boxShadow = theme.shadows[shadowSize]($surfaceColor || theme.palette.white);
38
44
  }
39
- return css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
45
+ return css(["border-color:", ";box-shadow:", ";"], $borderColor, boxShadow);
40
46
  };
41
47
  const StyledStatusIndicator = styled(StyledStatusIndicatorBase).attrs({
42
48
  'data-garden-id': COMPONENT_ID,
43
- 'data-garden-version': '9.0.0-next.17'
49
+ 'data-garden-version': '9.0.0-next.19'
44
50
  }).withConfig({
45
51
  displayName: "StyledStatusIndicator",
46
52
  componentId: "sc-16t9if3-0"
47
53
  })(["", " ", " ", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
48
54
  StyledStatusIndicator.defaultProps = {
49
- size: 'medium',
55
+ $size: 'medium',
50
56
  theme: DEFAULT_THEME
51
57
  };
52
58
 
@@ -5,7 +5,7 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled, { keyframes, css } from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
9
  import { getStatusBorderOffset, getStatusSize, TRANSITION_DURATION, getStatusColor } from './utility.js';
10
10
 
11
11
  const COMPONENT_ID = 'avatars.status-indicator.base';
@@ -15,25 +15,39 @@ const sizeStyles = props => {
15
15
  const size = getStatusSize(props, offset);
16
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
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;
18
+ const colorStyles = _ref => {
19
+ let {
20
+ theme,
21
+ $type
22
+ } = _ref;
23
+ const foregroundColor = getColor({
24
+ variable: 'foreground.onEmphasis',
25
+ theme
26
+ });
27
+ let backgroundColor;
28
+ let borderColor;
29
+ if ($type === 'offline') {
30
+ borderColor = getStatusColor(theme, $type);
31
+ backgroundColor = getColor({
32
+ variable: 'background.default',
33
+ theme
34
+ });
35
+ } else {
36
+ backgroundColor = getStatusColor(theme, $type);
37
+ borderColor = backgroundColor;
24
38
  }
25
- return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
39
+ return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, foregroundColor);
26
40
  };
27
41
  const StyledStatusIndicatorBase = styled.div.attrs({
28
42
  'data-garden-id': COMPONENT_ID,
29
- 'data-garden-version': '9.0.0-next.17'
43
+ 'data-garden-version': '9.0.0-next.19'
30
44
  }).withConfig({
31
45
  displayName: "StyledStatusIndicatorBase",
32
46
  componentId: "sc-1rininy-0"
33
47
  })(["transition:inherit;", " ", " ", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
34
48
  StyledStatusIndicatorBase.defaultProps = {
35
49
  theme: DEFAULT_THEME,
36
- size: 'small'
50
+ $size: 'small'
37
51
  };
38
52
 
39
53
  export { StyledStatusIndicatorBase };
@@ -10,7 +10,7 @@ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-the
10
10
  const COMPONENT_ID = 'avatars.text';
11
11
  const StyledText = styled.span.attrs({
12
12
  'data-garden-id': COMPONENT_ID,
13
- 'data-garden-version': '9.0.0-next.17'
13
+ 'data-garden-version': '9.0.0-next.19'
14
14
  }).withConfig({
15
15
  displayName: "StyledText",
16
16
  componentId: "sc-1a6hivh-0"
@@ -4,34 +4,75 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { getColorV8 } from '@zendeskgarden/react-theming';
7
+ import { getColor } from '@zendeskgarden/react-theming';
8
8
  import { math } from 'polished';
9
9
  import { SIZE } from '../types/index.js';
10
10
 
11
11
  const [xxs, xs, s, m, l] = SIZE;
12
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';
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';
27
63
  }
64
+ const colorArgs = StatusColorParams[type];
65
+ return colorArgs ? getColor({
66
+ ...colorArgs,
67
+ theme
68
+ }) : 'transparent';
28
69
  }
29
70
  function getStatusBorderOffset(props) {
30
- return props.size === xxs ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
71
+ return props.$size === xxs ? math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
31
72
  }
32
73
  function getStatusSize(props, offset) {
33
- const isActive = props.type === 'active';
34
- switch (props.size) {
74
+ const isActive = props.$type === 'active';
75
+ switch (props.$size) {
35
76
  case xxs:
36
77
  return math(`${props.theme.space.base}px - ${offset}`);
37
78
  case xs:
package/dist/index.cjs.js CHANGED
@@ -122,7 +122,7 @@ const STATUS = ['available', 'away', 'transfers', 'offline'];
122
122
  const COMPONENT_ID$6 = 'avatars.text';
123
123
  const StyledText = styled__default.default.span.attrs({
124
124
  'data-garden-id': COMPONENT_ID$6,
125
- 'data-garden-version': '9.0.0-next.17'
125
+ 'data-garden-version': '9.0.0-next.19'
126
126
  }).withConfig({
127
127
  displayName: "StyledText",
128
128
  componentId: "sc-1a6hivh-0"
@@ -133,28 +133,69 @@ StyledText.defaultProps = {
133
133
 
134
134
  const [xxs$1, xs$1, s$1, m$1, l$1] = SIZE;
135
135
  const TRANSITION_DURATION = 0.25;
136
- function getStatusColor(type, theme) {
137
- switch (type) {
138
- case 'active':
139
- return reactTheming.getColorV8('crimson', 400, theme);
140
- case 'available':
141
- return reactTheming.getColorV8('mint', 400, theme);
142
- case 'away':
143
- return reactTheming.getColorV8('orange', 400, theme);
144
- case 'transfers':
145
- return reactTheming.getColorV8('azure', 400, theme);
146
- case 'offline':
147
- return reactTheming.getColorV8('grey', 500, theme);
148
- default:
149
- return 'transparent';
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
+ }
150
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';
151
192
  }
152
193
  function getStatusBorderOffset(props) {
153
- return props.size === xxs$1 ? polished.math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
194
+ return props.$size === xxs$1 ? polished.math(`${props.theme.shadowWidths.sm} - 1`) : props.theme.shadowWidths.sm;
154
195
  }
155
196
  function getStatusSize(props, offset) {
156
- const isActive = props.type === 'active';
157
- switch (props.size) {
197
+ const isActive = props.$type === 'active';
198
+ switch (props.$size) {
158
199
  case xxs$1:
159
200
  return polished.math(`${props.theme.space.base}px - ${offset}`);
160
201
  case xs$1:
@@ -179,63 +220,83 @@ const sizeStyles$3 = props => {
179
220
  const size = getStatusSize(props, offset);
180
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);
181
222
  };
182
- const colorStyles$2 = props => {
183
- let backgroundColor = getStatusColor(props.type, props.theme);
184
- let borderColor = backgroundColor;
185
- if (props.type === 'offline') {
186
- borderColor = getStatusColor(props.type, props.theme);
187
- backgroundColor = props.theme.palette.white;
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;
188
243
  }
189
- return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, props.theme.palette.white);
244
+ return styled.css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, foregroundColor);
190
245
  };
191
246
  const StyledStatusIndicatorBase = styled__default.default.div.attrs({
192
247
  'data-garden-id': COMPONENT_ID$5,
193
- 'data-garden-version': '9.0.0-next.17'
248
+ 'data-garden-version': '9.0.0-next.19'
194
249
  }).withConfig({
195
250
  displayName: "StyledStatusIndicatorBase",
196
251
  componentId: "sc-1rininy-0"
197
252
  })(["transition:inherit;", " ", " ", ";"], sizeStyles$3, colorStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
198
253
  StyledStatusIndicatorBase.defaultProps = {
199
254
  theme: reactTheming.DEFAULT_THEME,
200
- size: 'small'
255
+ $size: 'small'
201
256
  };
202
257
 
203
258
  const COMPONENT_ID$4 = 'avatars.status_indicator';
204
259
  const [xxs, xs, s, m, l] = SIZE;
205
260
  const sizeStyles$2 = props => {
206
- const isVisible = !includes([xxs, xs], props.size);
261
+ const isVisible = !includes([xxs, xs], props.$size);
207
262
  const borderWidth = getStatusBorderOffset(props);
208
263
  let padding = '0';
209
- if (props.size === s) {
264
+ if (props.$size === s) {
210
265
  padding = polished.math(`${props.theme.space.base + 1}px - (${borderWidth} * 2)`);
211
- } else if (includes([m, l], props.size)) {
266
+ } else if (includes([m, l], props.$size)) {
212
267
  padding = polished.math(`${props.theme.space.base + 3}px - (${borderWidth} * 2)`);
213
268
  }
214
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;');
215
270
  };
216
- const colorStyles$1 = props => {
217
- const {
271
+ const colorStyles$1 = _ref => {
272
+ let {
218
273
  theme,
219
- type,
220
- size,
221
- borderColor,
222
- surfaceColor
223
- } = props;
224
- let boxShadow = theme.shadows.sm(surfaceColor || (type ? reactTheming.getColorV8('background', 600 , theme) : theme.palette.white));
225
- if (size === xxs) {
226
- boxShadow = boxShadow.replace(theme.shadowWidths.sm, '1px');
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);
227
288
  }
228
- return styled.css(["border-color:", ";box-shadow:", ";"], borderColor, boxShadow);
289
+ return styled.css(["border-color:", ";box-shadow:", ";"], $borderColor, boxShadow);
229
290
  };
230
291
  const StyledStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
231
292
  'data-garden-id': COMPONENT_ID$4,
232
- 'data-garden-version': '9.0.0-next.17'
293
+ 'data-garden-version': '9.0.0-next.19'
233
294
  }).withConfig({
234
295
  displayName: "StyledStatusIndicator",
235
296
  componentId: "sc-16t9if3-0"
236
297
  })(["", " ", " ", ";"], sizeStyles$2, colorStyles$1, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
237
298
  StyledStatusIndicator.defaultProps = {
238
- size: 'medium',
299
+ $size: 'medium',
239
300
  theme: reactTheming.DEFAULT_THEME
240
301
  };
241
302
 
@@ -243,7 +304,7 @@ const COMPONENT_ID$3 = 'avatars.avatar';
243
304
  const badgeStyles = props => {
244
305
  const [xxs, xs, s, m, l] = SIZE;
245
306
  let position = `${props.theme.space.base * -1}px`;
246
- switch (props.size) {
307
+ switch (props.$size) {
247
308
  case s:
248
309
  case m:
249
310
  position = polished.math(`${position} + 2`);
@@ -255,14 +316,24 @@ const badgeStyles = props => {
255
316
  break;
256
317
  }
257
318
  const animation = styled.keyframes(["0%{transform:scale(.1);}"]);
258
- 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));
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));
259
320
  };
260
- const colorStyles = props => {
261
- const statusColor = getStatusColor(props.status, props.theme);
262
- const backgroundColor = props.backgroundColor || 'transparent';
263
- const foregroundColor = props.foregroundColor || props.theme.palette.white;
264
- const surfaceColor = props.status ? props.surfaceColor || reactTheming.getColorV8('background', 600 , props.theme) : 'transparent';
265
- return styled.css(["box-shadow:", ";background-color:", ";color:", ";& > svg,& ", "{color:", ";}"], props.theme.shadows.sm(statusColor), backgroundColor, surfaceColor, StyledText, foregroundColor);
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);
266
337
  };
267
338
  const sizeStyles$1 = props => {
268
339
  let boxShadow;
@@ -270,33 +341,33 @@ const sizeStyles$1 = props => {
270
341
  let size;
271
342
  let fontSize;
272
343
  let svgSize;
273
- if (props.size === 'extraextrasmall') {
344
+ if (props.$size === 'extraextrasmall') {
274
345
  boxShadow = `0 0 0 ${polished.math(`${props.theme.shadowWidths.sm} - 1`)}`;
275
- borderRadius = props.isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
346
+ borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
276
347
  size = `${props.theme.space.base * 4}px`;
277
348
  fontSize = 0;
278
349
  svgSize = `${props.theme.space.base * 3}px`;
279
- } else if (props.size === 'extrasmall') {
350
+ } else if (props.$size === 'extrasmall') {
280
351
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
281
- borderRadius = props.isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
352
+ borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
282
353
  size = `${props.theme.space.base * 6}px`;
283
354
  fontSize = props.theme.fontSizes.sm;
284
355
  svgSize = `${props.theme.space.base * 3}px`;
285
- } else if (props.size === 'small') {
356
+ } else if (props.$size === 'small') {
286
357
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
287
- borderRadius = props.isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
358
+ borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} - 1`) : '50%';
288
359
  size = `${props.theme.space.base * 8}px`;
289
360
  fontSize = props.theme.fontSizes.md;
290
361
  svgSize = `${props.theme.space.base * 3}px`;
291
- } else if (props.size === 'large') {
362
+ } else if (props.$size === 'large') {
292
363
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
293
- borderRadius = props.isSystem ? polished.math(`${props.theme.borderRadii.md} + 1`) : '50%';
364
+ borderRadius = props.$isSystem ? polished.math(`${props.theme.borderRadii.md} + 1`) : '50%';
294
365
  size = `${props.theme.space.base * 12}px`;
295
366
  fontSize = props.theme.fontSizes.xl;
296
367
  svgSize = `${props.theme.space.base * 6}px`;
297
368
  } else {
298
369
  boxShadow = `inset 0 0 0 ${props.theme.shadowWidths.sm}`;
299
- borderRadius = props.isSystem ? props.theme.borderRadii.md : '50%';
370
+ borderRadius = props.$isSystem ? props.theme.borderRadii.md : '50%';
300
371
  size = `${props.theme.space.base * 10}px`;
301
372
  fontSize = props.theme.fontSizes.lg;
302
373
  svgSize = `${props.theme.space.base * 4}px`;
@@ -305,20 +376,20 @@ const sizeStyles$1 = props => {
305
376
  };
306
377
  const StyledAvatar = styled__default.default.figure.attrs({
307
378
  'data-garden-id': COMPONENT_ID$3,
308
- 'data-garden-version': '9.0.0-next.17'
379
+ 'data-garden-version': '9.0.0-next.19'
309
380
  }).withConfig({
310
381
  displayName: "StyledAvatar",
311
382
  componentId: "sc-608m04-0"
312
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));
313
384
  StyledAvatar.defaultProps = {
314
- size: 'medium',
385
+ $size: 'medium',
315
386
  theme: reactTheming.DEFAULT_THEME
316
387
  };
317
388
 
318
389
  const COMPONENT_ID$2 = 'avatars.status-indicator.status';
319
390
  const StyledStandaloneStatus = styled__default.default.figure.attrs({
320
391
  'data-garden-id': COMPONENT_ID$2,
321
- 'data-garden-version': '9.0.0-next.17'
392
+ 'data-garden-version': '9.0.0-next.19'
322
393
  }).withConfig({
323
394
  displayName: "StyledStandaloneStatus",
324
395
  componentId: "sc-1ow4nfj-0"
@@ -334,7 +405,7 @@ function sizeStyles(props) {
334
405
  }
335
406
  const StyledStandaloneStatusCaption = styled__default.default.figcaption.attrs({
336
407
  'data-garden-id': COMPONENT_ID$1,
337
- 'data-garden-version': '9.0.0-next.17'
408
+ 'data-garden-version': '9.0.0-next.19'
338
409
  }).withConfig({
339
410
  displayName: "StyledStandaloneStatusCaption",
340
411
  componentId: "sc-aalyk1-0"
@@ -346,13 +417,13 @@ StyledStandaloneStatusCaption.defaultProps = {
346
417
  const COMPONENT_ID = 'avatars.status-indicator.indicator';
347
418
  const StyledStandaloneStatusIndicator = styled__default.default(StyledStatusIndicatorBase).attrs({
348
419
  'data-garden-id': COMPONENT_ID,
349
- 'data-garden-version': '9.0.0-next.17'
420
+ 'data-garden-version': '9.0.0-next.19'
350
421
  }).withConfig({
351
422
  displayName: "StyledStandaloneStatusIndicator",
352
423
  componentId: "sc-1xt1heq-0"
353
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));
354
425
  StyledStandaloneStatusIndicator.defaultProps = {
355
- type: 'offline',
426
+ $type: 'offline',
356
427
  theme: reactTheming.DEFAULT_THEME
357
428
  };
358
429
 
@@ -393,18 +464,18 @@ const AvatarComponent = React.forwardRef((_ref, ref) => {
393
464
  const statusLabel = reactTheming.useText(AvatarComponent, props, 'statusLabel', defaultStatusLabel, shouldValidate);
394
465
  return React__namespace.default.createElement(StyledAvatar, Object.assign({
395
466
  ref: ref,
396
- isSystem: isSystem,
397
- size: size,
398
- status: computedStatus,
399
- surfaceColor: surfaceColor,
400
- backgroundColor: backgroundColor,
401
- foregroundColor: foregroundColor,
467
+ $isSystem: isSystem,
468
+ $size: size,
469
+ $status: computedStatus,
470
+ $surfaceColor: surfaceColor,
471
+ $backgroundColor: backgroundColor,
472
+ $foregroundColor: foregroundColor,
402
473
  "aria-atomic": "true",
403
474
  "aria-live": "polite"
404
475
  }, props), React.Children.only(children), computedStatus && React__namespace.default.createElement(StyledStatusIndicator, {
405
- size: size,
406
- type: computedStatus,
407
- surfaceColor: surfaceColor,
476
+ $size: size,
477
+ $type: computedStatus,
478
+ $surfaceColor: surfaceColor,
408
479
  "aria-label": statusLabel,
409
480
  as: "figcaption"
410
481
  }, computedStatus === 'active' ? React__namespace.default.createElement("span", {
@@ -456,8 +527,8 @@ const StatusIndicator = React.forwardRef((_ref, ref) => {
456
527
  ref: ref
457
528
  }, props), React__namespace.default.createElement(StyledStandaloneStatusIndicator, {
458
529
  role: "img",
459
- type: type,
460
- size: isCompact ? 'small' : 'medium',
530
+ $type: type,
531
+ $size: isCompact ? 'small' : 'medium',
461
532
  "aria-label": ariaLabel
462
533
  }, type === 'away' ? React__namespace.default.createElement(ClockIcon, {
463
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 extends Pick<IAvatarProps, 'backgroundColor' | 'foregroundColor' | 'surfaceColor' | 'isSystem' | 'size'> {
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(type?: IStyledStatusIndicatorProps['type'], theme?: IStyledStatusIndicatorProps['theme']): string;
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.17",
3
+ "version": "9.0.0-next.19",
4
4
  "description": "Components relating to avatars in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -31,7 +31,8 @@
31
31
  "styled-components": "^5.3.1"
32
32
  },
33
33
  "devDependencies": {
34
- "@zendeskgarden/react-theming": "^9.0.0-next.17",
34
+ "@zendeskgarden/react-dropdowns": "^9.0.0-next.19",
35
+ "@zendeskgarden/react-theming": "^9.0.0-next.19",
35
36
  "@zendeskgarden/svg-icons": "7.1.1"
36
37
  },
37
38
  "keywords": [
@@ -44,5 +45,5 @@
44
45
  "access": "public"
45
46
  },
46
47
  "zendeskgarden:src": "src/index.ts",
47
- "gitHead": "7a7e39c2a9e854ad0fe914d82e28c052aa102d2e"
48
+ "gitHead": "3f18fec721a25bebc274de6af38cd88ab4e63a79"
48
49
  }