@automattic/vip-design-system 2.13.0 → 2.13.2

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.
@@ -8,6 +8,7 @@ export interface AvatarProps {
8
8
  size?: number;
9
9
  src?: string;
10
10
  name?: string;
11
+ abbr?: string;
11
12
  className?: Argument;
12
13
  sx?: ThemeUIStyleObject;
13
14
  }
@@ -1,4 +1,4 @@
1
- var _excluded = ["name", "size", "src", "className", "sx"];
1
+ var _excluded = ["name", "size", "src", "className", "sx", "abbr"];
2
2
  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); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  /**
@@ -21,7 +21,9 @@ export var Avatar = /*#__PURE__*/forwardRef(function (_ref, ref) {
21
21
  className = _ref.className,
22
22
  _ref$sx = _ref.sx,
23
23
  sx = _ref$sx === void 0 ? {} : _ref$sx,
24
+ abbr = _ref.abbr,
24
25
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
26
+ var displayName = name && !abbr ? name.charAt(0) : abbr;
25
27
  return _jsx(Box, _extends({
26
28
  sx: _extends({
27
29
  borderRadius: '100%',
@@ -56,7 +58,7 @@ export var Avatar = /*#__PURE__*/forwardRef(function (_ref, ref) {
56
58
  fontSize: 2,
57
59
  textTransform: 'uppercase'
58
60
  },
59
- children: name ? name.charAt(0) : null
61
+ children: displayName
60
62
  })
61
63
  }));
62
64
  });
@@ -15,3 +15,4 @@ export default _default;
15
15
  type Story = StoryObj<typeof Avatar>;
16
16
  export declare const Default: () => import("react").JSX.Element;
17
17
  export declare const WithName: Story;
18
+ export declare const WithAbbreviation: Story;
@@ -26,6 +26,19 @@ export var Default = function Default() {
26
26
  export var WithName = {
27
27
  args: {
28
28
  name: 'Kitty',
29
- size: 30
29
+ size: 30,
30
+ sx: {
31
+ backgroundColor: '#D8A45F'
32
+ }
33
+ }
34
+ };
35
+ export var WithAbbreviation = {
36
+ args: {
37
+ name: 'Taylor Swift',
38
+ abbr: 'TS',
39
+ size: 64,
40
+ sx: {
41
+ backgroundColor: '#D8A45F'
42
+ }
30
43
  }
31
44
  };
@@ -919,7 +919,7 @@
919
919
  },
920
920
  "success": {
921
921
  "type": "color",
922
- "value": "#007934"
922
+ "value": "#30ac63"
923
923
  },
924
924
  "neutral": {
925
925
  "type": "color",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "2.13.0",
3
+ "version": "2.13.2",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -29,5 +29,18 @@ export const WithName: Story = {
29
29
  args: {
30
30
  name: 'Kitty',
31
31
  size: 30,
32
+ sx: {
33
+ backgroundColor: '#D8A45F',
34
+ },
35
+ },
36
+ };
37
+ export const WithAbbreviation: Story = {
38
+ args: {
39
+ name: 'Taylor Swift',
40
+ abbr: 'TS',
41
+ size: 64,
42
+ sx: {
43
+ backgroundColor: '#D8A45F',
44
+ },
32
45
  },
33
46
  };
@@ -14,6 +14,7 @@ export interface AvatarProps {
14
14
  size?: number;
15
15
  src?: string;
16
16
  name?: string;
17
+ abbr?: string;
17
18
  className?: Argument;
18
19
  sx?: ThemeUIStyleObject;
19
20
  }
@@ -22,54 +23,58 @@ type AvatarImageProps = AvatarProps & ImageProps;
22
23
 
23
24
  export const Avatar = forwardRef< HTMLElement, AvatarImageProps >(
24
25
  (
25
- { name, size = 32, src, className, sx = {}, ...props }: AvatarImageProps,
26
+ { name, size = 32, src, className, sx = {}, abbr, ...props }: AvatarImageProps,
26
27
  ref: Ref< HTMLElement >
27
- ) => (
28
- <Box
29
- sx={ {
30
- borderRadius: '100%',
31
- height: size,
32
- width: size,
33
- overflow: 'hidden',
34
- border: 'none',
35
- display: 'inline-flex',
36
- alignItems: 'center',
37
- justifyContent: 'center',
38
- color: 'inverse',
39
- textAlign: 'center',
40
- ...sx,
41
- } }
42
- className={ classNames( 'vip-avatar-component', className ) }
43
- aria-hidden="true"
44
- ref={ ref }
45
- { ...props }
46
- >
47
- { src ? (
48
- <Image
49
- src={ src }
50
- alt={ `Avatar image from ${ name }` }
51
- sx={ {
52
- borderRadius: '100%',
53
- width: '100%',
54
- display: 'block',
55
- } }
56
- />
57
- ) : (
58
- <Text
59
- as="span"
60
- sx={ {
61
- color: 'icon.inverse',
62
- mb: 0,
63
- fontWeight: 'bold',
64
- fontSize: 2,
65
- textTransform: 'uppercase',
66
- } }
67
- >
68
- { name ? name.charAt( 0 ) : null }
69
- </Text>
70
- ) }
71
- </Box>
72
- )
28
+ ) => {
29
+ const displayName = name && ! abbr ? name.charAt( 0 ) : abbr;
30
+
31
+ return (
32
+ <Box
33
+ sx={ {
34
+ borderRadius: '100%',
35
+ height: size,
36
+ width: size,
37
+ overflow: 'hidden',
38
+ border: 'none',
39
+ display: 'inline-flex',
40
+ alignItems: 'center',
41
+ justifyContent: 'center',
42
+ color: 'inverse',
43
+ textAlign: 'center',
44
+ ...sx,
45
+ } }
46
+ className={ classNames( 'vip-avatar-component', className ) }
47
+ aria-hidden="true"
48
+ ref={ ref }
49
+ { ...props }
50
+ >
51
+ { src ? (
52
+ <Image
53
+ src={ src }
54
+ alt={ `Avatar image from ${ name }` }
55
+ sx={ {
56
+ borderRadius: '100%',
57
+ width: '100%',
58
+ display: 'block',
59
+ } }
60
+ />
61
+ ) : (
62
+ <Text
63
+ as="span"
64
+ sx={ {
65
+ color: 'icon.inverse',
66
+ mb: 0,
67
+ fontWeight: 'bold',
68
+ fontSize: 2,
69
+ textTransform: 'uppercase',
70
+ } }
71
+ >
72
+ { displayName }
73
+ </Text>
74
+ ) }
75
+ </Box>
76
+ );
77
+ }
73
78
  );
74
79
 
75
80
  Avatar.displayName = 'Avatar';
@@ -919,7 +919,7 @@
919
919
  },
920
920
  "success": {
921
921
  "type": "color",
922
- "value": "#007934"
922
+ "value": "#30ac63"
923
923
  },
924
924
  "neutral": {
925
925
  "type": "color",
@@ -777,7 +777,7 @@
777
777
  },
778
778
  "success": {
779
779
  "type": "color",
780
- "value": "{color.green.60}"
780
+ "value": "{color.green.40}"
781
781
  },
782
782
  "neutral": {
783
783
  "type": "color",