@megafon/ui-core 2.1.0 → 2.1.4

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/es/colors/ColorItem/ColorItem.css +52 -0
  3. package/dist/es/colors/ColorItem/ColorItem.d.ts +12 -0
  4. package/dist/es/colors/ColorItem/ColorItem.js +35 -0
  5. package/dist/es/colors/Colors.css +203 -32
  6. package/dist/es/colors/Colors.js +243 -35
  7. package/dist/es/colors/colorsData.d.ts +20 -7
  8. package/dist/es/colors/colorsData.js +213 -61
  9. package/dist/es/components/Banner/BannerDot.css +2 -2
  10. package/dist/es/components/Button/Button.css +11 -11
  11. package/dist/es/components/Carousel/Carousel.css +1 -1
  12. package/dist/es/components/Carousel/Carousel.js +6 -1
  13. package/dist/es/components/ContentArea/ContentArea.css +4 -0
  14. package/dist/es/components/ContentArea/ContentArea.d.ts +6 -2
  15. package/dist/es/components/ContentArea/ContentArea.js +39 -6
  16. package/dist/es/components/Counter/Counter.css +3 -3
  17. package/dist/es/components/NavArrow/NavArrow.css +1 -1
  18. package/dist/es/components/Notification/Notification.css +10 -19
  19. package/dist/es/components/Paragraph/Paragraph.css +2 -0
  20. package/dist/es/components/Paragraph/Paragraph.d.ts +17 -1
  21. package/dist/es/components/Paragraph/Paragraph.js +40 -1
  22. package/dist/es/components/Tabs/Tabs.css +2 -2
  23. package/dist/es/components/Tabs/Tabs.js +41 -32
  24. package/dist/lib/colors/ColorItem/ColorItem.css +52 -0
  25. package/dist/lib/colors/ColorItem/ColorItem.d.ts +12 -0
  26. package/dist/lib/colors/ColorItem/ColorItem.js +50 -0
  27. package/dist/lib/colors/Colors.css +203 -32
  28. package/dist/lib/colors/Colors.js +250 -36
  29. package/dist/lib/colors/colorsData.d.ts +20 -7
  30. package/dist/lib/colors/colorsData.js +213 -61
  31. package/dist/lib/components/Banner/BannerDot.css +2 -2
  32. package/dist/lib/components/Button/Button.css +11 -11
  33. package/dist/lib/components/Carousel/Carousel.css +1 -1
  34. package/dist/lib/components/Carousel/Carousel.js +6 -1
  35. package/dist/lib/components/ContentArea/ContentArea.css +4 -0
  36. package/dist/lib/components/ContentArea/ContentArea.d.ts +6 -2
  37. package/dist/lib/components/ContentArea/ContentArea.js +42 -6
  38. package/dist/lib/components/Counter/Counter.css +3 -3
  39. package/dist/lib/components/NavArrow/NavArrow.css +1 -1
  40. package/dist/lib/components/Notification/Notification.css +10 -19
  41. package/dist/lib/components/Paragraph/Paragraph.css +2 -0
  42. package/dist/lib/components/Paragraph/Paragraph.d.ts +17 -1
  43. package/dist/lib/components/Paragraph/Paragraph.js +44 -1
  44. package/dist/lib/components/Tabs/Tabs.css +2 -2
  45. package/dist/lib/components/Tabs/Tabs.js +41 -32
  46. package/package.json +4 -3
  47. package/styles/base.less +49 -21
