@megafon/ui-shared 5.14.0 → 5.15.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.15.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.14.0...@megafon/ui-shared@5.15.0) (2024-07-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **banner:** fix banner height ([b2315de](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/b2315de6ce1bd08dacf3f80bdf9d07a45de480b5))
12
+
13
+
14
+ ### Features
15
+
16
+ * **banner, imagebanner:** update components ([c6e8d6b](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/c6e8d6bf308a6d179b768aceba23e564d17f3d64))
17
+
18
+
19
+
20
+
21
+
6
22
  # [5.14.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.13.0...@megafon/ui-shared@5.14.0) (2024-06-26)
7
23
 
8
24
 
@@ -7,26 +7,29 @@ h5 {
7
7
  }
8
8
  .mfui-image-banner {
9
9
  position: relative;
10
+ display: -webkit-box;
11
+ display: -ms-flexbox;
12
+ display: flex;
13
+ -webkit-box-orient: vertical;
14
+ -webkit-box-direction: normal;
15
+ -ms-flex-direction: column;
16
+ flex-direction: column;
17
+ -webkit-box-pack: justify;
18
+ -ms-flex-pack: justify;
19
+ justify-content: space-between;
10
20
  overflow: hidden;
11
21
  }
12
22
  @media screen and (min-width: 1024px) {
13
23
  .mfui-image-banner {
14
- height: 420px;
15
- padding: 0 80px;
16
- }
17
- }
18
- @media screen and (min-width: 1024px) {
19
- .mfui-image-banner__wrapper {
20
- display: -webkit-box;
21
- display: -ms-flexbox;
22
- display: flex;
24
+ -webkit-box-orient: horizontal;
25
+ -webkit-box-direction: normal;
26
+ -ms-flex-direction: row;
27
+ flex-direction: row;
23
28
  -webkit-box-align: center;
24
29
  -ms-flex-align: center;
25
30
  align-items: center;
26
- -webkit-box-pack: justify;
27
- -ms-flex-pack: justify;
28
- justify-content: space-between;
29
- height: 100%;
31
+ height: 420px;
32
+ padding: 0 80px;
30
33
  }
31
34
  }
32
35
  .mfui-image-banner__picture {
@@ -68,11 +71,11 @@ h5 {
68
71
  .mfui-image-banner__background-image {
69
72
  display: block;
70
73
  max-width: 100%;
71
- max-height: 250px;
74
+ max-height: 150px;
72
75
  }
73
76
  @media screen and (min-width: 768px) and (max-width: 1023px) {
74
77
  .mfui-image-banner__background-image {
75
- max-height: 280px;
78
+ max-height: 230px;
76
79
  }
77
80
  }
78
81
  @media screen and (min-width: 1024px) {
@@ -95,11 +98,6 @@ h5 {
95
98
  text-align: center;
96
99
  }
97
100
  }
98
- @media screen and (max-width: 1023px) {
99
- .mfui-image-banner_bottom-offset .mfui-image-banner__content {
100
- padding-bottom: 72px;
101
- }
102
- }
103
101
  .mfui-image-banner__description {
104
102
  margin-top: 16px;
105
103
  white-space: pre-wrap;
@@ -54,11 +54,15 @@ export interface IImageBannerProps {
54
54
  /** Ссылка на корневой элемент */
55
55
  rootRef?: Ref<HTMLDivElement>;
56
56
  /** Заголовок */
57
- title: string | React.ReactNode | React.ReactNode[];
57
+ title?: string | React.ReactNode | React.ReactNode[];
58
58
  /** Текст-описание */
59
59
  description?: string | React.ReactNode | React.ReactNode[];
60
60
  /** Строка со стоимостью услуги */
61
61
  cost?: string;
62
+ /** Тег заголовка на разрешении экрана 0-767 */
63
+ headerLevelMobile?: 'h1' | 'h2';
64
+ /** Тег заголовка на разрешении экрана 768+ */
65
+ headerLevel?: 'h1' | 'h2';
62
66
  /** Фоновый цвет */
63
67
  backgroundColor?: BackgroundColorType;
64
68
  /** Радиус границы */
@@ -81,10 +85,8 @@ export interface IImageBannerProps {
81
85
  isImageFullWidth?: boolean;
82
86
  /** Данные для блока с бейджами */
83
87
  badges?: PriceBadgePropsType[];
84
- /** Дополнительный отступ снизу при использовании в баннере */
85
- hasBottomOffset?: boolean;
86
88
  /** Элемент блока с рекламой */
87
- adBlock?: JSX.Element;
89
+ adBlock?: JSX.Element | null;
88
90
  }
89
91
  declare const ImageBanner: React.FC<IImageBannerProps>;
90
92
  export default ImageBanner;
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import "core-js/modules/es.symbol.js";
3
4
  import "core-js/modules/es.symbol.description.js";
4
5
  import "core-js/modules/es.array.map.js";
@@ -77,6 +78,10 @@ var ImageBanner = function ImageBanner(_ref2) {
77
78
  title = _ref2.title,
78
79
  description = _ref2.description,
79
80
  cost = _ref2.cost,
81
+ _ref2$headerLevelMobi = _ref2.headerLevelMobile,
82
+ headerLevelMobile = _ref2$headerLevelMobi === void 0 ? 'h1' : _ref2$headerLevelMobi,
83
+ _ref2$headerLevel = _ref2.headerLevel,
84
+ headerLevel = _ref2$headerLevel === void 0 ? 'h1' : _ref2$headerLevel,
80
85
  _ref2$backgroundColor = _ref2.backgroundColor,
81
86
  backgroundColor = _ref2$backgroundColor === void 0 ? BackgroundColor.TRANSPARENT : _ref2$backgroundColor,
82
87
  _ref2$radius = _ref2.radius,
@@ -85,17 +90,36 @@ var ImageBanner = function ImageBanner(_ref2) {
85
90
  isImageFullWidth = _ref2.isImageFullWidth,
86
91
  _ref2$badges = _ref2.badges,
87
92
  badges = _ref2$badges === void 0 ? [] : _ref2$badges,
88
- hasBottomOffset = _ref2.hasBottomOffset,
89
93
  adBlock = _ref2.adBlock,
90
94
  _ref2$children = _ref2.children,
91
95
  children = _ref2$children === void 0 ? [] : _ref2$children;
96
+
97
+ var _React$useState = React.useState(false),
98
+ _React$useState2 = _slicedToArray(_React$useState, 2),
99
+ isMobile = _React$useState2[0],
100
+ setIsMobile = _React$useState2[1];
101
+
102
+ React.useEffect(function () {
103
+ var mediaQuery = window.matchMedia("(max-width: ".concat(breakpoints.MOBILE_MIDDLE_END, "px)"));
104
+
105
+ var handleMediaChange = function handleMediaChange(_ref3) {
106
+ var matches = _ref3.matches;
107
+ setIsMobile(matches);
108
+ };
109
+
110
+ setIsMobile(mediaQuery.matches);
111
+ mediaQuery.addEventListener('change', handleMediaChange);
112
+ return function () {
113
+ mediaQuery.removeEventListener('change', handleMediaChange);
114
+ };
115
+ }, []);
92
116
  var navTheme = getTheme(backgroundColor);
93
117
  var hasImage = !!(imageMobile || imageMobile2x || imageDesktop || imageDesktop2x);
94
118
  var renderBadges = !!badges.length && /*#__PURE__*/React.createElement("div", {
95
119
  className: cn('badges', [classes.badges])
96
- }, badges.map(function (_ref3) {
97
- var text = _ref3.text,
98
- iconType = _ref3.iconType;
120
+ }, badges.map(function (_ref4) {
121
+ var text = _ref4.text,
122
+ iconType = _ref4.iconType;
99
123
  return /*#__PURE__*/React.createElement(PriceBadge, {
100
124
  className: classes.badge,
101
125
  theme: navTheme,
@@ -112,7 +136,8 @@ var ImageBanner = function ImageBanner(_ref2) {
112
136
  className: cn('badges-container', [classes.badgesContainer])
113
137
  }, renderBadges, renderAdBlock), !!title && /*#__PURE__*/React.createElement(Header, {
114
138
  className: cn('title', [classes.title]),
115
- color: "inherit"
139
+ color: "inherit",
140
+ as: isMobile ? headerLevelMobile : headerLevel
116
141
  }, typeof title === 'string' ? convert(title, titleConvertConfig) : title), !!description && /*#__PURE__*/React.createElement(Header, {
117
142
  className: cn('description', [classes.description]),
118
143
  as: "h5",
@@ -142,13 +167,10 @@ var ImageBanner = function ImageBanner(_ref2) {
142
167
  'has-image': hasImage,
143
168
  'auto-height': autoHeight,
144
169
  'full-width': isImageFullWidth,
145
- 'bottom-offset': hasBottomOffset && !hasImage,
146
170
  radius: radius
147
171
  }, [className, classes.root]),
148
172
  ref: rootRef
149
- }), /*#__PURE__*/React.createElement("div", {
150
- className: cn('wrapper')
151
- }, renderContent, hasImage && renderImage));
173
+ }), renderContent, hasImage && renderImage);
152
174
  };
153
175
 
154
176
  ImageBanner.propTypes = {
@@ -171,9 +193,11 @@ ImageBanner.propTypes = {
171
193
  rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
172
194
  current: PropTypes.elementType
173
195
  }), PropTypes.any])]),
174
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
196
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
175
197
  description: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
176
198
  cost: PropTypes.string,
199
+ headerLevelMobile: PropTypes.oneOf(['h1', 'h2']),
200
+ headerLevel: PropTypes.oneOf(['h1', 'h2']),
177
201
  backgroundColor: PropTypes.oneOf(Object.values(BackgroundColor)),
178
202
  radius: PropTypes.oneOf(Object.values(Radius)),
179
203
  imageMobile: PropTypes.string,
@@ -188,7 +212,6 @@ ImageBanner.propTypes = {
188
212
  iconType: PropTypes.oneOf(['timer', 'price', 'check', 'attention', 'info', 'profile']).isRequired,
189
213
  text: PropTypes.string.isRequired
190
214
  }).isRequired),
