@decisiv/ui-components 2.0.1-alpha.181 → 2.0.1-alpha.182
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/lib/components/Avatar/AvatarContainer.d.ts +1 -13
- package/lib/components/Avatar/AvatarContainer.d.ts.map +1 -1
- package/lib/components/Avatar/AvatarContainer.js +12 -13
- package/lib/components/Avatar/AvatarContent.d.ts +2 -2
- package/lib/components/Avatar/AvatarContent.d.ts.map +1 -1
- package/lib/components/Avatar/AvatarContent.js +24 -20
- package/lib/components/Avatar/index.d.ts.map +1 -1
- package/lib/components/Avatar/index.js +39 -5
- package/lib/components/Avatar/index.test.js +4 -0
- package/lib/components/Avatar/schema.d.ts.map +1 -1
- package/lib/components/Avatar/schema.js +3 -1
- package/lib/components/Avatar/types.d.ts +15 -2
- package/lib/components/Avatar/types.d.ts.map +1 -1
- package/lib/components/Tag/styles.d.ts.map +1 -1
- package/lib/components/Tag/styles.js +9 -43
- package/lib/modifiers/palette.d.ts +36 -0
- package/lib/modifiers/palette.d.ts.map +1 -0
- package/lib/modifiers/palette.js +88 -0
- package/package.json +2 -2
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const kindModifiers: {
|
|
3
|
-
readonly primary: () => CSS;
|
|
4
|
-
readonly secondary: () => CSS;
|
|
5
|
-
};
|
|
6
|
-
declare const sizeModifiers: {
|
|
7
|
-
readonly medium: () => CSS;
|
|
8
|
-
readonly large: () => CSS;
|
|
9
|
-
};
|
|
10
|
-
interface AvatarContainerProps {
|
|
11
|
-
kind?: keyof typeof kindModifiers;
|
|
12
|
-
size?: keyof typeof sizeModifiers;
|
|
13
|
-
}
|
|
1
|
+
import { AvatarContainerProps } from './types';
|
|
14
2
|
declare const AvatarContainer: import("styled-components").StyledComponent<"div", any, AvatarContainerProps, never>;
|
|
15
3
|
export default AvatarContainer;
|
|
16
4
|
//# sourceMappingURL=AvatarContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/AvatarContainer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AvatarContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/AvatarContainer.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoC/C,QAAA,MAAM,eAAe,sFAkBpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -17,25 +17,18 @@ var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"))
|
|
|
17
17
|
|
|
18
18
|
var _typography = _interopRequireDefault(require("@decisiv/design-tokens/lib/typography"));
|
|
19
19
|
|
|
20
|
+
var _palette = require("../../modifiers/palette");
|
|
21
|
+
|
|
20
22
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
|
-
var status = _color.default.status
|
|
25
|
-
visualInterest = _color.default.visualInterest;
|
|
26
|
-
var kindModifiers = {
|
|
27
|
-
primary: function primary() {
|
|
28
|
-
return (0, _styledComponents.css)(["background-color:", ";"], (0, _toColorString.default)(status.information.medium));
|
|
29
|
-
},
|
|
30
|
-
secondary: function secondary() {
|
|
31
|
-
return (0, _styledComponents.css)(["background-color:", ";"], (0, _toColorString.default)(visualInterest.licoriceMousse.medium));
|
|
32
|
-
}
|
|
33
|
-
};
|
|
26
|
+
var status = _color.default.status;
|
|
34
27
|
|
|
35
28
|
var makeSizeModifiers = function makeSizeModifiers(_ref) {
|
|
36
29
|
var size = _ref.size,
|
|
37
30
|
typeScale = _ref.typeScale;
|
|
38
|
-
return (0, _styledComponents.css)(["font-size:", ";height:", ";min-height:", ";width:", ";min-width:", ";"], (0, _rem.default)(_typography.default.size.scale[typeScale]), (0, _rem.default)(size), (0, _rem.default)(size), (0, _rem.default)(size), (0, _rem.default)(size));
|
|
31
|
+
return (0, _styledComponents.css)(["font-weight:", ";font-size:", ";height:", ";min-height:", ";width:", ";min-width:", ";"], _typography.default.weight.alias.regular, (0, _rem.default)(_typography.default.size.scale[typeScale]), (0, _rem.default)(size), (0, _rem.default)(size), (0, _rem.default)(size), (0, _rem.default)(size));
|
|
39
32
|
};
|
|
40
33
|
|
|
41
34
|
var sizeModifiers = {
|
|
@@ -48,15 +41,21 @@ var sizeModifiers = {
|
|
|
48
41
|
large: function large() {
|
|
49
42
|
return makeSizeModifiers({
|
|
50
43
|
size: 60,
|
|
51
|
-
typeScale:
|
|
44
|
+
typeScale: 3
|
|
52
45
|
});
|
|
53
46
|
}
|
|
54
47
|
};
|
|
55
48
|
|
|
49
|
+
var withGravatarModifiers = function withGravatarModifiers(props) {
|
|
50
|
+
var shouldUseGravatar = props.shouldUseGravatar;
|
|
51
|
+
if (!shouldUseGravatar) return null;
|
|
52
|
+
return (0, _styledComponents.css)(["color:transparent;background-color:transparent;border:none;"]);
|
|
53
|
+
};
|
|
54
|
+
|
|
56
55
|
var AvatarContainer = _styledComponents.default.div.withConfig({
|
|
57
56
|
displayName: "AvatarContainer",
|
|
58
57
|
componentId: "sc-16avffw-0"
|
|
59
|
-
})(["position:relative;align-items:center;background-color:", ";border-radius:50%;display:inline-flex;height:", ";justify-content:center;width:", ";> span[role='img']{line-height:0;}", ";", ";"], (0, _toColorString.default)(status.information.medium), (0, _rem.default)(36), (0, _rem.default)(36), (0, _styledComponentsModifiers.applyStyleModifiers)(
|
|
58
|
+
})(["position:relative;align-items:center;background-color:", ";border-radius:50%;display:inline-flex;height:", ";justify-content:center;width:", ";> span[role='img']{line-height:0;}", ";", ";", ""], (0, _toColorString.default)(status.information.medium), (0, _rem.default)(36), (0, _rem.default)(36), (0, _styledComponentsModifiers.applyStyleModifiers)(sizeModifiers, 'size'), _palette.withBorderedPalette, withGravatarModifiers);
|
|
60
59
|
|
|
61
60
|
var _default = AvatarContainer;
|
|
62
61
|
exports.default = _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
declare function AvatarContent(props:
|
|
2
|
+
import { AvatarContentProps } from './types';
|
|
3
|
+
declare function AvatarContent(props: AvatarContentProps): JSX.Element;
|
|
4
4
|
export default AvatarContent;
|
|
5
5
|
//# sourceMappingURL=AvatarContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarContent.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/AvatarContent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"AvatarContent.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/AvatarContent.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AA8B7C,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAkB7D;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -5,61 +5,65 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
|
|
12
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
11
|
|
|
14
|
-
var
|
|
12
|
+
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
13
|
+
|
|
14
|
+
var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
|
|
15
15
|
|
|
16
16
|
var _Typography = require("../Typography");
|
|
17
17
|
|
|
18
18
|
var _useAvatarIcon = _interopRequireDefault(require("./hooks/useAvatarIcon"));
|
|
19
19
|
|
|
20
|
-
var _useGravatar3 = _interopRequireDefault(require("./hooks/useGravatar"));
|
|
21
|
-
|
|
22
20
|
var _useInitials = _interopRequireDefault(require("./hooks/useInitials"));
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
var _palette = require("../../modifiers/palette");
|
|
25
23
|
|
|
26
|
-
function
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
25
|
|
|
28
|
-
function
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
29
27
|
|
|
30
|
-
function
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
29
|
|
|
32
|
-
function
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
31
|
|
|
34
32
|
var GravatarImg = _styledComponents.default.img.withConfig({
|
|
35
33
|
displayName: "AvatarContent__GravatarImg",
|
|
36
34
|
componentId: "sc-1jejgqy-0"
|
|
37
35
|
})(["border-radius:50%;width:100%;"]);
|
|
38
36
|
|
|
37
|
+
var borderColor = _objectSpread({}, _color.default.base.charcoal, {
|
|
38
|
+
alpha: _palette.BORDER_OPACITY.pastel
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
var GravatarShadow = _styledComponents.default.div.withConfig({
|
|
42
|
+
displayName: "AvatarContent__GravatarShadow",
|
|
43
|
+
componentId: "sc-1jejgqy-1"
|
|
44
|
+
})(["position:absolute;width:100%;height:100%;box-shadow:inset 0 0 0 1px ", ";border-radius:50%;top:0;left:0;"], (0, _toColorString.default)(borderColor));
|
|
45
|
+
|
|
39
46
|
var Initials = (0, _styledComponents.default)(_Typography.P).attrs({
|
|
40
47
|
as: 'span'
|
|
41
48
|
}).withConfig({
|
|
42
49
|
displayName: "AvatarContent__Initials",
|
|
43
|
-
componentId: "sc-1jejgqy-
|
|
44
|
-
})(["
|
|
50
|
+
componentId: "sc-1jejgqy-2"
|
|
51
|
+
})(["font-size:inherit;text-transform:uppercase;font-weight:inherit;"]);
|
|
45
52
|
|
|
46
53
|
var AvatarIcon = _styledComponents.default.div.withConfig({
|
|
47
54
|
displayName: "AvatarContent__AvatarIcon",
|
|
48
|
-
componentId: "sc-1jejgqy-
|
|
49
|
-
})(["
|
|
55
|
+
componentId: "sc-1jejgqy-3"
|
|
56
|
+
})([""]);
|
|
50
57
|
|
|
51
58
|
function AvatarContent(props) {
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
gravatarProps = _useGravatar2[0],
|
|
55
|
-
shouldUseGravatar = _useGravatar2[1];
|
|
56
|
-
|
|
59
|
+
var gravatarProps = props.gravatarProps,
|
|
60
|
+
shouldUseGravatar = props.shouldUseGravatar;
|
|
57
61
|
var initials = (0, _useInitials.default)(props);
|
|
58
62
|
var avatarIconProps = (0, _useAvatarIcon.default)(props);
|
|
59
63
|
|
|
60
64
|
switch (true) {
|
|
61
65
|
case shouldUseGravatar:
|
|
62
|
-
return _react.default.createElement(GravatarImg, gravatarProps);
|
|
66
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(GravatarImg, gravatarProps), _react.default.createElement(GravatarShadow, null));
|
|
63
67
|
|
|
64
68
|
case !!initials.length:
|
|
65
69
|
return _react.default.createElement(Initials, null, initials);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/index.tsx"],"names":[],"mappings":"AAAA,OAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,sBAAsB,EAGvB,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKjD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AA6DlC,QAAA,MAAM,aAAa,EAAE,sBAAsB,CACzC,SAAS,EACT,WAAW,CACS,CAAC;AAcvB,eAAe,aAAa,CAAC"}
|
|
@@ -19,6 +19,8 @@ exports.default = void 0;
|
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
23
|
+
|
|
22
24
|
var _useTranslations = _interopRequireDefault(require("../../utils/useTranslations"));
|
|
23
25
|
|
|
24
26
|
var _AvatarContainer = _interopRequireDefault(require("./AvatarContainer"));
|
|
@@ -35,29 +37,60 @@ var _types = require("./types");
|
|
|
35
37
|
|
|
36
38
|
var _schema = _interopRequireDefault(require("./schema"));
|
|
37
39
|
|
|
40
|
+
var _useGravatar3 = _interopRequireDefault(require("./hooks/useGravatar"));
|
|
41
|
+
|
|
38
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
43
|
|
|
40
44
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
41
45
|
|
|
46
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
47
|
+
|
|
48
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
49
|
+
|
|
50
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
51
|
+
|
|
52
|
+
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
53
|
+
|
|
54
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
55
|
+
|
|
42
56
|
function Avatar(props, ref) {
|
|
43
57
|
var ariaLabel = props['aria-label'],
|
|
44
58
|
email = props.email,
|
|
45
59
|
entityType = props.entityType,
|
|
60
|
+
color = props.color,
|
|
46
61
|
kind = props.kind,
|
|
47
62
|
name = props.name,
|
|
63
|
+
palette = props.palette,
|
|
48
64
|
size = props.size,
|
|
49
65
|
indicatorColor = props.indicatorColor;
|
|
50
66
|
var translate = (0, _useTranslations.default)();
|
|
67
|
+
|
|
68
|
+
var _useGravatar = (0, _useGravatar3.default)(props),
|
|
69
|
+
_useGravatar2 = _slicedToArray(_useGravatar, 2),
|
|
70
|
+
gravatarProps = _useGravatar2[0],
|
|
71
|
+
shouldUseGravatar = _useGravatar2[1];
|
|
72
|
+
|
|
73
|
+
(0, _react.useEffect)(function () {
|
|
74
|
+
if (!(0, _isEmpty.default)(kind)) window.console && // eslint-disable-next-line no-console
|
|
75
|
+
console.warn('[KeyDesignSystems] The `kind` prop for the `Avatar` component has been deprecated. Use `color` + `palette` instead.'); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, []); // This is done to not break the now deprecated `secondary` kind variant. Should be removed in the future.
|
|
77
|
+
|
|
78
|
+
var componentColor = kind === 'secondary' ? 'licoriceMousse' : color;
|
|
51
79
|
return _react.default.createElement(_AvatarContainer.default, {
|
|
52
80
|
ref: ref,
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
size: size,
|
|
82
|
+
palette: palette,
|
|
83
|
+
color: componentColor,
|
|
84
|
+
shouldUseGravatar: shouldUseGravatar
|
|
55
85
|
}, _react.default.createElement("span", {
|
|
56
86
|
"aria-label": translate(ariaLabel, 'avatar.aria.label', {
|
|
57
87
|
descriptor: name || email || entityType
|
|
58
88
|
}),
|
|
59
89
|
role: "img"
|
|
60
|
-
}, _react.default.createElement(_AvatarContent.default,
|
|
90
|
+
}, _react.default.createElement(_AvatarContent.default, _extends({
|
|
91
|
+
gravatarProps: gravatarProps,
|
|
92
|
+
shouldUseGravatar: shouldUseGravatar
|
|
93
|
+
}, props))), indicatorColor && indicatorColor in _commonUIColors.commonUIColors && _react.default.createElement(_AvatarIndicator.default, {
|
|
61
94
|
size: size,
|
|
62
95
|
color: indicatorColor
|
|
63
96
|
}));
|
|
@@ -68,10 +101,11 @@ AvatarWithRef.propTypes = _schema.default.propTypes;
|
|
|
68
101
|
AvatarWithRef.defaultProps = {
|
|
69
102
|
email: undefined,
|
|
70
103
|
entityType: _constants.entityTypes.person,
|
|
71
|
-
kind: _constants.kinds.primary,
|
|
72
104
|
name: undefined,
|
|
73
105
|
size: _constants.sizes.medium,
|
|
74
|
-
indicatorColor: undefined
|
|
106
|
+
indicatorColor: undefined,
|
|
107
|
+
color: 'information',
|
|
108
|
+
palette: 'bright'
|
|
75
109
|
};
|
|
76
110
|
var _default = AvatarWithRef;
|
|
77
111
|
exports.default = _default;
|
|
@@ -10,6 +10,8 @@ var _constants = require("./constants");
|
|
|
10
10
|
|
|
11
11
|
var _commonUIColors = require("../../utils/commonUIColors");
|
|
12
12
|
|
|
13
|
+
var _palette = require("../../modifiers/palette");
|
|
14
|
+
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
|
|
15
17
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -25,6 +27,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
25
27
|
var modifierMap = {
|
|
26
28
|
kind: Object.values(_constants.kinds),
|
|
27
29
|
size: Object.values(_constants.sizes),
|
|
30
|
+
palette: Object.keys(_palette.PALETTE_MAPPER),
|
|
31
|
+
color: Object.keys(_commonUIColors.commonUIColors),
|
|
28
32
|
indicatorColor: Object.keys(_commonUIColors.commonUIColors)
|
|
29
33
|
};
|
|
30
34
|
describe('Avatar', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/schema.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,KAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/schema.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,KAAsC,CAAC;AAwCnD,eAAe,MAAM,CAAC"}
|
|
@@ -15,8 +15,10 @@ var schema = (0, _reactDesc.describe)({
|
|
|
15
15
|
});
|
|
16
16
|
schema.propTypes = {
|
|
17
17
|
email: _reactDesc.PropTypes.string.description("The entity's email address. Used in Gravatar image lookup."),
|
|
18
|
+
color: _reactDesc.PropTypes.string.description('(See note) Sets the color for the background and the icon').defaultValue('information'),
|
|
18
19
|
entityType: _reactDesc.PropTypes.oneOf(Object.values(_constants.entityTypes)).description('Selects the entity type represented.').defaultValue('person'),
|
|
19
|
-
|
|
20
|
+
palette: _reactDesc.PropTypes.oneOf(['bright', 'pastel', 'dark']).description('What color variant to render').defaultValue('bright'),
|
|
21
|
+
kind: _reactDesc.PropTypes.oneOfType([_reactDesc.PropTypes.oneOf(Object.values(_constants.kinds))]).description('***DEPRECATED*** Use color + palette instead. Selects the kind of Avatar.').defaultValue('primary').format('***DEPRECATED*** string').deprecated('Use color + palette instead'),
|
|
20
22
|
name: _reactDesc.PropTypes.string.description("The entity's name. First letter of first and last words used to generate initials."),
|
|
21
23
|
size: _reactDesc.PropTypes.oneOfType([_reactDesc.PropTypes.oneOf(Object.values(_constants.sizes))]).description('Selects the size desired.'),
|
|
22
24
|
indicatorColor: _reactDesc.PropTypes.string.description('(See note) Sets the indicator color')
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
1
|
+
import { HTMLAttributes, Ref } from 'react';
|
|
2
2
|
import { entityTypes, kinds, sizes } from './constants';
|
|
3
3
|
import { CommonUIColorKeys } from '../../utils/commonUIColors';
|
|
4
|
+
import { GravatarProps, ShouldUseGravatar } from './hooks/useGravatar';
|
|
4
5
|
export declare type AvatarRef = HTMLDivElement;
|
|
5
|
-
export interface AvatarProps extends
|
|
6
|
+
export interface AvatarProps extends HTMLAttributes<HTMLElement> {
|
|
7
|
+
color?: CommonUIColorKeys;
|
|
6
8
|
email?: string;
|
|
7
9
|
entityType?: keyof typeof entityTypes;
|
|
8
10
|
indicatorColor?: CommonUIColorKeys;
|
|
9
11
|
kind?: keyof typeof kinds;
|
|
10
12
|
name?: string;
|
|
13
|
+
palette?: 'pastel' | 'bright' | 'dark';
|
|
11
14
|
ref?: Ref<AvatarRef>;
|
|
12
15
|
size?: keyof typeof sizes;
|
|
13
16
|
}
|
|
17
|
+
export interface AvatarContentProps extends AvatarProps {
|
|
18
|
+
gravatarProps: GravatarProps;
|
|
19
|
+
shouldUseGravatar: ShouldUseGravatar;
|
|
20
|
+
}
|
|
21
|
+
export interface AvatarContainerProps {
|
|
22
|
+
color?: CommonUIColorKeys;
|
|
23
|
+
palette?: 'pastel' | 'bright' | 'dark';
|
|
24
|
+
size?: keyof typeof sizes;
|
|
25
|
+
shouldUseGravatar: ShouldUseGravatar;
|
|
26
|
+
}
|
|
14
27
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Avatar/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,oBAAY,SAAS,GAAG,cAAc,CAAC;AAEvC,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC;IACtC,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvC,GAAG,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,OAAO,KAAK,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/styles.ts"],"names":[],"mappings":"AAeA,OAAO,EAAa,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAahE,UAAU,YAAa,SAAQ,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,aAAK,cAAc,GAAG,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAkBhF,eAAO,MAAM,OAAO,8EAkCnB,CAAC;AAqHF,eAAO,MAAM,SAAS,gFAqDrB,CAAC"}
|
|
@@ -17,6 +17,8 @@ var _commonUIColors = require("../../utils/commonUIColors");
|
|
|
17
17
|
|
|
18
18
|
var _color = _interopRequireDefault(require("../../modifiers/color"));
|
|
19
19
|
|
|
20
|
+
var _palette = require("../../modifiers/palette");
|
|
21
|
+
|
|
20
22
|
var _focusRingWithColor = _interopRequireDefault(require("../../utils/focusRingWithColor"));
|
|
21
23
|
|
|
22
24
|
var _styleModifiers = require("../../utils/styleModifiers");
|
|
@@ -38,23 +40,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
38
40
|
var _designTokens$color = _designTokens.default.color,
|
|
39
41
|
interactionColors = _designTokens$color.interaction,
|
|
40
42
|
statusColors = _designTokens$color.status;
|
|
41
|
-
var PALETTE_MAPPER = {
|
|
42
|
-
pastel: 'light',
|
|
43
|
-
bright: 'medium',
|
|
44
|
-
dark: 'dark'
|
|
45
|
-
};
|
|
46
|
-
var FG_COLOR = {
|
|
47
|
-
pastel: _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
48
|
-
alpha: 0.8
|
|
49
|
-
}),
|
|
50
|
-
bright: _designTokens.color.base.snowWhite,
|
|
51
|
-
dark: _designTokens.color.base.snowWhite
|
|
52
|
-
};
|
|
53
|
-
var BORDER_OPACITY = {
|
|
54
|
-
pastel: 0.1,
|
|
55
|
-
bright: 0.15,
|
|
56
|
-
dark: 0.3
|
|
57
|
-
};
|
|
58
43
|
|
|
59
44
|
var getContentMaxWidth = function getContentMaxWidth(props) {
|
|
60
45
|
var isSingleChild = props.isSingleChild,
|
|
@@ -78,7 +63,7 @@ var Content = _styledComponents.default.div.withConfig({
|
|
|
78
63
|
var _ref$palette = _ref.palette,
|
|
79
64
|
palette = _ref$palette === void 0 ? 'bright' : _ref$palette;
|
|
80
65
|
return (0, _toColorString.default)(_objectSpread({}, _designTokens.color.base.charcoal, {
|
|
81
|
-
alpha: BORDER_OPACITY[palette]
|
|
66
|
+
alpha: _palette.BORDER_OPACITY[palette]
|
|
82
67
|
}));
|
|
83
68
|
}, function (_ref2) {
|
|
84
69
|
var isSingleChild = _ref2.isSingleChild;
|
|
@@ -98,34 +83,13 @@ var contentSVGColor = function contentSVGColor(_ref3) {
|
|
|
98
83
|
return null;
|
|
99
84
|
};
|
|
100
85
|
|
|
101
|
-
var getColorByProps = function getColorByProps(_ref4) {
|
|
102
|
-
var variant = _ref4.variant,
|
|
103
|
-
colorProp = _ref4.color,
|
|
104
|
-
_ref4$palette = _ref4.palette,
|
|
105
|
-
palette = _ref4$palette === void 0 ? 'bright' : _ref4$palette;
|
|
106
|
-
if (variant === 'outline') return _objectSpread({}, _designTokens.color.base.snowWhite, {
|
|
107
|
-
fg: _designTokens.color.base.alaskanHusky
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
if (colorProp && colorProp in _commonUIColors.commonUIThreeShadeColors) {
|
|
111
|
-
var baseColor = _commonUIColors.commonUIThreeShadeColors[colorProp];
|
|
112
|
-
var fgColor = FG_COLOR[palette];
|
|
113
|
-
var bgColor = baseColor[PALETTE_MAPPER[palette]];
|
|
114
|
-
return palette === 'bright' ? bgColor : _objectSpread({}, bgColor, {
|
|
115
|
-
fg: fgColor
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return _commonUIColors.commonUIColors.licoriceMousse;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
86
|
var actionColors = {
|
|
123
87
|
normal: (0, _toColorString.default)(interactionColors.indianOcean),
|
|
124
88
|
danger: (0, _toColorString.default)(statusColors.danger.medium)
|
|
125
89
|
};
|
|
126
90
|
|
|
127
|
-
var actionColor = function actionColor(
|
|
128
|
-
var actionIntent =
|
|
91
|
+
var actionColor = function actionColor(_ref4) {
|
|
92
|
+
var actionIntent = _ref4.actionIntent;
|
|
129
93
|
return actionColors[actionIntent !== 'danger' ? 'normal' : 'danger'];
|
|
130
94
|
};
|
|
131
95
|
|
|
@@ -134,10 +98,12 @@ var colorModifiers = function colorModifiers(props) {
|
|
|
134
98
|
palette = _props$palette === void 0 ? 'bright' : _props$palette;
|
|
135
99
|
|
|
136
100
|
var borderColor = _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
137
|
-
alpha: BORDER_OPACITY[palette]
|
|
101
|
+
alpha: _palette.BORDER_OPACITY[palette]
|
|
138
102
|
});
|
|
139
103
|
|
|
140
|
-
return (0, _styledComponents.css)(["", "
|
|
104
|
+
return (0, _styledComponents.css)(["", " ", " ", ""], (0, _palette.withBorderedPalette)(props), (0, _styleModifiers.when)('variant', 'outline', (0, _styledComponents.css)(["", ""], (0, _color.default)(_objectSpread({}, _designTokens.color.base.snowWhite, {
|
|
105
|
+
fg: _designTokens.color.base.alaskanHusky
|
|
106
|
+
})))), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["&:hover{box-shadow:inset 0 0 0 ", " ", ";", "{border-color:transparent;}}"], (0, _rem.default)(100), (0, _toColorString.default)(borderColor), Content)));
|
|
141
107
|
};
|
|
142
108
|
|
|
143
109
|
var variantModifiers = function variantModifiers(props) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FlattenSimpleInterpolation } from 'styled-components';
|
|
2
|
+
import { CommonUIColorKeys } from '../utils/commonUIColors';
|
|
3
|
+
export interface PaletteProps {
|
|
4
|
+
color?: CommonUIColorKeys;
|
|
5
|
+
palette?: 'pastel' | 'bright' | 'dark';
|
|
6
|
+
}
|
|
7
|
+
export declare const PALETTE_MAPPER: {
|
|
8
|
+
readonly pastel: "light";
|
|
9
|
+
readonly bright: "medium";
|
|
10
|
+
readonly dark: "dark";
|
|
11
|
+
};
|
|
12
|
+
export declare const FG_COLOR: {
|
|
13
|
+
pastel: {
|
|
14
|
+
readonly alpha: 0.8;
|
|
15
|
+
readonly red: number;
|
|
16
|
+
readonly green: number;
|
|
17
|
+
readonly blue: number;
|
|
18
|
+
readonly fg: import("polished/lib/types/color").RgbColor | import("polished/lib/types/color").RgbaColor;
|
|
19
|
+
} | {
|
|
20
|
+
readonly alpha: 0.8;
|
|
21
|
+
readonly red: number;
|
|
22
|
+
readonly green: number;
|
|
23
|
+
readonly blue: number;
|
|
24
|
+
readonly fg: import("polished/lib/types/color").RgbColor | import("polished/lib/types/color").RgbaColor;
|
|
25
|
+
};
|
|
26
|
+
readonly bright: import("@decisiv/design-tokens/lib/color").Color;
|
|
27
|
+
readonly dark: import("@decisiv/design-tokens/lib/color").Color;
|
|
28
|
+
};
|
|
29
|
+
export declare const BORDER_OPACITY: {
|
|
30
|
+
readonly pastel: 0.1;
|
|
31
|
+
readonly bright: 0.15;
|
|
32
|
+
readonly dark: 0.3;
|
|
33
|
+
};
|
|
34
|
+
export declare function withPalette(props: PaletteProps): FlattenSimpleInterpolation;
|
|
35
|
+
export declare function withBorderedPalette(props: PaletteProps): FlattenSimpleInterpolation;
|
|
36
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/modifiers/palette.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,EAE3B,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAGL,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC;AAED,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;CAIX,CAAC;AAEX,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AA2BX,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,0BAA0B,CAI3E;AAKD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,GAClB,0BAA0B,CAa5B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withPalette = withPalette;
|
|
7
|
+
exports.withBorderedPalette = withBorderedPalette;
|
|
8
|
+
exports.BORDER_OPACITY = exports.FG_COLOR = exports.PALETTE_MAPPER = void 0;
|
|
9
|
+
|
|
10
|
+
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = require("styled-components");
|
|
13
|
+
|
|
14
|
+
var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
|
|
15
|
+
|
|
16
|
+
var _color2 = _interopRequireDefault(require("./color"));
|
|
17
|
+
|
|
18
|
+
var _commonUIColors = require("../utils/commonUIColors");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
23
|
+
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
25
|
+
|
|
26
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
+
|
|
28
|
+
var PALETTE_MAPPER = {
|
|
29
|
+
pastel: 'light',
|
|
30
|
+
bright: 'medium',
|
|
31
|
+
dark: 'dark'
|
|
32
|
+
};
|
|
33
|
+
exports.PALETTE_MAPPER = PALETTE_MAPPER;
|
|
34
|
+
var FG_COLOR = {
|
|
35
|
+
pastel: _objectSpread({}, _color.default.base.charcoal, {
|
|
36
|
+
alpha: 0.8
|
|
37
|
+
}),
|
|
38
|
+
bright: _color.default.base.snowWhite,
|
|
39
|
+
dark: _color.default.base.snowWhite
|
|
40
|
+
};
|
|
41
|
+
exports.FG_COLOR = FG_COLOR;
|
|
42
|
+
var BORDER_OPACITY = {
|
|
43
|
+
pastel: 0.1,
|
|
44
|
+
bright: 0.15,
|
|
45
|
+
dark: 0.3
|
|
46
|
+
};
|
|
47
|
+
exports.BORDER_OPACITY = BORDER_OPACITY;
|
|
48
|
+
|
|
49
|
+
var colorModifiers = function colorModifiers(props) {
|
|
50
|
+
var _props$palette = props.palette,
|
|
51
|
+
palette = _props$palette === void 0 ? 'bright' : _props$palette,
|
|
52
|
+
colorProp = props.color;
|
|
53
|
+
|
|
54
|
+
if (colorProp && colorProp in _commonUIColors.commonUIColors) {
|
|
55
|
+
var baseColor = _commonUIColors.commonUIThreeShadeColors[colorProp];
|
|
56
|
+
var fgColor = FG_COLOR[palette];
|
|
57
|
+
var bgColor = baseColor[PALETTE_MAPPER[palette]];
|
|
58
|
+
var colorPalette = palette === 'bright' ? bgColor : _objectSpread({}, bgColor, {
|
|
59
|
+
fg: fgColor
|
|
60
|
+
});
|
|
61
|
+
return (0, _styledComponents.css)(["", ""], (0, _color2.default)(colorPalette));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (0, _styledComponents.css)(["", ""], (0, _color2.default)(_commonUIColors.commonUIColors.licoriceMousse));
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Helper to apply the palette color Interpolation
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
function withPalette(props) {
|
|
72
|
+
return (0, _styledComponents.css)(["", ""], colorModifiers(props));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Helper to apply the palette color Interpolation with borders
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
function withBorderedPalette(props) {
|
|
80
|
+
var _props$palette2 = props.palette,
|
|
81
|
+
palette = _props$palette2 === void 0 ? 'bright' : _props$palette2;
|
|
82
|
+
|
|
83
|
+
var borderColor = _objectSpread({}, _color.default.base.charcoal, {
|
|
84
|
+
alpha: BORDER_OPACITY[palette]
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return (0, _styledComponents.css)(["", " border:1px solid ", ";"], colorModifiers(props), (0, _toColorString.default)(borderColor));
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.182+bbde1e2",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "bbde1e2883ce206cad4795fb09e444750b2cc535"
|
|
75
75
|
}
|