@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
|
@@ -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;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {colorBackgroundTertiary} from '../../styles/variables/_color';
|
|
6
|
+
import {
|
|
7
|
+
spaceSmall,
|
|
8
|
+
spaceXSmall,
|
|
9
|
+
spaceXXSmall,
|
|
10
|
+
} from '../../styles/variables/_space';
|
|
11
|
+
import classify from '../../utils/classify';
|
|
12
|
+
import type {AvatarSize} from '../Avatar';
|
|
13
|
+
import {BaseAvatar} from '../Avatar';
|
|
14
|
+
import type {PlacementType} from '../Tooltip';
|
|
15
|
+
import {Tooltip} from '../Tooltip';
|
|
16
|
+
|
|
17
|
+
import css from './AvatarGroup.module.css';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const COLOR_SEQUENCE = ['blue', 'green', 'orange', 'red', 'gray'];
|
|
21
|
+
|
|
22
|
+
export type AvatarGroupProps = {
|
|
23
|
+
children?: React.Node,
|
|
24
|
+
size?: AvatarSize,
|
|
25
|
+
borderColor?: string,
|
|
26
|
+
maxTooltipLines?: number,
|
|
27
|
+
placement?: PlacementType,
|
|
28
|
+
maxAvatars?: number,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const AvatarGroup = ({
|
|
32
|
+
children,
|
|
33
|
+
size = 'medium',
|
|
34
|
+
borderColor = colorBackgroundTertiary,
|
|
35
|
+
maxTooltipLines = 7,
|
|
36
|
+
placement = 'top',
|
|
37
|
+
maxAvatars = 5,
|
|
38
|
+
}: AvatarGroupProps): React.Node => {
|
|
39
|
+
const childAvatarCount = React.Children.count(children);
|
|
40
|
+
|
|
41
|
+
const leftOverlap = {
|
|
42
|
+
small: spaceXXSmall,
|
|
43
|
+
medium: `${parseInt(spaceSmall) / 2}px`,
|
|
44
|
+
large: spaceXSmall,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
let colorIndex = -1;
|
|
48
|
+
|
|
49
|
+
const avatarInGroup = (child, index, color) =>
|
|
50
|
+
React.cloneElement(child, {
|
|
51
|
+
size,
|
|
52
|
+
classNames: {wrapper: css.avatarInGroup},
|
|
53
|
+
style: {
|
|
54
|
+
borderColor,
|
|
55
|
+
marginLeft: `-${index !== 0 ? leftOverlap[size] : 0}`,
|
|
56
|
+
},
|
|
57
|
+
color,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const childrenArray = React.Children.toArray(children);
|
|
61
|
+
const totalAvatarCount = childrenArray.length;
|
|
62
|
+
const plusAvatar = () => {
|
|
63
|
+
const nameList = [];
|
|
64
|
+
|
|
65
|
+
for (let i = maxAvatars - 1; i < totalAvatarCount; i++) {
|
|
66
|
+
const child = childrenArray[i];
|
|
67
|
+
const {text} = child.props;
|
|
68
|
+
if (text) {
|
|
69
|
+
nameList.push(text);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const NameListNode = () => (
|
|
74
|
+
<span>
|
|
75
|
+
{nameList.map((name) => (
|
|
76
|
+
<React.Fragment key={name}>
|
|
77
|
+
{name}
|
|
78
|
+
<br />
|
|
79
|
+
</React.Fragment>
|
|
80
|
+
))}
|
|
81
|
+
</span>
|
|
82
|
+
);
|
|
83
|
+
return (
|
|
84
|
+
<Tooltip
|
|
85
|
+
body={<NameListNode />}
|
|
86
|
+
bodyMaxLines={maxTooltipLines}
|
|
87
|
+
placement={placement}
|
|
88
|
+
>
|
|
89
|
+
<div className={css.plusAvatar}>
|
|
90
|
+
<BaseAvatar
|
|
91
|
+
size={size}
|
|
92
|
+
color="gray"
|
|
93
|
+
text={`+${childAvatarCount - maxAvatars + 1}`}
|
|
94
|
+
classNames={{wrapper: css.avatarInGroup}}
|
|
95
|
+
style={{
|
|
96
|
+
borderColor,
|
|
97
|
+
marginLeft: `-${leftOverlap[size]}`,
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
</Tooltip>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const childrenWithProps = React.Children.map(children, (child, index) => {
|
|
106
|
+
const {imageSrc} = child.props;
|
|
107
|
+
if (!imageSrc) {
|
|
108
|
+
colorIndex++;
|
|
109
|
+
if (colorIndex === COLOR_SEQUENCE.length) {
|
|
110
|
+
colorIndex = 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const color = COLOR_SEQUENCE[colorIndex];
|
|
115
|
+
if (childAvatarCount <= maxAvatars) {
|
|
116
|
+
return avatarInGroup(child, index, color);
|
|
117
|
+
} else {
|
|
118
|
+
if (index < maxAvatars - 1) {
|
|
119
|
+
return avatarInGroup(child, index, color);
|
|
120
|
+
} else if (index === maxAvatars) {
|
|
121
|
+
return plusAvatar();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
className={classify(css.avatarGroupContainer, {
|
|
129
|
+
[css.largeSize]: size === 'large',
|
|
130
|
+
[css.mediumSize]: size === 'medium',
|
|
131
|
+
[css.smallSize]: size === 'small',
|
|
132
|
+
})}
|
|
133
|
+
>
|
|
134
|
+
{childrenWithProps}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@value (colorFillPrimary, colorBackgroundTertiary) from '../../styles/variables/_color.css';
|
|
2
|
+
@value (borderWidthTertiary) from '../../styles/variables/_border.css';
|
|
3
|
+
@value ( size34, size42, size60) from '../../styles/variables/_size.css';
|
|
4
|
+
|
|
5
|
+
.avatarGroupContainer {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.avatarGroupContainer.largeSize {
|
|
11
|
+
height: size60;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.avatarGroupContainer.mediumSize {
|
|
15
|
+
height: size42;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.avatarGroupContainer.smallSize {
|
|
19
|
+
height: size34;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.avatarInGroup {
|
|
23
|
+
display: flex;
|
|
24
|
+
border: borderWidthTertiary solid colorBackgroundTertiary;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nameList {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.plusAvatar {
|
|
33
|
+
display: flex;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _AvatarGroup = require("./AvatarGroup");
|
|
7
|
+
Object.keys(_AvatarGroup).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _AvatarGroup[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _AvatarGroup[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Badge = exports.BADGE_COLOR = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _color = require("../../styles/variables/_color");
|
|
9
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
+
var _Text = require("../Text/Text");
|
|
11
|
+
var _BadgeModule = _interopRequireDefault(require("./Badge.module.css"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
const BADGE_COLOR = Object.freeze({
|
|
17
|
+
gray: _color.colorGrayLightest,
|
|
18
|
+
red: _color.colorDangerLightest,
|
|
19
|
+
orange: _color.colorWarningLightest,
|
|
20
|
+
green: _color.colorSuccessLightest,
|
|
21
|
+
blue: _color.colorInformationLightest,
|
|
22
|
+
indigo: _color.colorNeutralLightest
|
|
23
|
+
});
|
|
24
|
+
exports.BADGE_COLOR = BADGE_COLOR;
|
|
25
|
+
const Badge = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
classNames,
|
|
28
|
+
text,
|
|
29
|
+
fill = 'gray'
|
|
30
|
+
} = _ref;
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
"data-testid": "Badge",
|
|
33
|
+
className: (0, _classify.default)(_BadgeModule.default.badgeWrapper, {
|
|
34
|
+
[_BadgeModule.default.fixedWidth]: text.length <= 2
|
|
35
|
+
}, classNames?.wrapper),
|
|
36
|
+
style: {
|
|
37
|
+
backgroundColor: BADGE_COLOR[fill]
|
|
38
|
+
}
|
|
39
|
+
}, /*#__PURE__*/React.createElement(_Text.ButtonTextSmall, null, text));
|
|
40
|
+
};
|
|
41
|
+
exports.Badge = Badge;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
colorDangerLightest,
|
|
7
|
+
colorGrayLightest,
|
|
8
|
+
colorInformationLightest,
|
|
9
|
+
colorNeutralLightest,
|
|
10
|
+
colorSuccessLightest,
|
|
11
|
+
colorWarningLightest,
|
|
12
|
+
} from '../../styles/variables/_color';
|
|
13
|
+
import classify from '../../utils/classify';
|
|
14
|
+
import {ButtonTextSmall} from '../Text/Text';
|
|
15
|
+
|
|
16
|
+
import css from './Badge.module.css';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
20
|
+
|
|
21
|
+
export const BADGE_COLOR = Object.freeze({
|
|
22
|
+
gray: colorGrayLightest,
|
|
23
|
+
red: colorDangerLightest,
|
|
24
|
+
orange: colorWarningLightest,
|
|
25
|
+
green: colorSuccessLightest,
|
|
26
|
+
blue: colorInformationLightest,
|
|
27
|
+
indigo: colorNeutralLightest,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type BadgeColorType = $Keys<typeof BADGE_COLOR>;
|
|
31
|
+
|
|
32
|
+
export type BadgeProps = {
|
|
33
|
+
classNames?: ClassNames,
|
|
34
|
+
text: string,
|
|
35
|
+
fill?: BadgeColorType,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Badge = ({
|
|
39
|
+
classNames,
|
|
40
|
+
text,
|
|
41
|
+
fill = 'gray',
|
|
42
|
+
}: BadgeProps): React.Node => (
|
|
43
|
+
<div
|
|
44
|
+
data-testid="Badge"
|
|
45
|
+
className={classify(
|
|
46
|
+
css.badgeWrapper,
|
|
47
|
+
{
|
|
48
|
+
[css.fixedWidth]: text.length <= 2,
|
|
49
|
+
},
|
|
50
|
+
classNames?.wrapper,
|
|
51
|
+
)}
|
|
52
|
+
style={{
|
|
53
|
+
backgroundColor: BADGE_COLOR[fill],
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<ButtonTextSmall>{text}</ButtonTextSmall>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@value (size22, size100) from '../../styles/variables/_size.css';
|
|
2
|
+
@value (spaceXSmall, spaceNone) from '../../styles/variables/_space.css';
|
|
3
|
+
|
|
4
|
+
.badgeWrapper {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
border-radius: size100;
|
|
9
|
+
height: size22;
|
|
10
|
+
padding: spaceNone spaceXSmall;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.fixedWidth {
|
|
14
|
+
padding: initial;
|
|
15
|
+
width: size22;
|
|
16
|
+
height: size22;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PADDING_SIZES = exports.Card = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var SPACES = _interopRequireWildcard(require("../../styles/variables/_space"));
|
|
9
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
+
var _string = require("../../utils/string");
|
|
11
|
+
var _CardModule = _interopRequireDefault(require("./Card.module.css"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
const PADDING_SIZES = Object.freeze({
|
|
17
|
+
small: 'small',
|
|
18
|
+
medium: 'medium',
|
|
19
|
+
large: 'large'
|
|
20
|
+
});
|
|
21
|
+
exports.PADDING_SIZES = PADDING_SIZES;
|
|
22
|
+
const getPaddingValue = size => {
|
|
23
|
+
const spaceKey = 'space' + (0, _string.capitalize)(size);
|
|
24
|
+
return SPACES[spaceKey] || SPACES['spaceNone'];
|
|
25
|
+
};
|
|
26
|
+
const Card = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
children,
|
|
29
|
+
classNames,
|
|
30
|
+
paddingTop = 'medium',
|
|
31
|
+
paddingRight = 'medium',
|
|
32
|
+
paddingBottom = 'medium',
|
|
33
|
+
paddingLeft = 'medium'
|
|
34
|
+
} = _ref;
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
"data-testid": "Card",
|
|
37
|
+
className: (0, _classify.default)(_CardModule.default.cardWrapper, classNames?.wrapper),
|
|
38
|
+
style: {
|
|
39
|
+
paddingTop: getPaddingValue(paddingTop),
|
|
40
|
+
paddingRight: getPaddingValue(paddingRight),
|
|
41
|
+
paddingBottom: getPaddingValue(paddingBottom),
|
|
42
|
+
paddingLeft: getPaddingValue(paddingLeft)
|
|
43
|
+
}
|
|
44
|
+
}, children);
|
|
45
|
+
};
|
|
46
|
+
exports.Card = Card;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import * as SPACES from '../../styles/variables/_space';
|
|
6
|
+
import classify from '../../utils/classify';
|
|
7
|
+
import {capitalize} from '../../utils/string';
|
|
8
|
+
|
|
9
|
+
import css from './Card.module.css';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
13
|
+
|
|
14
|
+
export const PADDING_SIZES = Object.freeze({
|
|
15
|
+
small: 'small',
|
|
16
|
+
medium: 'medium',
|
|
17
|
+
large: 'large',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type PaddingSizeType = $Values<typeof PADDING_SIZES>;
|
|
21
|
+
|
|
22
|
+
export type CardProps = {
|
|
23
|
+
classNames?: ClassNames,
|
|
24
|
+
children: React.Node,
|
|
25
|
+
paddingTop?: PaddingSizeType,
|
|
26
|
+
paddingRight?: PaddingSizeType,
|
|
27
|
+
paddingBottom?: PaddingSizeType,
|
|
28
|
+
paddingLeft?: PaddingSizeType,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getPaddingValue = (size: PaddingSizeType): string => {
|
|
32
|
+
const spaceKey = 'space' + capitalize(size);
|
|
33
|
+
return SPACES[spaceKey] || SPACES['spaceNone'];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Card = ({
|
|
37
|
+
children,
|
|
38
|
+
classNames,
|
|
39
|
+
paddingTop = 'medium',
|
|
40
|
+
paddingRight = 'medium',
|
|
41
|
+
paddingBottom = 'medium',
|
|
42
|
+
paddingLeft = 'medium',
|
|
43
|
+
}: CardProps): React.Node => (
|
|
44
|
+
<div
|
|
45
|
+
data-testid="Card"
|
|
46
|
+
className={classify(css.cardWrapper, classNames?.wrapper)}
|
|
47
|
+
style={{
|
|
48
|
+
paddingTop: getPaddingValue(paddingTop),
|
|
49
|
+
paddingRight: getPaddingValue(paddingRight),
|
|
50
|
+
paddingBottom: getPaddingValue(paddingBottom),
|
|
51
|
+
paddingLeft: getPaddingValue(paddingLeft),
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
@value (colorBackgroundTertiary) from '../../styles/variables/_color.css';
|
|
2
|
+
@value (borderRadiusMedium) from '../../styles/variables/_border.css';
|
|
3
|
+
|
|
4
|
+
.cardWrapper {
|
|
5
|
+
display: flex;
|
|
6
|
+
composes: borderPrimary from '../../styles/border.module.css';
|
|
7
|
+
background-color: colorBackgroundTertiary;
|
|
8
|
+
border-radius: borderRadiusMedium;
|
|
9
|
+
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.CircularLoader = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var COLORS = _interopRequireWildcard(require("../../styles/variables/_color
|
|
8
|
+
var COLORS = _interopRequireWildcard(require("../../styles/variables/_color"));
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
10
|
var _CircularLoaderModule = _interopRequireDefault(require("./CircularLoader.module.css"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -22,7 +22,9 @@ const Tooltip = _ref => {
|
|
|
22
22
|
children,
|
|
23
23
|
title,
|
|
24
24
|
body,
|
|
25
|
-
placement = 'top'
|
|
25
|
+
placement = 'top',
|
|
26
|
+
bodyMaxLines = 2,
|
|
27
|
+
titleMaxLines = 1
|
|
26
28
|
} = _ref;
|
|
27
29
|
const [open, setOpen] = React.useState(false);
|
|
28
30
|
const {
|
|
@@ -53,20 +55,20 @@ const Tooltip = _ref => {
|
|
|
53
55
|
...children.props
|
|
54
56
|
})), open && /*#__PURE__*/React.createElement("div", _extends({
|
|
55
57
|
ref: floating,
|
|
56
|
-
className: (0, _classify.classify)(_TooltipModule.default.tooltip, classNames?.
|
|
58
|
+
className: (0, _classify.classify)(_TooltipModule.default.tooltip, classNames?.tooltip),
|
|
57
59
|
style: {
|
|
58
60
|
position: strategy,
|
|
59
61
|
top: y ?? _space.spaceNone,
|
|
60
62
|
left: x ?? _space.spaceNone
|
|
61
63
|
}
|
|
62
|
-
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(
|
|
64
|
+
}, getFloatingProps()), !!title && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
65
|
+
line: titleMaxLines
|
|
66
|
+
}, /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
|
|
63
67
|
color: "inversePrimary"
|
|
64
|
-
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
65
|
-
line:
|
|
66
|
-
},
|
|
68
|
+
}, title)), !!body && /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
69
|
+
line: bodyMaxLines
|
|
70
|
+
}, /*#__PURE__*/React.createElement(_Text.BodyMedium, {
|
|
67
71
|
color: !title ? 'inversePrimary' : 'inverseSecondary'
|
|
68
|
-
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
69
|
-
line: 2
|
|
70
72
|
}, body))));
|
|
71
73
|
};
|
|
72
74
|
exports.Tooltip = Tooltip;
|