@spaced-out/ui-design-system 0.0.3 → 0.0.5
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/.cspell/custom-words.txt +2 -0
- package/.eslintignore +2 -1
- package/.github/pull_request_template.md +17 -0
- package/.prettierrc +27 -11
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +4 -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 +10 -8
- package/lib/components/Tooltip/Tooltip.js.flow +35 -12
- 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 +13 -4
- package/pull_request_template.md +0 -48
package/.cspell/custom-words.txt
CHANGED
package/.eslintignore
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
/src/assets/fontawesome/
|
|
1
|
+
/src/assets/fontawesome/
|
|
2
|
+
node_modules/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
### Description of changes
|
|
2
|
+
<!--- Describe your changes in detail -->
|
|
3
|
+
|
|
4
|
+
### Design Specs(Add a link to Spec sheet)
|
|
5
|
+
<!--- Add a link to design specs -->
|
|
6
|
+
|
|
7
|
+
### Screenshots(if appropriate)
|
|
8
|
+
|
|
9
|
+
### Does this close any currently open issues?
|
|
10
|
+
|
|
11
|
+
### Breaking changes(Describe if any)
|
|
12
|
+
|
|
13
|
+
### Checklist:
|
|
14
|
+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
|
15
|
+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
|
16
|
+
- [ ] Merged with latest `master` branch
|
|
17
|
+
- [ ] I have updated the documentation accordingly.
|
package/.prettierrc
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
{
|
|
2
|
+
"singleQuote": true,
|
|
3
|
+
"trailingComma": "all",
|
|
4
|
+
"printWidth": 80,
|
|
5
|
+
"tabWidth": 2,
|
|
6
|
+
"bracketSpacing": false,
|
|
7
|
+
"endOfLine": "lf",
|
|
8
|
+
"overrides": [
|
|
9
|
+
{
|
|
10
|
+
"files": [
|
|
11
|
+
"*.js",
|
|
12
|
+
"*.jsx"
|
|
13
|
+
],
|
|
14
|
+
"options": {
|
|
15
|
+
"parser": "babel-flow"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"files": [
|
|
20
|
+
"*.css"
|
|
21
|
+
],
|
|
22
|
+
"options": {
|
|
23
|
+
"parser": "css"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
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.5 (2022-11-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **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))
|
|
11
|
+
|
|
12
|
+
### 0.0.4 (2022-11-24)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* pr template ([#35](https://github.com/Spaced-Out/ui-design-system/issues/35)) ([c18e112](https://github.com/Spaced-Out/ui-design-system/commit/c18e1123730acaad77e1334a949573ac0cfd3708))
|
|
18
|
+
|
|
5
19
|
### 0.0.3 (2022-11-22)
|
|
6
20
|
|
|
7
21
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -144,9 +144,9 @@ Most commonly used commit prefixes:
|
|
|
144
144
|
|
|
145
145
|
> `build:` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, etc.
|
|
146
146
|
|
|
147
|
-
## Add yourself to the
|
|
147
|
+
## Add yourself to the maintainer list
|
|
148
148
|
|
|
149
|
-
To add yourself to the `
|
|
149
|
+
To add yourself to the `maintainers` table in the README and INTRODUCTION stories:
|
|
150
150
|
|
|
151
151
|
> Run the following commands from the root of the repo:
|
|
152
152
|
|
package/README.md
CHANGED
|
@@ -101,6 +101,10 @@ import * as SIZES from "@spaced-out/ui-design-system/lib/styles/variables/_size.
|
|
|
101
101
|
|
|
102
102
|
Check out our [**Contribution Guide**](https://spaced-out.github.io/ui-design-system/?path=/docs/contribution--page) to setup and contribute to Genesis.
|
|
103
103
|
|
|
104
|
+
## Changelog
|
|
105
|
+
|
|
106
|
+
Check out our [**Changelog here**](https://spaced-out.github.io/ui-design-system/?path=/docs/changelog--page)
|
|
107
|
+
|
|
104
108
|
## Maintainers ✨
|
|
105
109
|
|
|
106
110
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
@@ -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
|
+
});
|