@@ -36,6 +36,7 @@ h5 {
36
36
  .mfui-paragraph_color_purple {
37
37
  color: #731982;
38
38
  }
39
+ .mfui-paragraph_color_base,
39
40
  .mfui-paragraph_color_clearWhite {
40
41
  color: #FFFFFF;
41
42
  }
@@ -48,6 +49,7 @@ h5 {
48
49
  .mfui-paragraph_color_spbSky2 {
49
50
  color: #D8D8D8;
50
51
  }
52
+ .mfui-paragraph_color_content,
51
53
  .mfui-paragraph_color_freshAsphalt {
52
54
  color: #333333;
53
55
  }
@@ -1,5 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import './Paragraph.less';
3
+ declare const COLORS: {
4
+ GREEN: string;
5
+ PURPLE: string;
6
+ BASE: string;
7
+ SPB_SKY_0: string;
8
+ SPB_SKY_1: string;
9
+ SPB_SKY_2: string;
10
+ CONTENT: string;
11
+ FULL_BLACK: string;
12
+ INHERIT: string;
13
+ /** @deprecated */
14
+ CLEAR_WHITE: string;
15
+ /** @deprecated */
16
+ FRESH_ASPHALT: string;
17
+ };
18
+ declare type ColorType = typeof COLORS[keyof typeof COLORS];
3
19
  export interface IParagraphProps {
4
20
  /** Выравнивание по горизонтали */
5
21
  align?: 'left' | 'center' | 'right';
@@ -8,7 +24,7 @@ export interface IParagraphProps {
8
24
  /** Вертикальный отступ (включен по умолчанию) */
9
25
  hasMargin?: boolean;
10
26
  /** Цвет текста */
11
- color?: 'green' | 'purple' | 'clearWhite' | 'spbSky0' | 'spbSky1' | 'spbSky2' | 'freshAsphalt' | 'fullBlack' | 'inherit';
27
+ color?: ColorType;
12
28
  /** Дополнительный класс корневого элемента */
13
29
  className?: string;
14
30
  }
@@ -7,6 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ require("core-js/modules/es.array.concat");
11
+
12
+ require("core-js/modules/es.array.includes");
13
+
14
+ require("core-js/modules/es.object.values");
15
+
16
+ require("core-js/modules/es.string.includes");
17
+
10
18
  var React = _interopRequireWildcard(require("react"));
11
19
 
12
20
  var _uiHelpers = require("@megafon/ui-helpers");
@@ -17,6 +25,23 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
17
25
 
18
26
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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
27
 
28
+ var COLORS = {
29
+ GREEN: 'green',
30
+ PURPLE: 'purple',
31
+ BASE: 'base',
32
+ SPB_SKY_0: 'spbSky0',
33
+ SPB_SKY_1: 'spbSky1',
34
+ SPB_SKY_2: 'spbSky2',
35
+ CONTENT: 'content',
36
+ FULL_BLACK: 'fullBlack',
37
+ INHERIT: 'inherit',
38
+
39
+ /** @deprecated */
40
+ CLEAR_WHITE: 'clearWhite',
41
+
42
+ /** @deprecated */
43
+ FRESH_ASPHALT: 'freshAsphalt'
44
+ };
20
45
  var cn = (0, _uiHelpers.cnCreate)('mfui-paragraph');
21
46
 
22
47
  var Paragraph = function Paragraph(_ref) {
@@ -43,7 +68,25 @@ Paragraph.propTypes = {
43
68
  align: PropTypes.oneOf(['left', 'center', 'right']),
44
69
  size: PropTypes.oneOf(['regular', 'small']),
45
70
  hasMargin: PropTypes.bool,
46
- color: PropTypes.oneOf(['green', 'purple', 'clearWhite', 'spbSky0', 'spbSky1', 'spbSky2', 'freshAsphalt', 'fullBlack', 'inherit'])
71
+ color: function color(props, propName, componentName) {
72
+ var deprecatedBlackValue = COLORS.FRESH_ASPHALT;
73
+ var deprecatedWhiteValue = COLORS.CLEAR_WHITE;
74
+ var propValue = props[propName];
75
+
76
+ if (propValue && !Object.values(COLORS).includes(propValue)) {
77
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "', \n expected one of [").concat(Object.values(COLORS), "]"));
78
+ }
79
+
80
+ if (propValue && props[propName] === deprecatedBlackValue) {
81
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedBlackValue, "' is deprecated, please use value '").concat(COLORS.CONTENT, "'"));
82
+ }
83
+
84
+ if (propValue && props[propName] === deprecatedWhiteValue) {
85
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedWhiteValue, "' is deprecated, please use value '").concat(COLORS.BASE, "'"));
86
+ }
87
+
88
+ return null;
89
+ }
47
90
  };
48
91
  var _default = Paragraph;
49
92
  exports["default"] = _default;
@@ -254,8 +254,8 @@ h5 {
254
254
  border-color: rgba(237, 237, 237, 0.5);
255
255
  }
