@spaced-out/ui-design-system 0.0.4 → 0.0.6-beta.0
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/.github/workflows/publish_to_npm.yml +4 -0
- package/CHANGELOG.md +14 -0
- package/design-tokens/border/app-border.json +3 -0
- package/design-tokens/border/base-border.json +3 -0
- package/design-tokens/color/app-color.json +8 -5
- package/design-tokens/size/base-size.json +6 -0
- package/lib/components/Avatar/Avatar.js +150 -0
- package/lib/components/Avatar/Avatar.js.flow +178 -0
- package/lib/components/Avatar/Avatar.module.css +87 -0
- package/lib/components/Avatar/index.js +16 -0
- package/lib/components/Avatar/index.js.flow +3 -0
- package/lib/components/AvatarGroup/AvatarGroup.js +110 -0
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +137 -0
- package/lib/components/AvatarGroup/AvatarGroup.module.css +35 -0
- package/lib/components/AvatarGroup/index.js +16 -0
- package/lib/components/AvatarGroup/index.js.flow +3 -0
- package/lib/components/Badge/Badge.js +41 -0
- package/lib/components/Badge/Badge.js.flow +58 -0
- package/lib/components/Badge/Badge.module.css +17 -0
- package/lib/components/Badge/index.js +12 -0
- package/lib/components/Badge/index.js.flow +4 -0
- package/lib/components/Card/Card.js +46 -0
- package/lib/components/Card/Card.js.flow +56 -0
- package/lib/components/Card/Card.module.css +9 -0
- package/lib/components/Card/index.js +12 -0
- package/lib/components/Card/index.js.flow +4 -0
- package/lib/components/CircularLoader/CircularLoader.js +1 -1
- package/lib/components/CircularLoader/CircularLoader.js.flow +1 -1
- package/lib/components/Tooltip/Tooltip.js +6 -6
- package/lib/components/Tooltip/Tooltip.js.flow +23 -15
- package/lib/components/Tooltip/index.js.flow +1 -1
- package/lib/styles/variables/_border.css +2 -0
- package/lib/styles/variables/_border.js +3 -1
- package/lib/styles/variables/_border.js.flow +2 -0
- package/lib/styles/variables/_color.css +2 -0
- package/lib/styles/variables/_color.js +3 -1
- package/lib/styles/variables/_color.js.flow +2 -0
- package/lib/styles/variables/_size.css +4 -0
- package/lib/styles/variables/_size.js +5 -1
- package/lib/styles/variables/_size.js.flow +4 -0
- package/lib/utils/click-away.js +1 -1
- package/lib/utils/click-away.js.flow +1 -1
- package/lib/utils/string.js +14 -0
- package/lib/utils/string.js.flow +10 -0
- package/package.json +10 -1
|
@@ -53,6 +53,8 @@ jobs:
|
|
|
53
53
|
- name: Bump release version
|
|
54
54
|
if: startsWith(github.event.inputs.release-type, 'pre') != true
|
|
55
55
|
run: |
|
|
56
|
+
git fetch --all
|
|
57
|
+
git pull origin master
|
|
56
58
|
yarn build:changelog --release-as $RELEASE_TYPE
|
|
57
59
|
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
|
|
58
60
|
env:
|
|
@@ -63,6 +65,8 @@ jobs:
|
|
|
63
65
|
- name: Bump pre-release version
|
|
64
66
|
if: startsWith(github.event.inputs.release-type, 'pre')
|
|
65
67
|
run: |
|
|
68
|
+
git fetch --all
|
|
69
|
+
git pull origin master
|
|
66
70
|
yarn build:changelog --$RELEASE_TYPE beta
|
|
67
71
|
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
|
|
68
72
|
env:
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### 0.0.6-beta.0 (2022-11-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* script change to fetch all commits ([53a08cd](https://github.com/spaced-out/ui-design-system/commit/53a08cdbab66c32784bf672934ac6faa712d3996))
|
|
11
|
+
|
|
12
|
+
### 0.0.5 (2022-11-29)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **avatar:** [GDS-116] avatar and avatar group ([#36](https://github.com/spaced-out/ui-design-system/issues/36)) ([d326415](https://github.com/spaced-out/ui-design-system/commit/d326415371d96ff6a3dcaf9cd068b1a3468d87ed))
|
|
18
|
+
|
|
5
19
|
### 0.0.4 (2022-11-24)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -147,10 +147,13 @@
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
+
"gray.lightest": {
|
|
151
|
+
"value": "{baseColor.gray.75.value}"
|
|
152
|
+
},
|
|
150
153
|
"neutral": {
|
|
151
154
|
"value": "{baseColor.indigo.500.value}"
|
|
152
155
|
},
|
|
153
|
-
"neutral.lightest":{
|
|
156
|
+
"neutral.lightest": {
|
|
154
157
|
"value": "{baseColor.indigo.50.value}"
|
|
155
158
|
},
|
|
156
159
|
"neutral.light": {
|
|
@@ -166,7 +169,7 @@
|
|
|
166
169
|
"value": "{baseColor.green.500.value}"
|
|
167
170
|
},
|
|
168
171
|
"success.lightest": {
|
|
169
|
-
|
|
172
|
+
"value": "{baseColor.green.50.value}"
|
|
170
173
|
},
|
|
171
174
|
"success.light": {
|
|
172
175
|
"value": "{baseColor.green.200.value}"
|
|
@@ -181,7 +184,7 @@
|
|
|
181
184
|
"value": "{baseColor.blue.500.value}"
|
|
182
185
|
},
|
|
183
186
|
"information.lightest": {
|
|
184
|
-
|
|
187
|
+
"value": "{baseColor.blue.50.value}"
|
|
185
188
|
},
|
|
186
189
|
"information.light": {
|
|
187
190
|
"value": "{baseColor.blue.200.value}"
|
|
@@ -196,7 +199,7 @@
|
|
|
196
199
|
"value": "{baseColor.orange.500.value}"
|
|
197
200
|
},
|
|
198
201
|
"warning.lightest": {
|
|
199
|
-
|
|
202
|
+
"value": "{baseColor.orange.50.value}"
|
|
200
203
|
},
|
|
201
204
|
"warning.light": {
|
|
202
205
|
"value": "{baseColor.orange.200.value}"
|
|
@@ -211,7 +214,7 @@
|
|
|
211
214
|
"value": "{baseColor.red.500.value}"
|
|
212
215
|
},
|
|
213
216
|
"danger.lightest": {
|
|
214
|
-
|
|
217
|
+
"value": "{baseColor.red.50.value}"
|
|
215
218
|
},
|
|
216
219
|
"danger.light": {
|
|
217
220
|
"value": "{baseColor.red.200.value}"
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"20": {
|
|
25
25
|
"value": "20px"
|
|
26
26
|
},
|
|
27
|
+
"22": {
|
|
28
|
+
"value": "22px"
|
|
29
|
+
},
|
|
27
30
|
"24": {
|
|
28
31
|
"value": "24px"
|
|
29
32
|
},
|
|
@@ -45,6 +48,9 @@
|
|
|
45
48
|
"60": {
|
|
46
49
|
"value": "60px"
|
|
47
50
|
},
|
|
51
|
+
"100": {
|
|
52
|
+
"value": "100px"
|
|
53
|
+
},
|
|
48
54
|
"110": {
|
|
49
55
|
"value": "110px"
|
|
50
56
|
},
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.avatarSizeOptions = exports.BaseAvatar = exports.Avatar = exports.AVATAR_SIZE = exports.AVATAR_COLOR = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Text = require("../../components/Text");
|
|
9
|
+
var _color = require("../../styles/variables/_color");
|
|
10
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
|
+
var _Icon = require("../Icon");
|
|
12
|
+
var _AvatarModule = _interopRequireDefault(require("./Avatar.module.css"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
|
|
17
|
+
const AVATAR_SIZE = Object.freeze({
|
|
18
|
+
small: 'small',
|
|
19
|
+
medium: 'medium',
|
|
20
|
+
large: 'large'
|
|
21
|
+
});
|
|
22
|
+
exports.AVATAR_SIZE = AVATAR_SIZE;
|
|
23
|
+
const avatarSizeOptions = [...Object.keys(AVATAR_SIZE)];
|
|
24
|
+
exports.avatarSizeOptions = avatarSizeOptions;
|
|
25
|
+
const AVATAR_COLOR = Object.freeze({
|
|
26
|
+
red: _color.colorDangerLightest,
|
|
27
|
+
orange: _color.colorWarningLightest,
|
|
28
|
+
green: _color.colorSuccessLightest,
|
|
29
|
+
blue: _color.colorInformationLightest,
|
|
30
|
+
gray: _color.colorGrayLightest,
|
|
31
|
+
indigo: _color.colorNeutralLightest
|
|
32
|
+
});
|
|
33
|
+
exports.AVATAR_COLOR = AVATAR_COLOR;
|
|
34
|
+
const getAvatarText = function () {
|
|
35
|
+
let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
36
|
+
const [firstWord, secondWord] = text.split(' ');
|
|
37
|
+
const firstChar = firstWord ? firstWord[0].toUpperCase() : '';
|
|
38
|
+
const secondChar = secondWord ? secondWord[0].toUpperCase() : '';
|
|
39
|
+
return firstChar + secondChar;
|
|
40
|
+
};
|
|
41
|
+
const AvatarTextDecorator = _ref => {
|
|
42
|
+
let {
|
|
43
|
+
avatarText,
|
|
44
|
+
size
|
|
45
|
+
} = _ref;
|
|
46
|
+
switch (size) {
|
|
47
|
+
case 'small':
|
|
48
|
+
return /*#__PURE__*/React.createElement(_Text.SubTitleSmall, null, avatarText);
|
|
49
|
+
case 'medium':
|
|
50
|
+
return /*#__PURE__*/React.createElement(_Text.SubTitleMedium, null, avatarText);
|
|
51
|
+
case 'large':
|
|
52
|
+
return /*#__PURE__*/React.createElement(_Text.SubTitleLarge, null, avatarText);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// mapping of iconSize for each avatar size;
|
|
57
|
+
const iconSize = Object.freeze({
|
|
58
|
+
small: 'small',
|
|
59
|
+
medium: 'medium',
|
|
60
|
+
large: 'medium'
|
|
61
|
+
});
|
|
62
|
+
const AvatarConditionalContent = _ref2 => {
|
|
63
|
+
let {
|
|
64
|
+
imageSrc,
|
|
65
|
+
text,
|
|
66
|
+
iconName,
|
|
67
|
+
size = 'medium',
|
|
68
|
+
iconType,
|
|
69
|
+
color = 'blue'
|
|
70
|
+
} = _ref2;
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: _AvatarModule.default.innerContainer,
|
|
73
|
+
style: {
|
|
74
|
+
background: AVATAR_COLOR[color]
|
|
75
|
+
}
|
|
76
|
+
}, imageSrc ? /*#__PURE__*/React.createElement("img", {
|
|
77
|
+
src: imageSrc,
|
|
78
|
+
alt: "Avatar",
|
|
79
|
+
className: _AvatarModule.default.avatar
|
|
80
|
+
}) : iconName ? /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
81
|
+
name: iconName,
|
|
82
|
+
type: iconType,
|
|
83
|
+
size: iconSize[size]
|
|
84
|
+
}) : text ? /*#__PURE__*/React.createElement(AvatarTextDecorator, {
|
|
85
|
+
avatarText: getAvatarText(text),
|
|
86
|
+
size: size
|
|
87
|
+
}) : null);
|
|
88
|
+
};
|
|
89
|
+
const Avatar = _ref3 => {
|
|
90
|
+
let {
|
|
91
|
+
classNames,
|
|
92
|
+
size = 'medium',
|
|
93
|
+
imageSrc,
|
|
94
|
+
text,
|
|
95
|
+
style,
|
|
96
|
+
iconName,
|
|
97
|
+
iconType,
|
|
98
|
+
color,
|
|
99
|
+
ring = false
|
|
100
|
+
} = _ref3;
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: (0, _classify.default)(_AvatarModule.default.container, {
|
|
103
|
+
[_AvatarModule.default.largeSize]: size === 'large',
|
|
104
|
+
[_AvatarModule.default.mediumSize]: size === 'medium',
|
|
105
|
+
[_AvatarModule.default.smallSize]: size === 'small'
|
|
106
|
+
}, classNames?.wrapper),
|
|
107
|
+
style: style
|
|
108
|
+
}, ring ? /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: _AvatarModule.default.ring
|
|
110
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: _AvatarModule.default.whiteCircle
|
|
112
|
+
}, /*#__PURE__*/React.createElement(AvatarConditionalContent, {
|
|
113
|
+
imageSrc: imageSrc,
|
|
114
|
+
text: text,
|
|
115
|
+
iconName: iconName,
|
|
116
|
+
iconType: iconType,
|
|
117
|
+
color: color
|
|
118
|
+
}))) : /*#__PURE__*/React.createElement(AvatarConditionalContent, {
|
|
119
|
+
imageSrc: imageSrc,
|
|
120
|
+
text: text,
|
|
121
|
+
iconName: iconName,
|
|
122
|
+
iconType: iconType,
|
|
123
|
+
color: color
|
|
124
|
+
}));
|
|
125
|
+
};
|
|
126
|
+
exports.Avatar = Avatar;
|
|
127
|
+
const BaseAvatar = _ref4 => {
|
|
128
|
+
let {
|
|
129
|
+
classNames,
|
|
130
|
+
size = 'medium',
|
|
131
|
+
text = '',
|
|
132
|
+
style,
|
|
133
|
+
color = 'blue'
|
|
134
|
+
} = _ref4;
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: (0, _classify.default)(_AvatarModule.default.container, {
|
|
137
|
+
[_AvatarModule.default.baseLargeSize]: size === 'large',
|
|
138
|
+
[_AvatarModule.default.baseMediumSize]: size === 'medium',
|
|
139
|
+
[_AvatarModule.default.baseSmallSize]: size === 'small'
|
|
140
|
+
}, classNames?.wrapper),
|
|
141
|
+
style: {
|
|
142
|
+
...style,
|
|
143
|
+
background: AVATAR_COLOR[color]
|
|
144
|
+
}
|
|
145
|
+
}, /*#__PURE__*/React.createElement(AvatarTextDecorator, {
|
|
146
|
+
avatarText: text,
|
|
147
|
+
size: size
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
exports.BaseAvatar = BaseAvatar;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
SubTitleLarge,
|
|
7
|
+
SubTitleMedium,
|
|
8
|
+
SubTitleSmall,
|
|
9
|
+
} from '../../components/Text';
|
|
10
|
+
import {
|
|
11
|
+
colorDangerLightest,
|
|
12
|
+
colorGrayLightest,
|
|
13
|
+
colorInformationLightest,
|
|
14
|
+
colorNeutralLightest,
|
|
15
|
+
colorSuccessLightest,
|
|
16
|
+
colorWarningLightest,
|
|
17
|
+
} from '../../styles/variables/_color';
|
|
18
|
+
import classify from '../../utils/classify';
|
|
19
|
+
import type {IconType} from '../Icon';
|
|
20
|
+
import {Icon} from '../Icon';
|
|
21
|
+
|
|
22
|
+
import css from './Avatar.module.css';
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
26
|
+
|
|
27
|
+
export const AVATAR_SIZE = Object.freeze({
|
|
28
|
+
small: 'small',
|
|
29
|
+
medium: 'medium',
|
|
30
|
+
large: 'large',
|
|
31
|
+
});
|
|
32
|
+
export const avatarSizeOptions: Array<mixed> = [...Object.keys(AVATAR_SIZE)];
|
|
33
|
+
|
|
34
|
+
export type AvatarSize = $Keys<typeof AVATAR_SIZE>;
|
|
35
|
+
export const AVATAR_COLOR = Object.freeze({
|
|
36
|
+
red: colorDangerLightest,
|
|
37
|
+
orange: colorWarningLightest,
|
|
38
|
+
green: colorSuccessLightest,
|
|
39
|
+
blue: colorInformationLightest,
|
|
40
|
+
gray: colorGrayLightest,
|
|
41
|
+
indigo: colorNeutralLightest,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type AvatarColorType = $Keys<typeof AVATAR_COLOR>;
|
|
45
|
+
|
|
46
|
+
export type AvatarProps = {
|
|
47
|
+
classNames?: ClassNames,
|
|
48
|
+
size?: AvatarSize,
|
|
49
|
+
imageSrc?: string,
|
|
50
|
+
ring?: boolean,
|
|
51
|
+
icon?: boolean,
|
|
52
|
+
text?: string,
|
|
53
|
+
color?: AvatarColorType,
|
|
54
|
+
style?: mixed,
|
|
55
|
+
iconName?: string,
|
|
56
|
+
iconType?: IconType,
|
|
57
|
+
ring?: boolean,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getAvatarText = (text = '') => {
|
|
61
|
+
const [firstWord, secondWord] = text.split(' ');
|
|
62
|
+
const firstChar = firstWord ? firstWord[0].toUpperCase() : '';
|
|
63
|
+
const secondChar = secondWord ? secondWord[0].toUpperCase() : '';
|
|
64
|
+
return firstChar + secondChar;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const AvatarTextDecorator = ({
|
|
68
|
+
avatarText,
|
|
69
|
+
size,
|
|
70
|
+
}: {
|
|
71
|
+
avatarText: string,
|
|
72
|
+
size: AvatarSize,
|
|
73
|
+
}) => {
|
|
74
|
+
switch (size) {
|
|
75
|
+
case 'small':
|
|
76
|
+
return <SubTitleSmall>{avatarText}</SubTitleSmall>;
|
|
77
|
+
case 'medium':
|
|
78
|
+
return <SubTitleMedium>{avatarText}</SubTitleMedium>;
|
|
79
|
+
case 'large':
|
|
80
|
+
return <SubTitleLarge>{avatarText}</SubTitleLarge>;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// mapping of iconSize for each avatar size;
|
|
85
|
+
const iconSize = Object.freeze({
|
|
86
|
+
small: 'small',
|
|
87
|
+
medium: 'medium',
|
|
88
|
+
large: 'medium',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const AvatarConditionalContent = ({
|
|
92
|
+
imageSrc,
|
|
93
|
+
text,
|
|
94
|
+
iconName,
|
|
95
|
+
size = 'medium',
|
|
96
|
+
iconType,
|
|
97
|
+
color = 'blue',
|
|
98
|
+
}) => (
|
|
99
|
+
<div className={css.innerContainer} style={{background: AVATAR_COLOR[color]}}>
|
|
100
|
+
{imageSrc ? (
|
|
101
|
+
<img src={imageSrc} alt="Avatar" className={css.avatar}></img>
|
|
102
|
+
) : iconName ? (
|
|
103
|
+
<Icon name={iconName} type={iconType} size={iconSize[size]} />
|
|
104
|
+
) : text ? (
|
|
105
|
+
<AvatarTextDecorator avatarText={getAvatarText(text)} size={size} />
|
|
106
|
+
) : null}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
export const Avatar = ({
|
|
111
|
+
classNames,
|
|
112
|
+
size = 'medium',
|
|
113
|
+
imageSrc,
|
|
114
|
+
text,
|
|
115
|
+
style,
|
|
116
|
+
iconName,
|
|
117
|
+
iconType,
|
|
118
|
+
color,
|
|
119
|
+
ring = false,
|
|
120
|
+
}: AvatarProps): React.Node => (
|
|
121
|
+
<div
|
|
122
|
+
className={classify(
|
|
123
|
+
css.container,
|
|
124
|
+
{
|
|
125
|
+
[css.largeSize]: size === 'large',
|
|
126
|
+
[css.mediumSize]: size === 'medium',
|
|
127
|
+
[css.smallSize]: size === 'small',
|
|
128
|
+
},
|
|
129
|
+
classNames?.wrapper,
|
|
130
|
+
)}
|
|
131
|
+
style={style}
|
|
132
|
+
>
|
|
133
|
+
{ring ? (
|
|
134
|
+
<div className={css.ring}>
|
|
135
|
+
<div className={css.whiteCircle}>
|
|
136
|
+
<AvatarConditionalContent
|
|
137
|
+
imageSrc={imageSrc}
|
|
138
|
+
text={text}
|
|
139
|
+
iconName={iconName}
|
|
140
|
+
iconType={iconType}
|
|
141
|
+
color={color}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
) : (
|
|
146
|
+
<AvatarConditionalContent
|
|
147
|
+
imageSrc={imageSrc}
|
|
148
|
+
text={text}
|
|
149
|
+
iconName={iconName}
|
|
150
|
+
iconType={iconType}
|
|
151
|
+
color={color}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
export const BaseAvatar = ({
|
|
158
|
+
classNames,
|
|
159
|
+
size = 'medium',
|
|
160
|
+
text = '',
|
|
161
|
+
style,
|
|
162
|
+
color = 'blue',
|
|
163
|
+
}: AvatarProps): React.Node => (
|
|
164
|
+
<div
|
|
165
|
+
className={classify(
|
|
166
|
+
css.container,
|
|
167
|
+
{
|
|
168
|
+
[css.baseLargeSize]: size === 'large',
|
|
169
|
+
[css.baseMediumSize]: size === 'medium',
|
|
170
|
+
[css.baseSmallSize]: size === 'small',
|
|
171
|
+
},
|
|
172
|
+
classNames?.wrapper,
|
|
173
|
+
)}
|
|
174
|
+
style={{...style, background: AVATAR_COLOR[color]}}
|
|
175
|
+
>
|
|
176
|
+
<AvatarTextDecorator avatarText={text} size={size} />
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@value (colorFillPrimary, colorBackgroundTertiary, colorInformation) from '../../styles/variables/_color.css';
|
|
2
|
+
@value ( size34, size42, size60, sizeFluid) from '../../styles/variables/_size.css';
|
|
3
|
+
@value (borderRadiusCircle, borderRadiusLarge, borderRadiusXLarge, borderWidthSecondary) from '../../styles/variables/_border.css';
|
|
4
|
+
@value (spaceXXSmall, spaceXSmall) from '../../styles/variables/_space.css';
|
|
5
|
+
|
|
6
|
+
.container {
|
|
7
|
+
border-radius: borderRadiusCircle;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.container.largeSize {
|
|
14
|
+
width: size60;
|
|
15
|
+
height: size60;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.container.mediumSize {
|
|
19
|
+
width: size42;
|
|
20
|
+
height: size42;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.container.smallSize {
|
|
24
|
+
width: size34;
|
|
25
|
+
height: size34;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.container.baseLargeSize {
|
|
29
|
+
min-width: size60;
|
|
30
|
+
height: size60;
|
|
31
|
+
border-radius: borderRadiusXLarge;
|
|
32
|
+
padding: 0 spaceXSmall;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.container.baseMediumSize {
|
|
36
|
+
min-width: size42;
|
|
37
|
+
height: size42;
|
|
38
|
+
border-radius: borderRadiusLarge;
|
|
39
|
+
padding: 0 spaceXXSmall;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.container.baseSmallSize {
|
|
43
|
+
min-width: size34;
|
|
44
|
+
height: size34;
|
|
45
|
+
border-radius: borderRadiusLarge;
|
|
46
|
+
padding: 0 spaceXXSmall;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.avatar {
|
|
50
|
+
vertical-align: middle;
|
|
51
|
+
width: sizeFluid;
|
|
52
|
+
height: sizeFluid;
|
|
53
|
+
border-radius: borderRadiusCircle;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ring {
|
|
60
|
+
border-radius: borderRadiusCircle;
|
|
61
|
+
width: sizeFluid;
|
|
62
|
+
height: sizeFluid;
|
|
63
|
+
border: solid borderWidthSecondary transparent;
|
|
64
|
+
background-image: linear-gradient(white, white),
|
|
65
|
+
radial-gradient(circle at top right, colorFillPrimary, colorInformation);
|
|
66
|
+
background-origin: border-box;
|
|
67
|
+
background-clip: content-box, border-box;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.whiteCircle {
|
|
74
|
+
border-radius: borderRadiusCircle;
|
|
75
|
+
border: solid borderWidthSecondary colorBackgroundTertiary;
|
|
76
|
+
width: sizeFluid;
|
|
77
|
+
height: sizeFluid;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.innerContainer {
|
|
81
|
+
display: flex;
|
|
82
|
+
border-radius: borderRadiusCircle;
|
|
83
|
+
width: sizeFluid;
|
|
84
|
+
height: sizeFluid;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Avatar = require("./Avatar");
|
|
7
|
+
Object.keys(_Avatar).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Avatar[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Avatar[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AvatarGroup = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _color = require("../../styles/variables/_color");
|
|
9
|
+
var _space = require("../../styles/variables/_space");
|
|
10
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
|
+
var _Avatar = require("../Avatar");
|
|
12
|
+
var _Tooltip = require("../Tooltip");
|
|
13
|
+
var _AvatarGroupModule = _interopRequireDefault(require("./AvatarGroup.module.css"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
|
|
18
|
+
const COLOR_SEQUENCE = ['blue', 'green', 'orange', 'red', 'gray'];
|
|
19
|
+
const AvatarGroup = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
size = 'medium',
|
|
23
|
+
borderColor = _color.colorBackgroundTertiary,
|
|
24
|
+
maxTooltipLines = 7,
|
|
25
|
+
placement = 'top',
|
|
26
|
+
maxAvatars = 5
|
|
27
|
+
} = _ref;
|
|
28
|
+
const childAvatarCount = React.Children.count(children);
|
|
29
|
+
const leftOverlap = {
|
|
30
|
+
small: _space.spaceXXSmall,
|
|
31
|
+
medium: `${parseInt(_space.spaceSmall) / 2}px`,
|
|
32
|
+
large: _space.spaceXSmall
|
|
33
|
+
};
|
|
34
|
+
let colorIndex = -1;
|
|
35
|
+
const avatarInGroup = (child, index, color) => /*#__PURE__*/React.cloneElement(child, {
|
|
36
|
+
size,
|
|
37
|
+
classNames: {
|
|
38
|
+
wrapper: _AvatarGroupModule.default.avatarInGroup
|
|
39
|
+
},
|
|
40
|
+
style: {
|
|
41
|
+
borderColor,
|
|
42
|
+
marginLeft: `-${index !== 0 ? leftOverlap[size] : 0}`
|
|
43
|
+
},
|
|
44
|
+
color
|
|
45
|
+
});
|
|
46
|
+
const childrenArray = React.Children.toArray(children);
|
|
47
|
+
const totalAvatarCount = childrenArray.length;
|
|
48
|
+
const plusAvatar = () => {
|
|
49
|
+
const nameList = [];
|
|
50
|
+
for (let i = maxAvatars - 1; i < totalAvatarCount; i++) {
|
|
51
|
+
const child = childrenArray[i];
|
|
52
|
+
const {
|
|
53
|
+
text
|
|
54
|
+
} = child.props;
|
|
55
|
+
if (text) {
|
|
56
|
+
nameList.push(text);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const NameListNode = () => /*#__PURE__*/React.createElement("span", null, nameList.map(name => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
60
|
+
key: name
|
|
61
|
+
}, name, /*#__PURE__*/React.createElement("br", null))));
|
|
62
|
+
return /*#__PURE__*/React.createElement(_Tooltip.Tooltip, {
|
|
63
|
+
body: /*#__PURE__*/React.createElement(NameListNode, null),
|
|
64
|
+
bodyMaxLines: maxTooltipLines,
|
|
65
|
+
placement: placement
|
|
66
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: _AvatarGroupModule.default.plusAvatar
|
|
68
|
+
}, /*#__PURE__*/React.createElement(_Avatar.BaseAvatar, {
|
|
69
|
+
size: size,
|
|
70
|
+
color: "gray",
|
|
71
|
+
text: `+${childAvatarCount - maxAvatars + 1}`,
|
|
72
|
+
classNames: {
|
|
73
|
+
wrapper: _AvatarGroupModule.default.avatarInGroup
|
|
74
|
+
},
|
|
75
|
+
style: {
|
|
76
|
+
borderColor,
|
|
77
|
+
marginLeft: `-${leftOverlap[size]}`
|
|
78
|
+
}
|
|
79
|
+
})));
|
|
80
|
+
};
|
|
81
|
+
const childrenWithProps = React.Children.map(children, (child, index) => {
|
|
82
|
+
const {
|
|
83
|
+
imageSrc
|
|
84
|
+
} = child.props;
|
|
85
|
+
if (!imageSrc) {
|
|
86
|
+
colorIndex++;
|
|
87
|
+
if (colorIndex === COLOR_SEQUENCE.length) {
|
|
88
|
+
colorIndex = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const color = COLOR_SEQUENCE[colorIndex];
|
|
92
|
+
if (childAvatarCount <= maxAvatars) {
|
|
93
|
+
return avatarInGroup(child, index, color);
|
|
94
|
+
} else {
|
|
95
|
+
if (index < maxAvatars - 1) {
|
|
96
|
+
return avatarInGroup(child, index, color);
|
|
97
|
+
} else if (index === maxAvatars) {
|
|
98
|
+
return plusAvatar();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
className: (0, _classify.default)(_AvatarGroupModule.default.avatarGroupContainer, {
|
|
104
|
+
[_AvatarGroupModule.default.largeSize]: size === 'large',
|
|
105
|
+
[_AvatarGroupModule.default.mediumSize]: size === 'medium',
|
|
106
|
+
[_AvatarGroupModule.default.smallSize]: size === 'small'
|
|
107
|
+
})
|
|
108
|
+
}, childrenWithProps);
|
|
109
|
+
};
|
|
110
|
+
exports.AvatarGroup = AvatarGroup;
|