@occmundial/occ-atomic 3.0.0-beta.6 → 3.0.0-beta.8

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [3.0.0-beta.8](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2024-06-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Add border for promote alert ([5050f18](https://github.com/occmundial/occ-atomic/commit/5050f187b60f98118654ecbbe3e2cba7b29790ab))
7
+ * Add min height to tip container ([579d263](https://github.com/occmundial/occ-atomic/commit/579d26306d59ce73b5084f9cd632dd12ed162fc5))
8
+ * Resolve conflicts ([0a15dfa](https://github.com/occmundial/occ-atomic/commit/0a15dfa8d8da38a724d71622809f0e02c5bed0e9))
9
+
10
+
11
+ ### Features
12
+
13
+ * Render tip in banner component ([239e2c8](https://github.com/occmundial/occ-atomic/commit/239e2c82c23d79698bd912931b314ceddf252fb4))
14
+ * Update tip component with new design tokens ([b2367fc](https://github.com/occmundial/occ-atomic/commit/b2367fcaade288609df4c841c91fb308841ae4b0))
15
+
16
+
17
+ ### Performance Improvements
18
+
19
+ * Memoize text replace in tip text component ([69180ce](https://github.com/occmundial/occ-atomic/commit/69180ce9cb1e812769e31a837257d8c8e6f24199))
20
+
21
+ # [3.0.0-beta.7](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2024-06-06)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * Fix radio styles and add a form nav behavior ([59f0320](https://github.com/occmundial/occ-atomic/commit/59f03207a45b1ec27e02970668cffe2cfd5931a9))
27
+ * Ignore tab index if radio element is disabled ([e479098](https://github.com/occmundial/occ-atomic/commit/e4790982a127408a474f688a4647612ef8fbb446))
28
+
1
29
  # [3.0.0-beta.6](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2024-06-05)
2
30
 
3
31
 
@@ -9,17 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _Flexbox = _interopRequireDefault(require("../Flexbox"));
13
-
14
- var _WindowSize = _interopRequireDefault(require("../WindowSize"));
15
-
16
- var _Text = _interopRequireDefault(require("../Text"));
17
-
18
- var _Icon = _interopRequireDefault(require("../Icon"));
19
-
20
12
  var _grid = _interopRequireDefault(require("../subatomic/grid"));
21
13
 
22
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
14
+ var _Tip = _interopRequireDefault(require("../Tip"));
23
15
 
24
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
17
 
@@ -27,38 +19,27 @@ var Banner = function Banner(_ref) {
27
19
  var id = _ref.id,
28
20
  style = _ref.style,
29
21
  className = _ref.className,
30
- classes = _ref.classes,
31
22
  children = _ref.children,
32
23
  onClose = _ref.onClose,
33
- winWidth = _ref.winWidth;
34
- var isMobile = winWidth < _grid["default"].xs;
35
- return /*#__PURE__*/_react["default"].createElement("div", {
24
+ winWidth = _ref.winWidth,
25
+ cta = _ref.cta,
26
+ _ref$theme = _ref.theme,
27
+ theme = _ref$theme === void 0 ? 'promote' : _ref$theme;
28
+ return /*#__PURE__*/_react["default"].createElement(_Tip["default"], {
36
29
  id: id,
30
+ style: style,
37
31
  className: className,
38
- style: style
39
- }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
40
- display: "flex",
41
- className: classes.container
42
- }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
43
- flex: "1",
44
- className: classes.textFlex
45
- }, /*#__PURE__*/_react["default"].createElement(_Text["default"], {
46
- white: true,
47
- small: isMobile,
48
- tag: "div",
49
- className: classes.textBanner
50
- }, children)), /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
51
- className: classes.iconFlex
52
- }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
53
- iconName: "close",
54
- colors: [_colors["default"].bgWhite],
55
- onClick: onClose,
56
- className: classes.icon
57
- }))));
32
+ onClose: onClose,
33
+ size: winWidth < _grid["default"].xs ? 'small' : 'large',
34
+ center: true,
35
+ type: "banner",
36
+ cta: cta,
37
+ theme: theme,
38
+ icon: true
39
+ }, children);
58
40
  };
59
41
 
60
42
  Banner.propTypes = {
61
- classes: _propTypes["default"].object.isRequired,
62
43
  winWidth: _propTypes["default"].number,
63
44
 
64
45
  /** Text of the tip. If you put text between two * characters that text will be displayed as bold. */
@@ -68,9 +49,14 @@ Banner.propTypes = {
68
49
  id: _propTypes["default"].string,
69
50
  className: _propTypes["default"].string,
70
51
  style: _propTypes["default"].object,
71
- onClose: _propTypes["default"].func
52
+ onClose: _propTypes["default"].func,
53
+ cta: _propTypes["default"].shape({
54
+ text: _propTypes["default"].string,
55
+ href: _propTypes["default"].string,
56
+ target: _propTypes["default"].string,
57
+ onClick: _propTypes["default"].func
58
+ }),
59
+ theme: _propTypes["default"].oneOf(['info', 'warning', 'success', 'error', 'promote'])
72
60
  };
73
-
74
- var _default = (0, _WindowSize["default"])(Banner);
75
-
61
+ var _default = Banner;
76
62
  exports["default"] = _default;
@@ -13,6 +13,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _Text = _interopRequireDefault(require("../Text"));
15
15
 
16
+ var _Tag = _interopRequireDefault(require("../Tag"));
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
19
 
18
20
  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); }
@@ -75,6 +77,14 @@ var Radio = /*#__PURE__*/function (_React$Component) {
75
77
  if (onChange) onChange(option.value);
76
78
  }
77
79
  }
80
+ }, {
81
+ key: "handleKeyDown",
82
+ value: function handleKeyDown(e, option) {
83
+ if (e.keyCode == 13 || e.keyCode == 32) {
84
+ e.preventDefault();
85
+ this.onChange(option);
86
+ }
87
+ }
78
88
  }, {
79
89
  key: "render",
80
90
  value: function render() {
@@ -87,6 +97,7 @@ var Radio = /*#__PURE__*/function (_React$Component) {
87
97
  id = _this$props.id,
88
98
  textOverflow = _this$props.textOverflow,
89
99
  className = _this$props.className,
100
+ alignLeft = _this$props.alignLeft,
90
101
  style = _this$props.style;
91
102
  return /*#__PURE__*/_react["default"].createElement("div", {
92
103
  id: id
@@ -94,7 +105,10 @@ var Radio = /*#__PURE__*/function (_React$Component) {
94
105
  return /*#__PURE__*/_react["default"].createElement("div", _extends({
95
106
  id: option.trk,
96
107
  key: option.value,
97
- tabIndex: -1,
108
+ tabIndex: option.disabled ? -1 : 0,
109
+ onKeyDown: function onKeyDown(e) {
110
+ return _this2.handleKeyDown(e, option);
111
+ },
98
112
  "data-testid": option.testId
99
113
  }, option.testId && {
100
114
  'data-value': selected == option.value ? 1 : 0
@@ -109,12 +123,15 @@ var Radio = /*#__PURE__*/function (_React$Component) {
109
123
  id: option.trk
110
124
  }), option.label && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
111
125
  tag: "label",
112
- className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '')
126
+ className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '').concat(alignLeft ? " ".concat(classes.alignLeft) : '')
113
127
  }, option.label), option.right && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
114
128
  tag: "label",
115
129
  corpSecondary: true,
116
130
  className: classes.right
117
- }, option.right));
131
+ }, option.right), option.tag && /*#__PURE__*/_react["default"].createElement(_Tag["default"], {
132
+ theme: "link",
133
+ className: classes.tag
134
+ }, option.tag));
118
135
  }));
