@decisiv/ui-components 2.0.1-alpha.176 → 2.0.1-alpha.177

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAmB,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAQvE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAsDhC,QAAA,MAAM,YAAY,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAE9D,CAAC;AAQF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAmB,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAC;AAIxE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAWhC,QAAA,MAAM,YAAY,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAE9D,CAAC;AAQF,eAAe,YAAY,CAAC"}
@@ -19,21 +19,9 @@ exports.default = void 0;
19
19
 
20
20
  var _react = _interopRequireWildcard(require("react"));
21
21
 
22
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
-
24
- var _styledComponentsModifiers = require("styled-components-modifiers");
25
-
26
- var _color = _interopRequireDefault(require("../../modifiers/color"));
27
-
28
- var _constants = require("./constants");
29
-
30
- var _commonUIColors = require("../../utils/commonUIColors");
31
-
32
- var _utils = require("../../utils");
33
-
34
22
  var _types = require("./types");
35
23
 
36
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ var _styles = require("./styles");
37
25
 
38
26
  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; } }
39
27
 
@@ -43,57 +31,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
43
31
 
44
32
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
45
33
 
46
- var colorModifiers = (0, _utils.applyDynamicModifiers)('color', function (_ref) {
47
- var color = _ref.color;
48
- return (0, _styledComponents.css)(["", ""], color && color in _commonUIColors.commonUIColors && (0, _color.default)(_commonUIColors.commonUIColors[color]));
49
- });
50
-
51
- var getSizeStyles = function getSizeStyles(key) {
52
- return (0, _styledComponents.css)(_constants.sizeStyles[key] || '');
53
- };
54
-
55
- var sizeModifiers = (0, _styledComponentsModifiers.applyStyleModifiers)({
56
- small: function small(_ref2) {
57
- var v = _ref2.variant;
58
- return getSizeStyles("small.".concat(v));
59
- },
60
- medium: function medium(_ref3) {
61
- var v = _ref3.variant;
62
- return getSizeStyles("medium.".concat(v));
63
- },
64
- large: function large(_ref4) {
65
- var v = _ref4.variant;
66
- return getSizeStyles("large.".concat(v));
67
- }
68
- }, 'size');
69
- var variantModifiers = (0, _styledComponentsModifiers.applyStyleModifiers)({
70
- round: function round() {
71
- return (0, _styledComponents.css)({
72
- borderRadius: '50%'
73
- });
74
- },
75
- square: function square() {
76
- return (0, _styledComponents.css)({
77
- borderRadius: '2px'
78
- });
79
- }
80
- }, 'variant'); // The default coloring is explicitly set instead of relying on the
81
- // `visualInterest.licoriceMousse.medium` colors. The "default" badge is
82
- // intended to be used in “empty” and/or “no results” messages, the snowWhite
83
- // fg color and lower contrast help convey “emptiness”.
84
-
85
- var BadgeContainer = _styledComponents.default.div.withConfig({
86
- displayName: "Badge__BadgeContainer",
87
- componentId: "sc-1y6oxgp-0"
88
- })(["align-items:center;display:inline-flex;justify-content:center;", ";", ";", ";", ";"], (0, _color.default)(_commonUIColors.commonUIColors.information), colorModifiers, sizeModifiers, variantModifiers);
89
-
90
34
  function Badge(props, containerRef) {
91
35
  var ariaLabel = props['aria-label'],
92
36
  Icon = props.icon,
93
37
  size = props.size,
94
38
  rest = _objectWithoutProperties(props, ["aria-label", "icon", "size"]);
95
39
 
96
- return _react.default.createElement(BadgeContainer, _extends({
40
+ return _react.default.createElement(_styles.BadgeContainer, _extends({
97
41
  ref: containerRef,
98
42
  size: size
99
43
  }, rest), _react.default.createElement(Icon, {
@@ -55,12 +55,23 @@ describe('Badge', function () {
55
55
  expect(container).toMatchSnapshot();
56
56
  });
57
57
  });
58
+ ['bright', 'pastel'].forEach(function (palette) {
59
+ it("renders correctly with palette=\"".concat(palette, "\""), function () {
60
+ var _renderBadge3 = renderBadge({
61
+ palette: palette,
62
+ color: 'carrotCake'
63
+ }),
64
+ container = _renderBadge3.container;
65
+
66
+ expect(container).toMatchSnapshot();
67
+ });
68
+ });
58
69
  it("renders correctly with size=\"small\" and variant=\"square\"", function () {
59
- var _renderBadge3 = renderBadge({
70
+ var _renderBadge4 = renderBadge({
60
71
  size: 'small',
61
72
  variant: 'square'
62
73
  }),
63
- container = _renderBadge3.container;
74
+ container = _renderBadge4.container;
64
75
 
65
76
  expect(container).toMatchSnapshot();
66
77
  });
@@ -70,10 +81,10 @@ describe('Badge', function () {
70
81
  key = _ref2[0],
71
82
  value = _ref2[1];
72
83
 
73
- var _renderBadge4 = renderBadge({
84
+ var _renderBadge5 = renderBadge({
74
85
  color: key
75
86
  }),
76
- container = _renderBadge4.container;
87
+ container = _renderBadge5.container;
77
88
 
78
89
  expect(container.firstChild).toHaveStyleRule('background-color', (0, _toColorString.default)(value));
79
90
  });
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAqC,CAAC;AAwBlD,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAqC,CAAC;AA4BlD,eAAe,MAAM,CAAC"}
@@ -15,6 +15,7 @@ schema.propTypes = {
15
15
  'aria-label': _reactDesc.PropTypes.string.description('Descriptive text for accessibility purposes').isRequired,
16
16
  color: _reactDesc.PropTypes.string.description('(See note) Sets the color for the background and the icon').defaultValue('information'),
17
17
  icon: _reactDesc.PropTypes.element.description('Must be an icon component from `@decisiv/iconix`').isRequired,
18
+ palette: _reactDesc.PropTypes.oneOf(['bright', 'pastel']).description('What color variant to render').defaultValue('bright'),
18
19
  size: _reactDesc.PropTypes.oneOf(['small', 'medium', 'large']).description('(See note) Sets the size of the badge').defaultValue('medium'),
19
20
  variant: _reactDesc.PropTypes.oneOf(['round', 'square']).description('(See note) Controls primary style variations of the badge').defaultValue('round')
20
21
  };
@@ -0,0 +1,3 @@
1
+ import { BadgeProps } from './types';
2
+ export declare const BadgeContainer: import("styled-components").StyledComponent<"div", any, Pick<BadgeProps, "variant" | "size" | "color" | "palette">, never>;
3
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/styles.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA+DrC,eAAO,MAAM,cAAc,4HAQ1B,CAAC"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BadgeContainer = void 0;
7
+
8
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+
10
+ var _styledComponentsModifiers = require("styled-components-modifiers");
11
+
12
+ var _designTokens = require("@decisiv/design-tokens");
13
+
14
+ var _color = _interopRequireDefault(require("../../modifiers/color"));
15
+
16
+ var _constants = require("./constants");
17
+
18
+ var _commonUIColors = require("../../utils/commonUIColors");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
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; } }
23
+
24
+ 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; }
25
+
26
+ 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; }
27
+
28
+ 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; }
29
+
30
+ var FG_COLOR = {
31
+ pastel: 'dark'
32
+ };
33
+ var PALETTE_MAPPER = {
34
+ pastel: 'light',
35
+ bright: 'medium'
36
+ };
37
+
38
+ var colorModifiers = function colorModifiers(props) {
39
+ var _props$palette = props.palette,
40
+ palette = _props$palette === void 0 ? 'bright' : _props$palette,
41
+ color = props.color;
42
+
43
+ if (color && color in _commonUIColors.commonUIColors) {
44
+ var baseColor = _commonUIColors.commonUIThreeShadeColors[color];
45
+ var fgColor = palette === 'bright' ? _designTokens.color.base.snowWhite : baseColor[FG_COLOR[palette]];
46
+ var bgColor = baseColor[PALETTE_MAPPER[palette]];
47
+ var colorPalette = palette === 'bright' ? bgColor : _objectSpread({}, bgColor, {
48
+ fg: fgColor
49
+ });
50
+ return (0, _styledComponents.css)(["", ""], (0, _color.default)(colorPalette));
51
+ }
52
+
53
+ return null;
54
+ };
55
+
56
+ var getSizeStyles = function getSizeStyles(key) {
57
+ return (0, _styledComponents.css)(_constants.sizeStyles[key] || '');
58
+ };
59
+
60
+ var sizeModifiers = (0, _styledComponentsModifiers.applyStyleModifiers)({
61
+ small: function small(_ref) {
62
+ var v = _ref.variant;
63
+ return getSizeStyles("small.".concat(v));
64
+ },
65
+ medium: function medium(_ref2) {
66
+ var v = _ref2.variant;
67
+ return getSizeStyles("medium.".concat(v));
68
+ },
69
+ large: function large(_ref3) {
70
+ var v = _ref3.variant;
71
+ return getSizeStyles("large.".concat(v));
72
+ }
73
+ }, 'size');
74
+ var variantModifiers = (0, _styledComponentsModifiers.applyStyleModifiers)({
75
+ round: function round() {
76
+ return (0, _styledComponents.css)({
77
+ borderRadius: '50%'
78
+ });
79
+ },
80
+ square: function square() {
81
+ return (0, _styledComponents.css)({
82
+ borderRadius: '2px'
83
+ });
84
+ }
85
+ }, 'variant'); // The default coloring is explicitly set instead of relying on the
86
+ // `visualInterest.licoriceMousse.medium` colors. The "default" badge is
87
+ // intended to be used in “empty” and/or “no results” messages, the snowWhite
88
+ // fg color and lower contrast help convey “emptiness”.
89
+ // eslint-disable-next-line import/prefer-default-export
90
+
91
+ var BadgeContainer = _styledComponents.default.div.withConfig({
92
+ displayName: "styles__BadgeContainer",
93
+ componentId: "sc-1lruwqa-0"
94
+ })(["align-items:center;display:inline-flex;justify-content:center;", ";", ";", ";"], colorModifiers, sizeModifiers, variantModifiers);
95
+
96
+ exports.BadgeContainer = BadgeContainer;
@@ -8,6 +8,7 @@ export interface BadgeProps {
8
8
  'aria-label': string;
9
9
  color?: CommonUIColorKeys;
10
10
  icon: IconComponent;
11
+ palette?: 'pastel' | 'bright';
11
12
  size?: 'small' | 'medium' | 'large';
12
13
  variant?: 'round' | 'square';
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAIpC,aAAK,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,oBAAY,QAAQ,GAAG,cAAc,CAAC;AAItC,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9B;AAED,iBAAS,gBAAgB,CACvB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,SAAS,EACnB,aAAa,EAAE,OAAO,GACrB,KAAK,GAAG,IAAI,CAqBd;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/types.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,iBAAiB,EAElB,MAAM,4BAA4B,CAAC;AAIpC,aAAK,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,oBAAY,QAAQ,GAAG,cAAc,CAAC;AAItC,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9B;AAED,iBAAS,gBAAgB,CACvB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,SAAS,EACnB,aAAa,EAAE,OAAO,GACrB,KAAK,GAAG,IAAI,CAqBd;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decisiv/ui-components",
3
- "version": "2.0.1-alpha.176+0ca8bda",
3
+ "version": "2.0.1-alpha.177+205e39a",
4
4
  "description": "Decisiv's design system React components",
5
5
  "author": "Decisiv UI Development Team",
6
6
  "license": "MIT",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@decisiv/breakpoint-observer": "^1.8.8",
19
- "@decisiv/design-tokens": "^1.8.9-alpha.294+0ca8bda",
20
- "@decisiv/iconix": "^2.0.1-alpha.176+0ca8bda",
19
+ "@decisiv/design-tokens": "^1.8.8",
20
+ "@decisiv/iconix": "^2.0.0",
21
21
  "@decisiv/prop-types": "^1.6.9",
22
22
  "@seznam/compose-react-refs": "^1.0.2",
23
23
  "csstype": "^2.6.5",
@@ -71,5 +71,5 @@
71
71
  "access": "public"
72
72
  },
73
73
  "private": false,
74
- "gitHead": "0ca8bda2fe88c901881b6fb2262f99c143da7075"
74
+ "gitHead": "205e39a7485f904df27a6656ff9f1f15eeeef354"
75
75
  }