191
- hasBottomOffset: PropTypes.bool,
192
215
  adBlock: PropTypes.element
193
216
  };
194
217
  export default ImageBanner;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
@@ -7,26 +7,29 @@ h5 {
7
7
  }
8
8
  .mfui-image-banner {
9
9
  position: relative;
10
+ display: -webkit-box;
11
+ display: -ms-flexbox;
12
+ display: flex;
13
+ -webkit-box-orient: vertical;
14
+ -webkit-box-direction: normal;
15
+ -ms-flex-direction: column;
16
+ flex-direction: column;
17
+ -webkit-box-pack: justify;
18
+ -ms-flex-pack: justify;
19
+ justify-content: space-between;
10
20
  overflow: hidden;
11
21
  }
12
22
  @media screen and (min-width: 1024px) {
13
23
  .mfui-image-banner {
14
- height: 420px;
15
- padding: 0 80px;
16
- }
17
- }
18
- @media screen and (min-width: 1024px) {
19
- .mfui-image-banner__wrapper {
20
- display: -webkit-box;
21
- display: -ms-flexbox;
22
- display: flex;
24
+ -webkit-box-orient: horizontal;
25
+ -webkit-box-direction: normal;
26
+ -ms-flex-direction: row;
27
+ flex-direction: row;
23
28
  -webkit-box-align: center;
24
29
  -ms-flex-align: center;
25
30
  align-items: center;
26
- -webkit-box-pack: justify;
27
- -ms-flex-pack: justify;
28
- justify-content: space-between;
29
- height: 100%;
31
+ height: 420px;
32
+ padding: 0 80px;
30
33
  }
31
34
  }