119
136
  }
120
137
  }]);
@@ -139,6 +156,7 @@ Radio.propTypes = {
139
156
  value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
140
157
  label: _propTypes["default"].string,
141
158
  right: _propTypes["default"].string,
159
+ tag: _propTypes["default"].string,
142
160
  trk: _propTypes["default"].string,
143
161
 
144
162
  /** The testId property adds the data attribute data-testid to
@@ -146,6 +164,9 @@ Radio.propTypes = {
146
164
  testId: _propTypes["default"].string
147
165
  })),
148
166
 
167
+ /** Align the content to the left */
168
+ alignLeft: _propTypes["default"].bool,
169
+
149
170
  /** Use this prop to overflow the text of the label, adding '...' and the end. */
150
171
  textOverflow: _propTypes["default"].bool,
151
172
 
@@ -15,6 +15,9 @@ Object {
15
15
  },
16
16
  },
17
17
  },
18
+ "alignLeft": Object {
19
+ "flex": "none",
20
+ },
18
21
  "cont": Object {
19
22
  "&$active": Object {
20
23
  "&:active": Object {
@@ -24,7 +27,6 @@ Object {
24
27
  "& $radio:before": Object {
25
28
  "borderColor": "#0047A5",
26
29
  "borderWidth": "3px",
27
- "boxShadow": "initial",
28
30
  },
29
31
  },
30
32
  "&:focus $radio:before": Object {
@@ -37,7 +39,6 @@ Object {
37
39
  },
38
40
  "& $radio:before": Object {
39
41
  "borderColor": "#0047A5",
40
- "boxShadow": "initial",
41
42
  },
42
43
  },
43
44
  },
@@ -56,7 +57,7 @@ Object {
56
57
  "boxShadow": "initial",
57
58
  },
58
59
  },
59
- "alignItems": "start",
60
+ "alignItems": "center",
60
61
  "boxSizing": "border-box",
61
62
  "cursor": "pointer",
62
63
  "display": "flex",
@@ -122,8 +123,11 @@ Object {
122
123
  "position": "absolute",
123
124
  "top": "50%",
124
125
  "transform": "translate(-50%, -50%)",
126
+ "transition": "0.3s all",
125
127
  "width": 20,
126
128
  },
129
+ "alignItems": "center",
130
+ "display": "flex",
127
131
  "height": "24px",
128
132
  "position": "relative",
129
133
  "width": "24px",
@@ -131,6 +135,11 @@ Object {
131
135
  "right": Object {
132
136
  "float": "right",
133
137
  "marginLeft": "8px",
138
+ "pointerEvents": "none",
139
+ },
140
+ "tag": Object {
141
+ "marginLeft": "8px",
142
+ "pointerEvents": "none",
134
143
  },
135
144
  }
136
145
  `;
@@ -20,7 +20,7 @@ var _default = {
20
20
  paddingBottom: _spacing["default"]['size-2'],
21
21
  boxSizing: 'border-box',
22
22
  display: 'flex',
23
- alignItems: 'start',
23
+ alignItems: 'center',
24
24
  cursor: 'pointer',
25
25
  outline: '0',
26
26
  '&$active': {
@@ -30,8 +30,7 @@ var _default = {
30
30
  },
31
31
  '&:hover': {
32
32
  '& $radio:before': {
33
- borderColor: radio['selected']['border']['hover'],
34
- boxShadow: 'initial'
33
+ borderColor: radio['selected']['border']['hover']
35
34
  },
36
35
  '& $radio:after': {
37
36
  background: radio['selected']['bg']['hover']
@@ -40,8 +39,7 @@ var _default = {
40
39
  '&:active': {
41
40
  '& $radio:before': {
42
41
  borderColor: radio['selected']['border']['hover'],
43
- borderWidth: '3px',
44
- boxShadow: 'initial'
42
+ borderWidth: '3px'
45
43
  },
46
44
  '& $radio:after': {
47
45
  background: radio['selected']['bg']['hover']
@@ -49,10 +47,6 @@ var _default = {
49
47
  }
50
48
  },
51
49
  '&:not($active)': {
52
- '&:focus $radio:before': {
53
- borderColor: radio['unselected']['border']['default'],
54
- boxShadow: _shadows["default"]['focus-bright-blue']
55
- },
56
50
  '&:hover $radio:before': {
57
51
  borderColor: radio['unselected']['border']['hover'],
58
52
  boxShadow: 'initial'
@@ -61,6 +55,10 @@ var _default = {
61
55
  borderColor: radio['unselected']['border']['hover'],
62
56
  borderWidth: '2px',
63
57
  boxShadow: 'initial'
58
+ },
59
+ '&:focus $radio:before': {
60
+ borderColor: radio['unselected']['border']['default'],
61
+ boxShadow: _shadows["default"]['focus-bright-blue']
64
62
  }
65
63
  }
66
64
  },
@@ -68,6 +66,8 @@ var _default = {
68
66
  width: _spacing["default"]['size-5'],
69
67
  height: _spacing["default"]['size-5'],
70
68
  position: 'relative',
69
+ display: 'flex',
70
+ alignItems: 'center',
71
71
  '&:before': {
72
72
  content: '""',
73
73
  boxSizing: 'border-box',
@@ -79,7 +79,8 @@ var _default = {
79
79
  left: '50%',
80
80
  transform: 'translate(-50%, -50%)',
81
81
  border: "1px solid ".concat(radio['unselected']['border']['default']),
82
- background: radio['bg']['default']
82
+ background: radio['bg']['default'],
83
+ transition: '0.3s all'
83
84
  },
84
85
  '&:after': {
85
86
  content: '""',
@@ -136,12 +137,20 @@ var _default = {
136
137
  },
137
138
  right: {
138
139
  marginLeft: _spacing["default"]['size-2'],
139
- "float": 'right'
140
+ "float": 'right',
141
+ pointerEvents: 'none'
140
142
  },
141
143
  overflow: {
142
144
  overflow: 'hidden',
143
145
  textOverflow: 'ellipsis',
144
146
  whiteSpace: 'nowrap'
147
+ },
148
+ tag: {
149
+ marginLeft: _spacing["default"]['size-2'],
150
+ pointerEvents: 'none'
151
+ },
152
+ alignLeft: {
153
+ flex: 'none'
145
154
  }
146
155
  };
147
156
  exports["default"] = _default;
package/build/Tip/Tip.js CHANGED
@@ -1,39 +1,26 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports["default"] = void 0;
9
7
 
10
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
11
9
 
12
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
11
 
14
- var _isString = _interopRequireDefault(require("lodash/isString"));
15
-
16
- var _flatten = _interopRequireDefault(require("lodash/flatten"));
17
-
18
12
  var _Flexbox = _interopRequireDefault(require("../Flexbox"));
19
13
 
20
- var _Text = _interopRequireDefault(require("../Text"));
21
-
22
14
  var _Icon = _interopRequireDefault(require("../Icon"));
23
15
 
24
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ var _Button = _interopRequireDefault(require("../Button"));
27
17
 
28
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ var _TipText = _interopRequireDefault(require("./TipText"));
29
19
 
30
- 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; }
20
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
31
21
 
32
- 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); }
33
-
34
- 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; }
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
23
 
36
- var boldRegex = /\*(.*?)\*/g;
37
24
  var icons = {
38
25
  info: 'info-circle',
39
26
  warning: 'alert',
@@ -42,6 +29,13 @@ var icons = {
42
29
  promote: null
43
30
  };
44
31
  var PROMOTE = 'promote';
32
+ var colorTextClasses = {
33
+ info: 'textInfo',
34
+ promote: 'textPromote',
35
+ warning: 'textWarning',
36
+ success: 'textSuccess',
37
+ error: 'textError'
38
+ };
45
39
  /** Tip component with different themes (info, warning, success & error). You can pass a string or a react element as the children prop, but the bold regex will only work with strings. */
46
40
 
47
41
  var Tip = function Tip(_ref) {
@@ -54,62 +48,12 @@ var Tip = function Tip(_ref) {
54
48
  noBorderRadius = _ref.noBorderRadius,
55
49
  center = _ref.center,
56
50
  onClose = _ref.onClose,
57
- spacedClose = _ref.spacedClose,
58
51
  children = _ref.children,
59
- cta = _ref.cta;
60
-
61
- var replaceStringToBold = function replaceStringToBold() {
62
- if (children === '') return children;
63
- var result = children.split(boldRegex);
64
- if (result.length === 1) return children;
65
-
66
- for (var i = 1, length = result.length; i < length; i += 2) {
67
- result[i] = boldMatch(result[i], i, theme);
68
- }
69
-
70
- return result;
71
- };
72
-
73
- var getTheme = function getTheme() {
74
- if (theme === PROMOTE) return {
75
- white: true
76
- };
77
- return _defineProperty({}, theme, true);
78
- };
79
-
80
- var boldMatch = function boldMatch(match, i) {
81
- return /*#__PURE__*/_react["default"].createElement(_Text["default"], _extends({
82
- key: i,
83
- strong: true,
84
- tag: "b"
85
- }, getTheme()), match);
86
- };
87
-
88
- var getIconName = function getIconName() {
89
- return icons[theme];
90
- };
91
-
92
- var renderText = function renderText() {
93
- var textArray;
94
- if (!Array.isArray(children)) textArray = [children];
95
- var text = (0, _flatten["default"])(textArray.map(function (x) {
96
- return (0, _isString["default"])(x) ? replaceStringToBold(x, theme) : x;
97
- }));
98
-
99
- if (cta) {
100
- text.push( /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, ' ', /*#__PURE__*/_react["default"].createElement("a", {
101
- className: classes.cta,
102
- href: cta.href,
103
- target: cta.target,
104
- onClick: cta.onClick
105
- }, /*#__PURE__*/_react["default"].createElement(_Text["default"], _extends({
106
- tag: "span"
107
- }, getTheme()), cta.text))));
108
- }
109
-
110
- return text;
111
- };
112
-
52
+ cta = _ref.cta,
53
+ _ref$size = _ref.size,
54
+ size = _ref$size === void 0 ? 'large' : _ref$size,
55
+ _ref$type = _ref.type,
56
+ type = _ref$type === void 0 ? 'alert' : _ref$type;
113
57
  return /*#__PURE__*/_react["default"].createElement("div", {
114
58
  id: id,
115
59
  className: className,
@@ -117,26 +61,34 @@ var Tip = function Tip(_ref) {
117
61
  }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
118
62
  justifyContent: "start",
119
63
  display: "flex",
120
- className: "".concat(classes.container, " ").concat(classes[theme]).concat(noBorderRadius ? " ".concat(classes.noBorderRadius) : '')
64
+ className: "".concat(classes.container, " ").concat(classes[theme]).concat(noBorderRadius ? " ".concat(classes.noBorderRadius) : '').concat(size === 'small' ? " ".concat(classes.small) : '')
121
65
  }, /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
122
66
  display: "flex",
123
67
  flex: "1",
124
68
  justifyContent: center ? 'center' : null,
125
- alignItems: "center"
126
- }, icon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
127
- iconName: getIconName(),
69
+ alignItems: "stretch",
70
+ className: type === 'banner' ? classes.bannerContent : ''
71
+ }, icon && theme !== PROMOTE && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
72
+ iconName: icons[theme],
128
73
  className: classes.icon,
129
- colors: [_colors["default"]["".concat(theme, "Text")]]
130
- }), /*#__PURE__*/_react["default"].createElement("div", {
131
- className: icon ? classes.textWithIcon : classes.text
132
- }, /*#__PURE__*/_react["default"].createElement(_Text["default"], _extends({
133
- standard: true,
134
- tag: "div"
135
- }, getTheme()), renderText()))), onClose && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
136
- iconName: "cross",
74
+ colors: [theme === 'info' ? _colors["default"].icon.brand["default"] : _colors["default"].icon[theme]]
75
+ }), /*#__PURE__*/_react["default"].createElement(_Flexbox["default"], {
76
+ display: "flex",
77
+ direction: size === 'small' ? 'col' : 'row'
78
+ }, /*#__PURE__*/_react["default"].createElement(_TipText["default"], {
79
+ classes: "".concat(classes.normalText, " ").concat(classes[colorTextClasses[theme]]),
80
+ text: children
81
+ }), cta && /*#__PURE__*/_react["default"].createElement("a", {
82
+ className: "".concat(classes.cta, " ").concat(size === 'small' ? classes.ctaSmall : classes.ctaLarge, " ").concat(classes[colorTextClasses[theme]]),
83
+ href: cta.href,
84
+ target: cta.target,
85
+ onClick: cta.onClick
86
+ }, cta.text))), onClose && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
137
87
  onClick: onClose,
138
- colors: [theme === PROMOTE ? _colors["default"].bgWhite : _colors["default"]["".concat(theme, "Text")]],
139
- className: spacedClose ? classes.spacedClose : null
88
+ className: classes.closeIcon,
89
+ size: type === 'banner' ? 'lg' : 'md',
90
+ icon: "x",
91
+ theme: theme === PROMOTE ? 'ghostWhite' : 'ghostGrey'
140
92
  })));
141
93
  };
142
94
 
@@ -151,6 +103,7 @@ Tip.propTypes = {
151
103
 
152
104
  /** Text of the tip. If you put text between two * characters that text will be displayed as bold. */
153
105
  children: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired,
106
+ size: _propTypes["default"].oneOf(['large', 'small']),
154
107
 
155
108
  /** Call to action. Appended after the children's text. */
156
109
  cta: _propTypes["default"].shape({
@@ -176,7 +129,8 @@ Tip.propTypes = {
176
129
  spacedClose: _propTypes["default"].bool,
177
130
  id: _propTypes["default"].string,
178
131
  className: _propTypes["default"].string,
179
- style: _propTypes["default"].object
132
+ style: _propTypes["default"].object,
133
+ type: _propTypes["default"].oneOf(['alert', 'banner'])
180
134
  };
181
135
  var _default = Tip;
182
136
  exports["default"] = _default;
@@ -46,12 +46,6 @@ describe("Tip", function () {
46
46
  }));
47
47
  expect(wrapper.find('.icon').length).toBe(1);
48
48
  });
49
- it('has bold text', function () {
50
- var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_Tip["default"], {
51
- classes: classes
52
- }, "Text with *bold* text"));
53
- expect(wrapper.find('b').length).toBe(1);
54
- });
55
49
  });
56
50
  describe("TipJSS", function () {
57
51
  it('matches the snapshot', function () {
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ 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; }
19
+
20
+ var boldRegex = /\*(.*?)\*/g;
21
+
22
+ var TipText = function TipText(_ref) {
23
+ var classes = _ref.classes,
24
+ text = _ref.text;
25
+ if (text === '' || typeof text !== 'string') return text;
26
+ var result = (0, _react.useMemo)(function () {
27
+ return text.replace(boldRegex, function (_, txt) {
28
+ return txt;
29
+ });
30
+ }, [text]);
31
+ return /*#__PURE__*/_react["default"].createElement("p", {
32
+ className: classes
33
+ }, result);
34
+ };
35
+
36
+ TipText.propTypes = {
37
+ classes: _propTypes["default"].string.isRequired,
38
+ text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired
39
+ };
40
+ var _default = TipText;
41
+ exports["default"] = _default;
@@ -4,44 +4,111 @@ exports[`Tip matches the snapshot 1`] = `ShallowWrapper {}`;
4
4
 
5
5
  exports[`Tip styles matches the snapshot 1`] = `
6
6
  Object {
7
+ "bannerContent": Object {
8
+ "margin": "auto",
9
+ "maxWidth": "1200px",
10
+ },
11
+ "closeIcon": Object {
12
+ "marginLeft": "16px",
13
+ },
7
14
  "container": Object {
8
15
  "alignItems": "center",
9
- "borderRadius": 6,
10
- "padding": 16,
16
+ "borderRadius": "4px",
17
+ "minHeight": "56px",
18
+ "outlineOffset": "-1px",
19
+ "padding": Array [
20
+ "8px",
21
+ "16px",
22
+ ],
11
23
  },
12
24
  "cta": Object {
13
25
  "cursor": "pointer",
26
+ "font": "400 14px/1.5 'OccText', sans-serif",
14
27
  "textDecoration": "underline",
28
+ "textWrap": "nowrap",
29
+ },
30
+ "ctaLarge": Object {
31
+ "alignSelf": "center",
32
+ "marginLeft": "16px",
33
+ },
34
+ "ctaSmall": Object {
35
+ "alignSelf": "start",
36
+ "margin": Array [
37
+ "8px",
38
+ 0,
39
+ 0,
40
+ ],
15
41
  },
16
42
  "error": Object {
17
- "backgroundColor": "#fcebeb",
43
+ "backgroundColor": "#fce8e8",
44
+ "outline": "1px solid #FBDFDF",
18
45
  },
19
46
  "icon": Object {
20
- "marginRight": 8,
47
+ "flexShrink": 0,
48
+ "marginRight": "8px",
21
49
  },
22
50
  "info": Object {
23
- "backgroundColor": "#efebf7",
51
+ "backgroundColor": "#e3efff",
52
+ "outline": "1px solid #b9d7ff",
53
+ },
54
+ "largePadding": Object {
55
+ "padding": "12px",
24
56
  },
25
57
  "noBorderRadius": Object {
26
58
  "borderRadius": 0,
27
59
  },
60
+ "normalText": Object {
61
+ "display": "inline-block",
62
+ "font": "400 14px/1.5 'OccText', sans-serif",
63
+ "margin": 0,
64
+ },
28
65
  "promote": Object {
29
- "backgroundColor": "#222222",
66
+ "backgroundColor": "#000",
67
+ "outline": "1px solid rgba(255,255,255,0.2)",
30
68
  },
31
- "spacedClose": Object {
32
- "marginRight": 48,
69
+ "small": Object {
70
+ "maxWidth": 360,
71
+ "padding": "12px",
72
+ },
73
+ "smallPadding": Object {
74
+ "padding": "8px",
33
75
  },
34
76
  "success": Object {
35
- "backgroundColor": "#e6f5eb",
77
+ "backgroundColor": "#ebfbf1",
78
+ "outline": "1px solid #d7f6e3",
36
79
  },
37
80
  "text": Object {
38
81
  "maxWidth": "100%",
39
82
  },
40
- "textWithIcon": Object {
41
- "maxWidth": "calc(100% - 32px)",
83
+ "textContainer": Object {
84
+ "padding": Array [
85
+ "12px",
86
+ 0,
87
+ ],
88
+ },
89
+ "textError": Object {
90
+ "color": "#8b1313",
91
+ "textDecorationColor": "#8b1313",
92
+ },
93
+ "textInfo": Object {
94
+ "color": "#083CAE",
95
+ "textDecorationColor": "#083CAE",
96
+ },
97
+ "textPromote": Object {
98
+ "color": "#fff",
99
+ "textDecorationColor": "#fff",
100
+ },
101
+ "textSuccess": Object {
102
+ "color": "#16542e",
103
+ "textDecorationColor": "#16542e",
104
+ },
105
+ "textWarning": Object {
106
+ "color": "#664a0e",
107
+ "textDecorationColor": "#664a0e",
42
108
  },
43
109
  "warning": Object {
44
- "backgroundColor": "#fffaed",
110
+ "backgroundColor": "#fff8e9",
111
+ "outline": "1px solid #fff1d3",
45
112
  },
46
113
  }
47
114
  `;
@@ -5,61 +5,114 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- var _spacing = _interopRequireDefault(require("../subatomic/spacing"));
8
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
9
9
 
10
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
10
+ var _fonts = _interopRequireDefault(require("../tokens/fonts.json"));
11
+
12
+ var _spacing = _interopRequireDefault(require("../tokens/spacing.json"));
13
+
14
+ var _borderRadius = _interopRequireDefault(require("../tokens/borderRadius.json"));
15
+
16
+ var _styles = require("../Text/styles");
11
17
 
12
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
19
 
14
- var infoLight = _colors["default"].infoLight,
15
- warningLight = _colors["default"].warningLight,
16
- successLight = _colors["default"].successLight,
17
- errorLight = _colors["default"].errorLight,
18
- grey900 = _colors["default"].grey900;
19
- var radius = _spacing["default"].radius,
20
- large = _spacing["default"].large,
21
- medium = _spacing["default"].medium,
22
- small = _spacing["default"].small,
23
- tiny = _spacing["default"].tiny;
24
20
  var _default = {
25
21
  container: {
26
- padding: small,
27
- borderRadius: radius,
28
- alignItems: 'center'
22
+ padding: [_spacing["default"]['size-2'], _spacing["default"]['size-4']],
23
+ borderRadius: _borderRadius["default"]['br-xs'],
24
+ minHeight: '56px',
25
+ alignItems: 'center',
26
+ outlineOffset: '-1px'
29
27
  },
30
28
  noBorderRadius: {
31
29
  borderRadius: 0
32
30
  },
33
31
  info: {
34
- backgroundColor: infoLight
32
+ backgroundColor: _colors["default"].alert.info.bg,
33
+ outline: "1px solid ".concat(_colors["default"].alert.info.border)
35
34
  },
36
35
  warning: {
37
- backgroundColor: warningLight
36
+ backgroundColor: _colors["default"].alert.warning.bg,
37
+ outline: "1px solid ".concat(_colors["default"].alert.warning.border)
38
38
  },
39
39
  success: {
40
- backgroundColor: successLight
40
+ backgroundColor: _colors["default"].alert.success.bg,
41
+ outline: "1px solid ".concat(_colors["default"].alert.success.border)
41
42
  },
42
43
  error: {
43
- backgroundColor: errorLight
44
+ backgroundColor: _colors["default"].alert.error.bg,
45
+ outline: "1px solid ".concat(_colors["default"].alert.error.border)
44
46
  },
45
47
  promote: {
46
- backgroundColor: grey900
48
+ backgroundColor: _colors["default"].alert.neutral.bg,
49
+ outline: "1px solid ".concat(_colors["default"].alert.neutral.border)
50
+ },
51
+ textInfo: {
52
+ color: _colors["default"].text.indigo.primary,
53
+ textDecorationColor: _colors["default"].text.indigo.primary
54
+ },
55
+ textWarning: {
56
+ color: _colors["default"].text.warning,
57
+ textDecorationColor: _colors["default"].text.warning
58
+ },
59
+ textSuccess: {
60
+ color: _colors["default"].text.success,
61
+ textDecorationColor: _colors["default"].text.success
62
+ },
63
+ textError: {
64
+ color: _colors["default"].text.error,
65
+ textDecorationColor: _colors["default"].text.error
66
+ },
67
+ textPromote: {
68
+ color: _colors["default"].text.white.primary,
69
+ textDecorationColor: _colors["default"].text.white.primary
47
70
  },
48
71
  icon: {
49
- marginRight: tiny
72
+ marginRight: _spacing["default"]['size-2'],
73
+ flexShrink: 0
50
74
  },
51
75
  text: {
52
76
  maxWidth: '100%'
53
77
  },
54
- textWithIcon: {
55
- maxWidth: "calc(100% - ".concat(medium, "px)")
78
+ closeIcon: {
79
+ marginLeft: _spacing["default"]['size-4']
56
80
  },
57
- spacedClose: {
58
- marginRight: large
81
+ smallPadding: {
82
+ padding: _spacing["default"]['size-2']
83
+ },
84
+ largePadding: {
85
+ padding: _spacing["default"]['size-3']
59
86
  },
60
87
  cta: {
61
88
  textDecoration: 'underline',
62
- cursor: 'pointer'
89
+ font: (0, _styles.parseFontValue)(_fonts["default"]['alert-default']),
90
+ cursor: 'pointer',
91
+ textWrap: 'nowrap'
92
+ },
93
+ ctaLarge: {
94
+ marginLeft: _spacing["default"]['size-4'],
95
+ alignSelf: 'center'
96
+ },
97
+ ctaSmall: {
98
+ margin: [_spacing["default"]['size-2'], 0, 0],
99
+ alignSelf: 'start'
100
+ },
101
+ normalText: {
102
+ font: (0, _styles.parseFontValue)(_fonts["default"]['alert-default']),
103
+ display: 'inline-block',
104
+ margin: 0
105
+ },
106
+ textContainer: {
107
+ padding: [_spacing["default"]['size-3'], 0]
108
+ },
109
+ small: {
110
+ maxWidth: 360,
111
+ padding: _spacing["default"]['size-3']
112
+ },
113
+ bannerContent: {
114
+ maxWidth: '1200px',
115
+ margin: 'auto'
63
116
  }
64
117
  };
65
118
  exports["default"] = _default;
@@ -343,7 +343,7 @@
343
343
  },
344
344
  "info": {
345
345
  "bg": "#e3efff",
346
- "border": "#e3efff"
346
+ "border": "#b9d7ff"
347
347
  },
348
348
  "neutral": {
349
349
  "bg": "#000",
@@ -402,7 +402,7 @@
402
402
  },
403
403
  "info": {
404
404
  "bg": "#e3efff",
405
- "border": "#e3efff"
405
+ "border": "#b9d7ff"
406
406
  },
407
407
  "featured": {
408
408
  "border": "rgba(255,255,255,0.2)",
@@ -567,7 +567,7 @@
567
567
  "subtle": "#d7f6e3"
568
568
  },
569
569
  "info": {
570
- "subtle": "#e3efff"
570
+ "subtle": "#b9d7ff"
571
571
  }
572
572
  },
573
573
  "text": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occmundial/occ-atomic",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.8",
4
4
  "description": "Collection of shareable styled React components for OCC applications.",
5
5
  "homepage": "http://occmundial.github.io/occ-atomic",
6
6
  "main": "build/index.js",