256
256
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner {
257
- color: rgba(255, 255, 255, 0.5);
258
- fill: rgba(255, 255, 255, 0.5);
257
+ color: #FFFFFF80;
258
+ fill: #FFFFFF80;
259
259
  }
260
260
  .mfui-tabs_tab-color_green:not(.mfui-tabs_sticky) .mfui-tabs__tab-inner:hover {
261
261
  color: #FFFFFF;
@@ -126,36 +126,41 @@ var Tabs = function Tabs(_ref) {
126
126
 
127
127
  var _React$useState9 = React.useState(0),
128
128
  _React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
129
- underlineWidth = _React$useState10[0],
130
- setUnderlineWidth = _React$useState10[1];
129
+ activeTabWidth = _React$useState10[0],
130
+ setActiveTabWidth = _React$useState10[1];
131
131
 
132
132
  var _React$useState11 = React.useState(0),
133
133
  _React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
134
- underlineTranslate = _React$useState12[0],
135
- setUnderlineTranslate = _React$useState12[1];
134
+ underlineWidth = _React$useState12[0],
135
+ setUnderlineWidth = _React$useState12[1];
136
136
 
137
- var _React$useState13 = React.useState('none'),
137
+ var _React$useState13 = React.useState(0),
138
138
  _React$useState14 = (0, _slicedToArray2["default"])(_React$useState13, 2),
139
- underlineTransition = _React$useState14[0],
140
- setUnderlineTransition = _React$useState14[1];
139
+ underlineTranslate = _React$useState14[0],
140
+ setUnderlineTranslate = _React$useState14[1];
141
141
 
142
- var _React$useState15 = React.useState('auto'),
142
+ var _React$useState15 = React.useState('none'),
143
143
  _React$useState16 = (0, _slicedToArray2["default"])(_React$useState15, 2),
144
- tabListHeight = _React$useState16[0],
145
- setTabListHeight = _React$useState16[1];
144
+ underlineTransition = _React$useState16[0],
145
+ setUnderlineTransition = _React$useState16[1];
146
146
 
147
- var _React$useState17 = React.useState(false),
147
+ var _React$useState17 = React.useState('auto'),
148
148
  _React$useState18 = (0, _slicedToArray2["default"])(_React$useState17, 2),
149
- isSticky = _React$useState18[0],
150
- setSticky = _React$useState18[1];
149
+ tabListHeight = _React$useState18[0],
150
+ setTabListHeight = _React$useState18[1];
151
151
 
152
- var _React$useState19 = React.useState({
152
+ var _React$useState19 = React.useState(false),
153
+ _React$useState20 = (0, _slicedToArray2["default"])(_React$useState19, 2),
154
+ isSticky = _React$useState20[0],
155
+ setSticky = _React$useState20[1];
156
+
157
+ var _React$useState21 = React.useState({
153
158
  left: 0,
154
159
  right: 0
155
160
  }),
156
- _React$useState20 = (0, _slicedToArray2["default"])(_React$useState19, 2),
157
- stickyOffset = _React$useState20[0],
158
- setStickyOffset = _React$useState20[1];
161
+ _React$useState22 = (0, _slicedToArray2["default"])(_React$useState21, 2),
162
+ stickyOffset = _React$useState22[0],
163
+ setStickyOffset = _React$useState22[1];
159
164
 
160
165
  var setTabRef = React.useCallback(function (tab) {
161
166
  tab && tabsRef.current.push(tab);
@@ -165,21 +170,15 @@ var Tabs = function Tabs(_ref) {
165
170
  return;
166
171
  }
167
172
 
168
- var tabNodeChild = tabsRef.current[currentIndex].firstElementChild;
169
-
170
- var _ref2 = tabNodeChild || {},
171
- _ref2$clientWidth = _ref2.clientWidth,
172
- clientWidth = _ref2$clientWidth === void 0 ? 0 : _ref2$clientWidth;
173
-
174
173
  var translate = (0, _toConsumableArray2["default"])(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
175
174
  var _node$getBoundingClie = node.getBoundingClientRect(),
176
175
  width = _node$getBoundingClie.width;
177
176
 
178
177
  return accWidth + width;
179
178
  }, 0);
180
- setUnderlineWidth(clientWidth);
179
+ setUnderlineWidth(activeTabWidth);
181
180
  setUnderlineTranslate(translate);
182
- }, [currentIndex]);
181
+ }, [currentIndex, activeTabWidth]);
183
182
  var calculateSticky = React.useCallback(function () {
184
183
  if (!sticky || !rootRef.current || !tabListRef.current) {
185
184
  return;
@@ -276,12 +275,12 @@ var Tabs = function Tabs(_ref) {
276
275
  }, []);
277
276
  React.useEffect(function () {
278
277
  var observer = new IntersectionObserver(function (entries) {
279
- entries.forEach(function (_ref3) {
280
- var isIntersecting = _ref3.isIntersecting,
281
- _ref3$boundingClientR = _ref3.boundingClientRect,
282
- top = _ref3$boundingClientR.top,
283
- left = _ref3$boundingClientR.left,
284
- right = _ref3$boundingClientR.right;
278
+ entries.forEach(function (_ref2) {
279
+ var isIntersecting = _ref2.isIntersecting,
280
+ _ref2$boundingClientR = _ref2.boundingClientRect,
281
+ top = _ref2$boundingClientR.top,
282
+ left = _ref2$boundingClientR.left,
283
+ right = _ref2$boundingClientR.right;
285
284
 
286
285
  if (!sticky || !rootRef.current || !tabListRef.current) {
287
286
  return;
@@ -323,10 +322,20 @@ var Tabs = function Tabs(_ref) {
323
322
  }, [calculateSticky]);
324
323
  React.useEffect(function () {
325
324
  var handleResize = (0, _lodash["default"])(function () {
326
- calculateUnderline();
327
325
  calculateSticky();
328
326
  }, 300);
327
+ var activeTabNode = tabsRef.current[currentIndex];
328
+ var resizeObserver = new ResizeObserver(function (entries) {
329
+ if (!entries.length || !entries[0]) {
330
+ return;
331
+ }
332
+
333
+ var width = entries[0].contentRect.width;
334
+ setActiveTabWidth(width);
335
+ calculateUnderline();
336
+ });
329
337
  calculateUnderline();
338
+ resizeObserver.observe(activeTabNode);
330
339
  window.addEventListener('resize', handleResize);
331
340
  return function () {
332
341
  window.removeEventListener('resize', handleResize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "2.1.0",
3
+ "version": "2.1.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -28,6 +28,7 @@
28
28
  "lint": "yarn lint:ts && yarn lint:less",
29
29
  "lint:ts": "eslint --ext .js,.jsx,.ts,.tsx src --max-warnings=0",
30
30
  "lint:less": "stylelint --syntax less src/**/*.less src/**/**/*.less",
31
+ "lint:less:fix": "yarn lint:less --fix",
31
32
  "test": "yarn test:unit",
32
33
  "test:unit": "jest",
33
34
  "test:update": "jest --updateSnapshot"
@@ -52,7 +53,7 @@
52
53
  "@babel/preset-env": "^7.8.6",
53
54
  "@babel/preset-react": "^7.8.3",
54
55
  "@babel/preset-typescript": "^7.8.3",
55
- "@megafon/ui-icons": "^0.1.0",
56
+ "@megafon/ui-icons": "^0.1.1",
56
57
  "@svgr/core": "^2.4.1",
57
58
  "@testing-library/react-hooks": "^7.0.1",
58
59
  "@types/enzyme": "^3.10.5",
@@ -95,5 +96,5 @@
95
96
  "react-popper": "^2.2.3",
96
97
  "swiper": "^6.5.6"
97
98
  },
98
- "gitHead": "42bd6840a217196ba9e80c6c77f92f5951881c12"
99
+ "gitHead": "88cfe6bca4b341ea19d7cb0b70798250bbbe127a"
99
100
  }
package/styles/base.less CHANGED
@@ -1,47 +1,75 @@
1
1
  // Basic Colors
2
2
  @green: #00B956;
3
3
  @purple: #731982;
4
- @clearWhite: #FFFFFF;
4
+ @base: #FFFFFF;
5
5
  @spbSky0: #F6F6F6;
6
6
  @spbSky1: #EDEDED;
7
7
  @spbSky2: #D8D8D8;
8
- @freshAsphalt: #333333;
8
+ @spbSky3: #999999;
9
+ @content: #333333;
9
10
  @fullBlack: #000000;
10
11
 
11
12
  // Secondary Colors
12
13
  @warmRedC: #EB5A40;
13
- @mandarin: #FFA717;
14
+ @Pantone137C: #FFA717;
14
15
  @Pantone311C: #5BD9E5;
15
16
  @reflexBlue: #444189;
16
17
 
17
18
  // System Colors
18
19
  @fury: #F62434;
19
- @link: #34AAF2;
20
+ @systemBlue: #34AAF2;
21
+ @background: #FFFFFF;
20
22
  @buttonHoverGreen: #10E272;
21
- @buttonhoverPurple: #A500BF;
23
+ @buttonhoverPurple: #534455;
22
24
  @buttonDown: #404D46;
23
25
 
26
+ // Gradients
27
+ @basic: linear-gradient(90deg, #01873F 0%, #00B956 74%, #14CD6A 100%);
28
+ @vip: linear-gradient(90deg, #5B1168 0%, #731982 74%, #821E93 100%);
29
+ @exclusive: linear-gradient(90deg, #2A2674 0%, #444189 74%, #504D93 100%);
30
+
31
+ // Static
32
+ @STCBlack: #333333;
33
+ @STCWhite: #FFFFFF;
34
+
35
+ // Static Opacity
36
+
37
+ @STCWhite5: #FFFFFF0D;
38
+ @STCWhite10: #FFFFFF1A;
39
+ @STCWhite20: #FFFFFF33;
40
+ @STCWhite50: #FFFFFF80;
41
+ @STCBlack5: #3333330D;
42
+ @STCBlack10: #3333331A;
43
+ @STCBlack20: #33333333;
44
+ @STCBlack50: #33333380;
45
+
46
+ // Soft (new)
47
+ @green80: #0CDC78;
48
+ @green20: #DDFFEC;
49
+ @purple80: #AA67C1;
50
+ @purple20: #FFEEFF;
51
+ @warmRedC80: #FF765D;
52
+ @warmRedC20: #FFCFC7;
53
+ @Pantone137C80: #FFB945;
54
+ @Pantone137C20: #FFEDD1;
55
+ @Pantone311C80: #62E3FF;
56
+ @Pantone311C20: #E1FAFF;
57
+ @reflexBlue80: #554FC9;
58
+ @reflexBlue20: #EBEAFF;
59
+ @fury80: #F8505D;
60
+ @fury20: #FFC5C9;
61
+
24
62
  // Notification Colors
25
- // TODO: будут отрефакторены после доработки палитры со стороны дизайна
26
- @error: #F1515D;
27
- @success: rgba(0, 185, 86, 0.1);
28
- @info: #DEF7FA;
29
- @warning: #FFEDD1;
30
- @green20: fade(@green, 20);
31
- @warmRedC20: fade(@warmRedC, 20);
32
- @mandarin20: fade(@mandarin, 20);
33
- @Pantone311C20: fade(@Pantone311C, 20);
63
+ // TODO: будут отрефакторены после обновления дизайном Notification по новой палитре
64
+ @error: #FFC4C9;
34
65
  @spbSky160: fade(@spbSky1, 60);
35
- @clearWhite60: fade(@clearWhite, 60);
36
- @clearWhite20: fade(@clearWhite, 20);
66
+ @base30: fade(@base, 30);
37
67
 
38
68
  // Additional Colors Variants
39
- @clearWhite50: fade(@clearWhite, 50);
40
- @freshAsphalt25: fade(@freshAsphalt, 25);
41
- @freshAsphalt50: fade(@freshAsphalt, 50);
69
+ @content25: fade(@content, 25);
42
70
  @fullBlack25: fade(@fullBlack, 25);
43
71
  @fullBlack50: fade(@fullBlack, 50);
44
- @freshAsphaltLighten50: lighten(@freshAsphalt, 50);
72
+ @contentLighten50: lighten(@content, 50);
45
73
 
46
74
  // BREAKPOINTS
47
75
  @mobileSmallEnd: 479px;
@@ -199,7 +227,7 @@ h5 {
199
227
  }
200
228
 
201
229
  .link() {
202
- color: @link;
230
+ color: @systemBlue;
203
231
  text-decoration: none;
204
232
 
205
233
  &:hover {