32
35
  .mfui-image-banner__picture {
@@ -68,11 +71,11 @@ h5 {
68
71
  .mfui-image-banner__background-image {
69
72
  display: block;
70
73
  max-width: 100%;
71
- max-height: 250px;
74
+ max-height: 150px;
72
75
  }
73
76
  @media screen and (min-width: 768px) and (max-width: 1023px) {
74
77
  .mfui-image-banner__background-image {
75
- max-height: 280px;
78
+ max-height: 230px;
76
79
  }
77
80
  }
78
81
  @media screen and (min-width: 1024px) {
@@ -95,11 +98,6 @@ h5 {
95
98
  text-align: center;
96
99
  }
97
100
  }
98
- @media screen and (max-width: 1023px) {
99
- .mfui-image-banner_bottom-offset .mfui-image-banner__content {
100
- padding-bottom: 72px;
101
- }
102
- }
103
101
  .mfui-image-banner__description {
104
102
  margin-top: 16px;
105
103
  white-space: pre-wrap;
@@ -54,11 +54,15 @@ export interface IImageBannerProps {
54
54
  /** Ссылка на корневой элемент */
55
55
  rootRef?: Ref<HTMLDivElement>;
56
56
  /** Заголовок */
57
- title: string | React.ReactNode | React.ReactNode[];
57
+ title?: string | React.ReactNode | React.ReactNode[];
58
58
  /** Текст-описание */
59
59
  description?: string | React.ReactNode | React.ReactNode[];
60
60
  /** Строка со стоимостью услуги */
61
61
  cost?: string;
62
+ /** Тег заголовка на разрешении экрана 0-767 */
63
+ headerLevelMobile?: 'h1' | 'h2';
64
+ /** Тег заголовка на разрешении экрана 768+ */
65
+ headerLevel?: 'h1' | 'h2';
62
66
  /** Фоновый цвет */
63
67
  backgroundColor?: BackgroundColorType;
64
68
  /** Радиус границы */
@@ -81,10 +85,8 @@ export interface IImageBannerProps {
81
85
  isImageFullWidth?: boolean;
82
86
  /** Данные для блока с бейджами */
83
87
  badges?: PriceBadgePropsType[];
84
- /** Дополнительный отступ снизу при использовании в баннере */
85
- hasBottomOffset?: boolean;
86
88
  /** Элемент блока с рекламой */
87
- adBlock?: JSX.Element;
89
+ adBlock?: JSX.Element | null;
88
90
  }
89
91
  declare const ImageBanner: React.FC<IImageBannerProps>;
90
92
  export default ImageBanner;
@@ -9,6 +9,8 @@ exports["default"] = exports.ImageVerticalAlign = exports.NavTheme = exports.Rad
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
12
14
  require("core-js/modules/es.symbol.js");
13
15
 
14
16
  require("core-js/modules/es.symbol.description.js");
@@ -105,6 +107,10 @@ var ImageBanner = function ImageBanner(_ref2) {
105
107
  title = _ref2.title,
106
108
  description = _ref2.description,
107
109
  cost = _ref2.cost,
110
+ _ref2$headerLevelMobi = _ref2.headerLevelMobile,
111
+ headerLevelMobile = _ref2$headerLevelMobi === void 0 ? 'h1' : _ref2$headerLevelMobi,
112
+ _ref2$headerLevel = _ref2.headerLevel,
113
+ headerLevel = _ref2$headerLevel === void 0 ? 'h1' : _ref2$headerLevel,
108
114
  _ref2$backgroundColor = _ref2.backgroundColor,
109
115
  backgroundColor = _ref2$backgroundColor === void 0 ? BackgroundColor.TRANSPARENT : _ref2$backgroundColor,
110
116
  _ref2$radius = _ref2.radius,
@@ -113,18 +119,38 @@ var ImageBanner = function ImageBanner(_ref2) {
113
119
  isImageFullWidth = _ref2.isImageFullWidth,
114
120
  _ref2$badges = _ref2.badges,
115
121
  badges = _ref2$badges === void 0 ? [] : _ref2$badges,
116
- hasBottomOffset = _ref2.hasBottomOffset,
117
122
  adBlock = _ref2.adBlock,
118
123
  _ref2$children = _ref2.children,
119
124
  children = _ref2$children === void 0 ? [] : _ref2$children;
125
+
126
+ var _React$useState = _react["default"].useState(false),
127
+ _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
128
+ isMobile = _React$useState2[0],
129
+ setIsMobile = _React$useState2[1];
130
+
131
+ _react["default"].useEffect(function () {
132
+ var mediaQuery = window.matchMedia("(max-width: ".concat(_uiHelpers.breakpoints.MOBILE_MIDDLE_END, "px)"));
133
+
134
+ var handleMediaChange = function handleMediaChange(_ref3) {
135
+ var matches = _ref3.matches;
136
+ setIsMobile(matches);
137
+ };
138
+
139
+ setIsMobile(mediaQuery.matches);
140
+ mediaQuery.addEventListener('change', handleMediaChange);
141
+ return function () {
142
+ mediaQuery.removeEventListener('change', handleMediaChange);
143
+ };
144
+ }, []);
145
+
120
146
  var navTheme = getTheme(backgroundColor);
121
147
  var hasImage = !!(imageMobile || imageMobile2x || imageDesktop || imageDesktop2x);
122
148
 
123
149
  var renderBadges = !!badges.length && /*#__PURE__*/_react["default"].createElement("div", {
124
150
  className: cn('badges', [classes.badges])
125
- }, badges.map(function (_ref3) {
126
- var text = _ref3.text,
127
- iconType = _ref3.iconType;
151
+ }, badges.map(function (_ref4) {
152
+ var text = _ref4.text,
153
+ iconType = _ref4.iconType;
128
154
  return /*#__PURE__*/_react["default"].createElement(_uiCore.PriceBadge, {
129
155
  className: classes.badge,
130
156
  theme: navTheme,
@@ -143,7 +169,8 @@ var ImageBanner = function ImageBanner(_ref2) {
143
169
  className: cn('badges-container', [classes.badgesContainer])
144
170
  }, renderBadges, renderAdBlock), !!title && /*#__PURE__*/_react["default"].createElement(_uiCore.Header, {
145
171
  className: cn('title', [classes.title]),
146
- color: "inherit"
172
+ color: "inherit",
173
+ as: isMobile ? headerLevelMobile : headerLevel
147
174
  }, typeof title === 'string' ? (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig) : title), !!description && /*#__PURE__*/_react["default"].createElement(_uiCore.Header, {
148
175
  className: cn('description', [classes.description]),
149
176
  as: "h5",
@@ -175,13 +202,10 @@ var ImageBanner = function ImageBanner(_ref2) {
175
202
  'has-image': hasImage,
176
203
  'auto-height': autoHeight,
177
204
  'full-width': isImageFullWidth,
178
- 'bottom-offset': hasBottomOffset && !hasImage,
179
205
  radius: radius
180
206
  }, [className, classes.root]),
181
207
  ref: rootRef
182
- }), /*#__PURE__*/_react["default"].createElement("div", {
183
- className: cn('wrapper')
184
- }, renderContent, hasImage && renderImage));
208
+ }), renderContent, hasImage && renderImage);
185
209
  };
186
210
 
187
211
  ImageBanner.propTypes = {
@@ -204,9 +228,11 @@ ImageBanner.propTypes = {
204
228
  rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
205
229
  current: PropTypes.elementType
206
230
  }), PropTypes.any])]),
207
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
231
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
208
232
  description: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
209
233
  cost: PropTypes.string,
234
+ headerLevelMobile: PropTypes.oneOf(['h1', 'h2']),
235
+ headerLevel: PropTypes.oneOf(['h1', 'h2']),
210
236
  backgroundColor: PropTypes.oneOf(Object.values(BackgroundColor)),
211
237
  radius: PropTypes.oneOf(Object.values(Radius)),
212
238
  imageMobile: PropTypes.string,
@@ -221,7 +247,6 @@ ImageBanner.propTypes = {
221
247
  iconType: PropTypes.oneOf(['timer', 'price', 'check', 'attention', 'info', 'profile']).isRequired,
222
248
  text: PropTypes.string.isRequired
223
249
  }).isRequired),
224
- hasBottomOffset: PropTypes.bool,
225
250
  adBlock: PropTypes.element
226
251
  };
227
252
  var _default = ImageBanner;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-shared",
3
- "version": "5.14.0",
3
+ "version": "5.15.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "dependencies": {
84
84
  "@babel/runtime": "^7.8.4",
85
- "@megafon/ui-core": "^5.16.0",
85
+ "@megafon/ui-core": "^5.17.0",
86
86
  "@megafon/ui-helpers": "^2.6.0",
87
87
  "core-js": "^3.6.4",
88
88
  "htmr": "^0.9.2",
@@ -90,5 +90,5 @@
90
90
  "prop-types": "^15.7.2",
91
91
  "swiper": "^6.5.6"
92
92
  },
93
- "gitHead": "0d4f96ecbc805db6a1b2200dd9adbb707349d474"
93
+ "gitHead": "426c7d8e65c13746f9cc1c895a2e7e1b4b08316a"
94
94
  }