@occmundial/occ-atomic 3.0.0-beta.34 → 3.0.0-beta.36

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # [3.0.0-beta.36](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.35...v3.0.0-beta.36) (2024-07-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Pass props directly ([39fc2c4](https://github.com/occmundial/occ-atomic/commit/39fc2c455fead75aec07995b3f99123774b28100))
7
+ * Remove unnecesary arrow padding ([fcbf53b](https://github.com/occmundial/occ-atomic/commit/fcbf53bbf2f750dab61d82021be54f5eb95f3e7b))
8
+ * Remove unnused variable ([613405c](https://github.com/occmundial/occ-atomic/commit/613405c2466d79a0694f33aa0b19c2d55160ca8b))
9
+
10
+ # [3.0.0-beta.35](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.34...v3.0.0-beta.35) (2024-07-24)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Change end start tooltip behaviour ([220bcb8](https://github.com/occmundial/occ-atomic/commit/220bcb8c071735ab33eb20817afb5cfcc83106b8))
16
+ * Change svg to floating arrow ([09b1d67](https://github.com/occmundial/occ-atomic/commit/09b1d67810e5b354b3656efc92b623e3e55abc9c))
17
+ * Set min width for end or start and update examples ([65a9f31](https://github.com/occmundial/occ-atomic/commit/65a9f315dc38c011a4563b7726e5bbd4fd2c2725))
18
+
19
+
20
+ ### Features
21
+
22
+ * Update tooltip with new design tokens ([1843c88](https://github.com/occmundial/occ-atomic/commit/1843c887fc232adc0b4877b8348777448394395f))
23
+
1
24
  # [3.0.0-beta.34](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.33...v3.0.0-beta.34) (2024-07-22)
2
25
 
3
26
 
@@ -15,9 +15,13 @@ var _react2 = require("@floating-ui/react");
15
15
 
16
16
  var _colors = _interopRequireDefault(require("../subatomic/colors"));
17
17
 
18
+ var _colors2 = _interopRequireDefault(require("../tokens/colors.json"));
19
+
18
20
  var _hooks = require("./hooks");
19
21
 
20
- var _colorsArrow;
22
+ var _Icon = _interopRequireDefault(require("../Icon"));
23
+
24
+ var _colorsArrow, _borderColors;
21
25
 
22
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
27
 
@@ -46,8 +50,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
46
50
  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; }
47
51
 
48
52
  var infoLight = _colors["default"].infoLight,
49
- white = _colors["default"].white,
50
- grey900 = _colors["default"].grey900,
51
53
  info = _colors["default"].info;
52
54
  var themes = {
53
55
  DARK: 'dark',
@@ -55,7 +57,20 @@ var themes = {
55
57
  INFO: 'info',
56
58
  PURPLE: 'purple'
57
59
  };
58
- var colorsArrow = (_colorsArrow = {}, _defineProperty(_colorsArrow, themes.DARK, grey900), _defineProperty(_colorsArrow, themes.LIGHT, white), _defineProperty(_colorsArrow, themes.INFO, infoLight), _defineProperty(_colorsArrow, themes.PURPLE, info), _colorsArrow);
60
+ var colorsArrow = (_colorsArrow = {}, _defineProperty(_colorsArrow, themes.DARK, _colors2["default"].bg.neutral), _defineProperty(_colorsArrow, themes.INFO, infoLight), _defineProperty(_colorsArrow, themes.LIGHT, _colors2["default"].bg.surface["default"]), _defineProperty(_colorsArrow, themes.PURPLE, info), _colorsArrow);
61
+ var borderColors = (_borderColors = {}, _defineProperty(_borderColors, themes.DARK, {
62
+ bg: 'black',
63
+ border: 'rgba(0, 0, 0, 0.8)'
64
+ }), _defineProperty(_borderColors, themes.LIGHT, {
65
+ bg: _colors2["default"].border["default"].subtle,
66
+ border: _colors2["default"].border["default"].subtle
67
+ }), _defineProperty(_borderColors, themes.INFO, {
68
+ bg: infoLight,
69
+ border: infoLight
70
+ }), _defineProperty(_borderColors, themes.PURPLE, {
71
+ bg: info,
72
+ border: info
73
+ }), _borderColors);
59
74
  /** Tooltip component to display messages within a container. */
60
75
 
61
76
  function Tooltip(_ref) {
@@ -63,7 +78,8 @@ function Tooltip(_ref) {
63
78
  openProp = _ref.open,
64
79
  children = _ref.children,
65
80
  text = _ref.text,
66
- theme = _ref.theme,
81
+ _ref$theme = _ref.theme,
82
+ theme = _ref$theme === void 0 ? 'purple' : _ref$theme,
67
83
  _ref$openOnHover = _ref.openOnHover,
68
84
  openOnHover = _ref$openOnHover === void 0 ? false : _ref$openOnHover,
69
85
  _ref$closeDelay = _ref.closeDelay,
@@ -79,10 +95,11 @@ function Tooltip(_ref) {
79
95
  _ref$fit = _ref.fit,
80
96
  fit = _ref$fit === void 0 ? false : _ref$fit,
81
97
  _ref$width = _ref.width,
82
- width = _ref$width === void 0 ? 220 : _ref$width,
98
+ width = _ref$width === void 0 ? 'auto' : _ref$width,
83
99
  _ref$strategy = _ref.strategy,
84
100
  strategy = _ref$strategy === void 0 ? 'absolute' : _ref$strategy,
85
- onChange = _ref.onChange;
101
+ onChange = _ref.onChange,
102
+ icon = _ref.icon;
86
103
  var arrowRef = (0, _react.useRef)(null);
87
104
 
88
105
  var _useOpenTooltipState = (0, _hooks.useOpenTooltipState)(openProp, onChange, closeDelay),
@@ -91,23 +108,43 @@ function Tooltip(_ref) {
91
108
  setOpen = _useOpenTooltipState2[1];
92
109
 
93
110
  var getMiddlewares = (0, _react.useMemo)(function () {
94
- var middlewares = [(0, _react2.offset)(16)];
111
+ var middlewares = [(0, _react2.offset)(function (_ref2) {
112
+ var rects = _ref2.rects;
113
+
114
+ if (placement === 'top-start' || placement === 'bottom-start') {
115
+ return {
116
+ crossAxis: rects.reference.width / 2 - 18,
117
+ mainAxis: 16
118
+ };
119
+ } else if (placement === 'top-end' || placement === 'bottom-end') {
120
+ return {
121
+ crossAxis: -(rects.reference.width / 2) + 18,
122
+ mainAxis: 16
123
+ };
124
+ }
125
+
126
+ return {
127
+ mainAxis: 16
128
+ };
129
+ })];
95
130
  showArrow && middlewares.push((0, _react2.arrow)({
96
- element: arrowRef,
97
- padding: 16
131
+ element: arrowRef
98
132
  }));
99
133
  var sizeMiddleware = (0, _react2.size)({
100
- apply: function apply(_ref2) {
101
- var elements = _ref2.elements,
102
- rects = _ref2.rects,
103
- availableWidth = _ref2.availableWidth;
134
+ apply: function apply(_ref3) {
135
+ var elements = _ref3.elements,
136
+ rects = _ref3.rects,
137
+ availableWidth = _ref3.availableWidth;
104
138
  var styles = {};
105
139
 
106
140
  if (fit) {
107
141
  styles.width = "".concat(rects.reference.width, "px");
108
142
  } else {
109
143
  styles.maxWidth = "".concat(availableWidth, "px");
110
- if (width) styles.width = typeof width === 'string' ? width : "".concat(width, "px");else styles.width = '';
144
+
145
+ if (width) {
146
+ styles.width = typeof width === 'string' ? width : "".concat(width, "px");
147
+ } else styles.width = '';
111
148
  }
112
149
 
113
150
  Object.assign(elements.floating.style, styles);
@@ -144,20 +181,33 @@ function Tooltip(_ref) {
144
181
  return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", _extends({
145
182
  ref: refs.setReference
146
183
  }, getReferenceProps(), {
147
- className: "".concat(classes.activator, " ").concat(className.hasOwnProperty('activator') && className.activator)
184
+ className: "".concat(classes.activator, " ").concat(className.hasOwnProperty('activator') ? className.activator : '')
148
185
  }), children), /*#__PURE__*/_react["default"].createElement(_react2.FloatingPortal, null, open && /*#__PURE__*/_react["default"].createElement("div", _extends({
149
- className: "".concat(classes.tooltip, " ").concat(className.hasOwnProperty('tooltip') && className.tooltip, " ").concat(classes[theme] || classes.purple),
186
+ className: "".concat(classes.tooltip, " ").concat(className.hasOwnProperty('tooltip') ? className.tooltip : '', " ").concat(classes[theme] || classes.purple),
150
187
  ref: refs.setFloating,
151
188
  style: _objectSpread(_objectSpread({}, floatingStyles), {}, {
152
189
  zIndex: zIndex,
153
190
  position: strategy
154
191
  })
155
- }, getFloatingProps()), text, showArrow && /*#__PURE__*/_react["default"].createElement(_react2.FloatingArrow, {
192
+ }, getFloatingProps()), /*#__PURE__*/_react["default"].createElement("div", {
193
+ className: classes.content
194
+ }, icon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
195
+ iconName: icon,
196
+ width: 12,
197
+ height: 12
198
+ }), /*#__PURE__*/_react["default"].createElement("p", {
199
+ className: classes.text
200
+ }, text)), showArrow && /*#__PURE__*/_react["default"].createElement(_react2.FloatingArrow, {
201
+ style: {
202
+ transform: 'translateY(1px)'
203
+ },
156
204
  ref: arrowRef,
157
205
  context: context,
158
206
  fill: colorsArrow[theme] || colorsArrow[themes.PURPLE],
159
- width: 14,
160
- height: 10
207
+ strokeWidth: 1,
208
+ stroke: borderColors[theme].border,
209
+ width: 20,
210
+ d: "M0 20C0 20 2.06906 19.9829 5.91817 15.4092C7.49986 13.5236 8.97939 12.3809 10.0002 12.3809C11.0202 12.3809 12.481 13.6451 14.0814 15.5472C17.952 20.1437 20 20 20 20H0Z"
161
211
  }))));
162
212
  }
163
213
 
@@ -204,7 +254,8 @@ Tooltip.propTypes = {
204
254
  strategy: _propTypes["default"].oneOf(['absolute', 'fixed']),
205
255
 
206
256
  /** Callback fired when the Tooltip show state changes. */
207
- onChange: _propTypes["default"].func
257
+ onChange: _propTypes["default"].func,
258
+ icon: _propTypes["default"].string
208
259
  };
209
260
  var _default = Tooltip;
210
261
  exports["default"] = _default;
@@ -1,14 +1,21 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Tooltip matches the snapshot 1`] = `"<div class=\\"activator false\\"></div>"`;
3
+ exports[`Tooltip matches the snapshot 1`] = `"<div class=\\"activator \\"></div>"`;
4
4
 
5
5
  exports[`Tooltip styles matches the snapshot 1`] = `
6
6
  Object {
7
7
  "activator": Object {
8
8
  "display": "inline-block",
9
9
  },
10
+ "content": Object {
11
+ "alignItems": "center",
12
+ "display": "flex",
13
+ "gap": "4px",
14
+ "justifyContent": "center",
15
+ },
10
16
  "dark": Object {
11
- "background": "#222222",
17
+ "background": "#000",
18
+ "boxShadow": "inset 0 0 0 1px rgba(255,255,255,0.2)",
12
19
  "color": "#ffffff",
13
20
  },
14
21
  "info": Object {
@@ -16,18 +23,27 @@ Object {
16
23
  "color": "#5736ab",
17
24
  },
18
25
  "light": Object {
19
- "background": "#ffffff",
26
+ "&:after": Object {
27
+ "boxShadow": "inset -2px -2px 0 -1px #EDEDF1",
28
+ },
29
+ "background": "#fff",
30
+ "boxShadow": "inset 0 0 0 1px #EDEDF1",
20
31
  "color": "#5736ab",
21
32
  },
22
33
  "purple": Object {
23
34
  "background": "#5736ab",
24
35
  "color": "#ffffff",
25
36
  },
37
+ "text": Object {
38
+ "font": "300 12px/1.5 'OccText', sans-serif",
39
+ "margin": 0,
40
+ },
26
41
  "tooltip": Object {
27
42
  "borderRadius": "4px",
28
- "fontSize": "14px",
29
- "lineHeight": 1.5,
30
- "padding": "16px",
43
+ "padding": Array [
44
+ "8px",
45
+ "12px",
46
+ ],
31
47
  },
32
48
  }
33
49
  `;
@@ -7,38 +7,60 @@ exports["default"] = void 0;
7
7
 
8
8
  var _colors = _interopRequireDefault(require("../subatomic/colors"));
9
9
 
10
+ var _colors2 = _interopRequireDefault(require("../tokens/colors.json"));
11
+
12
+ var _fonts = _interopRequireDefault(require("../tokens/fonts.json"));
13
+
14
+ var _spacing = _interopRequireDefault(require("../tokens/spacing.json"));
15
+
16
+ var _borderRadius = _interopRequireDefault(require("../tokens/borderRadius.json"));
17
+
18
+ var _styles = require("../Text/styles");
19
+
10
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
21
 
12
22
  var infoLight = _colors["default"].infoLight,
13
23
  infoText = _colors["default"].infoText,
14
24
  info = _colors["default"].info,
15
- white = _colors["default"].white,
16
- grey900 = _colors["default"].grey900;
25
+ white = _colors["default"].white;
17
26
  var _default = {
18
27
  activator: {
19
28
  display: 'inline-block'
20
29
  },
21
30
  tooltip: {
22
- padding: '16px',
23
- borderRadius: '4px',
24
- fontSize: '14px',
25
- lineHeight: 1.5
31
+ padding: [_spacing["default"]['size-2'], _spacing["default"]['size-3']],
32
+ borderRadius: _borderRadius["default"]['br-xs']
33
+ },
34
+ content: {
35
+ display: 'flex',
36
+ gap: _spacing["default"]['size-1'],
37
+ alignItems: 'center',
38
+ justifyContent: 'center'
26
39
  },
27
40
  info: {
28
41
  background: infoLight,
29
42
  color: infoText
30
43
  },
31
44
  dark: {
32
- background: grey900,
33
- color: white
45
+ background: _colors2["default"].bg.neutral,
46
+ color: white,
47
+ boxShadow: "inset 0 0 0 1px ".concat(_colors2["default"].border.inverse.subtle)
34
48
  },
35
49
  light: {
36
- background: white,
37
- color: info
50
+ background: _colors2["default"].bg.surface["default"],
51
+ color: info,
52
+ '&:after': {
53
+ boxShadow: "inset -2px -2px 0 -1px ".concat(_colors2["default"].border["default"].subtle)
54
+ },
55
+ boxShadow: "inset 0 0 0 1px ".concat(_colors2["default"].border["default"].subtle)
38
56
  },
39
57
  purple: {
40
58
  background: info,
41
59
  color: white
60
+ },
61
+ text: {
62
+ font: (0, _styles.parseFontValue)(_fonts["default"]['body-x-small']),
63
+ margin: 0
42
64
  }
43
65
  };
44
66
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occmundial/occ-atomic",
3
- "version": "3.0.0-beta.34",
3
+ "version": "3.0.0-beta.36",
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",