@megafon/ui-shared 6.0.0-beta.1 → 6.0.0-beta.2
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/dist/es/components/Card/Card.d.ts +6 -2
- package/dist/es/components/Card/Card.js +26 -6
- package/dist/es/components/Card/types.d.ts +6 -0
- package/dist/es/components/Container/Container.js +3 -1
- package/dist/es/components/ImageBanner/ImageBanner.d.ts +12 -14
- package/dist/es/components/ImageBanner/ImageBanner.js +31 -23
- package/dist/lib/components/Card/Card.d.ts +6 -2
- package/dist/lib/components/Card/Card.js +26 -6
- package/dist/lib/components/Card/types.d.ts +6 -0
- package/dist/lib/components/Container/Container.js +3 -1
- package/dist/lib/components/ImageBanner/ImageBanner.d.ts +12 -14
- package/dist/lib/components/ImageBanner/ImageBanner.js +30 -22
- package/package.json +7 -9
- package/dist/es/components/AudioPlayer/style/AudioPlayer.css +0 -1
- package/dist/es/components/AudioPlayer/style/AudioProgress.css +0 -1
- package/dist/es/components/AudioPlayer/style/AudioRange.css +0 -1
- package/dist/es/components/AudioPlayer/style/AudioVolume.css +0 -1
- package/dist/es/components/BenefitsIcons/style/BenefitsIcons.css +0 -1
- package/dist/es/components/BenefitsIcons/style/BenefitsIconsTile.css +0 -1
- package/dist/es/components/Breadcrumbs/components/BreadcrumbsItem.css +0 -1
- package/dist/es/components/Card/Card.css +0 -1
- package/dist/es/components/Container/Container.css +0 -1
- package/dist/es/components/DownloadLinks/DownloadLink.css +0 -1
- package/dist/es/components/DownloadLinks/DownloadLinks.css +0 -1
- package/dist/es/components/ImageBanner/ImageBanner.css +0 -1
- package/dist/es/components/Instructions/Instructions.css +0 -1
- package/dist/es/components/NotificationBox/NotificationBox.css +0 -1
- package/dist/es/components/PageTitle/PageTitle.css +0 -1
- package/dist/es/components/Partners/Partners.css +0 -1
- package/dist/es/components/PictureWithDescription/PictureWithDescription.css +0 -1
- package/dist/es/components/Property/Property.css +0 -1
- package/dist/es/components/Property/PropertyDescription.css +0 -1
- package/dist/es/components/Steps/Steps.css +0 -1
- package/dist/es/components/Steps/StepsItem.css +0 -1
- package/dist/es/components/StoreBanner/StoreBanner.css +0 -1
- package/dist/es/components/StoreButton/StoreButton.css +0 -1
- package/dist/es/components/Table/Table.css +0 -1
- package/dist/es/components/TextBox/TextBox.css +0 -1
- package/dist/es/components/TextBox/TextBoxPicture.css +0 -1
- package/dist/es/components/TextWithIcon/TextWithIcon.css +0 -1
- package/dist/es/components/TextWithIcon/TextWithIconItem.css +0 -1
- package/dist/es/components/TitleDescriptionBox/TitleDescriptionBox.css +0 -1
- package/dist/es/components/VideoBanner/VideoBanner.css +0 -1
- package/dist/es/components/VideoBlock/VideoBlock.css +0 -1
- package/dist/lib/components/AudioPlayer/style/AudioPlayer.css +0 -1
- package/dist/lib/components/AudioPlayer/style/AudioProgress.css +0 -1
- package/dist/lib/components/AudioPlayer/style/AudioRange.css +0 -1
- package/dist/lib/components/AudioPlayer/style/AudioVolume.css +0 -1
- package/dist/lib/components/BenefitsIcons/style/BenefitsIcons.css +0 -1
- package/dist/lib/components/BenefitsIcons/style/BenefitsIconsTile.css +0 -1
- package/dist/lib/components/Breadcrumbs/components/BreadcrumbsItem.css +0 -1
- package/dist/lib/components/Card/Card.css +0 -1
- package/dist/lib/components/Container/Container.css +0 -1
- package/dist/lib/components/DownloadLinks/DownloadLink.css +0 -1
- package/dist/lib/components/DownloadLinks/DownloadLinks.css +0 -1
- package/dist/lib/components/ImageBanner/ImageBanner.css +0 -1
- package/dist/lib/components/Instructions/Instructions.css +0 -1
- package/dist/lib/components/NotificationBox/NotificationBox.css +0 -1
- package/dist/lib/components/PageTitle/PageTitle.css +0 -1
- package/dist/lib/components/Partners/Partners.css +0 -1
- package/dist/lib/components/PictureWithDescription/PictureWithDescription.css +0 -1
- package/dist/lib/components/Property/Property.css +0 -1
- package/dist/lib/components/Property/PropertyDescription.css +0 -1
- package/dist/lib/components/Steps/Steps.css +0 -1
- package/dist/lib/components/Steps/StepsItem.css +0 -1
- package/dist/lib/components/StoreBanner/StoreBanner.css +0 -1
- package/dist/lib/components/StoreButton/StoreButton.css +0 -1
- package/dist/lib/components/Table/Table.css +0 -1
- package/dist/lib/components/TextBox/TextBox.css +0 -1
- package/dist/lib/components/TextBox/TextBoxPicture.css +0 -1
- package/dist/lib/components/TextWithIcon/TextWithIcon.css +0 -1
- package/dist/lib/components/TextWithIcon/TextWithIconItem.css +0 -1
- package/dist/lib/components/TitleDescriptionBox/TitleDescriptionBox.css +0 -1
- package/dist/lib/components/VideoBanner/VideoBanner.css +0 -1
- package/dist/lib/components/VideoBlock/VideoBlock.css +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import './Card.scss';
|
3
|
-
import { ButtonType, FeaturesList, IconsList, Image, Link, Price, TextsList, Title } from './types';
|
3
|
+
import { ButtonType, FeaturesList, IconsList, Image, Link, MarkerList, Price, TextsList, Title } from './types';
|
4
4
|
export interface ICard {
|
5
5
|
/** Дополнительные data атрибуты к внутренним элементам */
|
6
6
|
dataAttrs?: {
|
@@ -22,7 +22,7 @@ export interface ICard {
|
|
22
22
|
rootRef?: React.Ref<HTMLDivElement | HTMLAnchorElement>;
|
23
23
|
isFullHeight?: boolean;
|
24
24
|
/** Вид */
|
25
|
-
view?: 'shadow' | 'background';
|
25
|
+
view?: 'shadow' | 'hover-shadow' | 'background';
|
26
26
|
/** Ссылка для карточки */
|
27
27
|
link?: Link;
|
28
28
|
/** Изображение */
|
@@ -31,6 +31,8 @@ export interface ICard {
|
|
31
31
|
icon?: React.ReactNode;
|
32
32
|
/** Заголовок */
|
33
33
|
title: Title;
|
34
|
+
/** Маркированный список */
|
35
|
+
markerList?: MarkerList;
|
34
36
|
/** Список текстов */
|
35
37
|
textsList?: TextsList;
|
36
38
|
/** Список характеристик */
|
@@ -43,6 +45,8 @@ export interface ICard {
|
|
43
45
|
button?: ButtonType;
|
44
46
|
/** Дополнительная кнопка */
|
45
47
|
extraButton?: ButtonType;
|
48
|
+
/** Бейдж */
|
49
|
+
badge?: React.ReactElement;
|
46
50
|
/** Обработчик клика по карточке */
|
47
51
|
onClick?: () => void;
|
48
52
|
}
|
@@ -45,14 +45,16 @@ var Card = function Card(_ref5) {
|
|
45
45
|
image = _ref5.image,
|
46
46
|
icon = _ref5.icon,
|
47
47
|
title = _ref5.title,
|
48
|
+
markerList = _ref5.markerList,
|
48
49
|
textsList = _ref5.textsList,
|
49
50
|
featuresList = _ref5.featuresList,
|
50
51
|
iconsList = _ref5.iconsList,
|
51
52
|
price = _ref5.price,
|
52
53
|
button = _ref5.button,
|
53
54
|
extraButton = _ref5.extraButton,
|
55
|
+
badge = _ref5.badge,
|
54
56
|
onClick = _ref5.onClick;
|
55
|
-
var isOnlyTitle = !image && !icon && !textsList && !featuresList && !iconsList && !price && !button && !extraButton;
|
57
|
+
var isOnlyTitle = !image && !icon && !markerList && !textsList && !featuresList && !iconsList && !price && !button && !extraButton;
|
56
58
|
var isLink = (link === null || link === void 0 ? void 0 : link.href) && !button && !extraButton;
|
57
59
|
var isBottomImage = (image === null || image === void 0 ? void 0 : image.position) === 'bottom';
|
58
60
|
var ElementType = isLink ? 'a' : 'div';
|
@@ -60,14 +62,18 @@ var Card = function Card(_ref5) {
|
|
60
62
|
if (!image) {
|
61
63
|
return null;
|
62
64
|
}
|
65
|
+
var _image$position = image.position,
|
66
|
+
position = _image$position === void 0 ? 'top' : _image$position,
|
67
|
+
src = image.src,
|
68
|
+
alt = image.alt;
|
63
69
|
return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.imgBox), {
|
64
70
|
className: cn('img-box', {
|
65
|
-
position:
|
71
|
+
position: position
|
66
72
|
})
|
67
73
|
}), /*#__PURE__*/React.createElement("img", {
|
68
74
|
className: cn('img'),
|
69
|
-
src:
|
70
|
-
alt:
|
75
|
+
src: src,
|
76
|
+
alt: alt
|
71
77
|
}));
|
72
78
|
};
|
73
79
|
var renderIcon = function renderIcon() {
|
@@ -79,6 +85,18 @@ var Card = function Card(_ref5) {
|
|
79
85
|
}), icon);
|
80
86
|
};
|
81
87
|
var renderContent = function renderContent() {
|
88
|
+
if (markerList) {
|
89
|
+
return /*#__PURE__*/React.createElement("ul", {
|
90
|
+
className: cn('marker-list')
|
91
|
+
}, markerList.map(function (item, i) {
|
92
|
+
return /*#__PURE__*/React.createElement("li", {
|
93
|
+
className: cn('marker-item'),
|
94
|
+
key: i
|
95
|
+
}, convert(item.title, {}), !!item.note && /*#__PURE__*/React.createElement("span", {
|
96
|
+
className: cn('marker-note')
|
97
|
+
}, convert(item.note, {})));
|
98
|
+
}));
|
99
|
+
}
|
82
100
|
if (textsList) {
|
83
101
|
return /*#__PURE__*/React.createElement("div", {
|
84
102
|
className: cn('texts')
|
@@ -193,10 +211,12 @@ var Card = function Card(_ref5) {
|
|
193
211
|
target: isLink ? link === null || link === void 0 ? void 0 : link.target : undefined,
|
194
212
|
onClick: isLink ? onClick : undefined,
|
195
213
|
ref: rootRef
|
196
|
-
}), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/React.createElement(
|
214
|
+
}), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/React.createElement("div", {
|
215
|
+
className: cn('header')
|
216
|
+
}, /*#__PURE__*/React.createElement(Header, {
|
197
217
|
className: cn('title'),
|
198
218
|
as: "h3",
|
199
219
|
align: title.align
|
200
|
-
}, title.text), renderContent(), renderFooter());
|
220
|
+
}, title.text), badge), renderContent(), renderFooter());
|
201
221
|
};
|
202
222
|
export default Card;
|
@@ -20,6 +20,12 @@ export type Title = {
|
|
20
20
|
/** Выравнивание */
|
21
21
|
align?: 'left' | 'center';
|
22
22
|
};
|
23
|
+
export type MarkerList = {
|
24
|
+
/** Заголовок */
|
25
|
+
title: string;
|
26
|
+
/** Примечание */
|
27
|
+
note?: string;
|
28
|
+
}[];
|
23
29
|
export type TextsList = {
|
24
30
|
/** Заголовок */
|
25
31
|
title?: string;
|
@@ -30,6 +30,8 @@ var Container = function Container(_ref) {
|
|
30
30
|
}, [className]),
|
31
31
|
ref: rootRef,
|
32
32
|
id: id
|
33
|
-
}, /*#__PURE__*/React.createElement(
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
34
|
+
className: cn('inner')
|
35
|
+
}, /*#__PURE__*/React.createElement(ContentArea, null, children)));
|
34
36
|
};
|
35
37
|
export default Container;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { PriceBadge } from '@megafon/ui-core';
|
3
2
|
import './ImageBanner.scss';
|
4
3
|
export declare const BackgroundColor: {
|
5
4
|
readonly TRANSPARENT: "transparent";
|
@@ -26,11 +25,6 @@ export declare const ImageVerticalAlign: {
|
|
26
25
|
readonly BOTTOM: "bottom";
|
27
26
|
};
|
28
27
|
export type ImageVerticalAlignType = (typeof ImageVerticalAlign)[keyof typeof ImageVerticalAlign];
|
29
|
-
type PriceBadgeTypes = React.ComponentProps<typeof PriceBadge>;
|
30
|
-
export type PriceBadgePropsType = Pick<PriceBadgeTypes, 'iconType'> & {
|
31
|
-
/** Текст бейджа */
|
32
|
-
text: string;
|
33
|
-
};
|
34
28
|
export interface IImageBannerProps {
|
35
29
|
/** Дополнительные data атрибуты к внутренним элементам */
|
36
30
|
dataAttrs?: {
|
@@ -43,22 +37,27 @@ export interface IImageBannerProps {
|
|
43
37
|
classes?: {
|
44
38
|
root?: string;
|
45
39
|
image?: string;
|
40
|
+
imageSource?: string;
|
46
41
|
title?: string;
|
47
42
|
description?: string;
|
48
43
|
cost?: string;
|
49
44
|
badgesContainer?: string;
|
50
45
|
badges?: string;
|
51
|
-
badge?: string;
|
52
46
|
adBlock?: string;
|
47
|
+
children?: string;
|
53
48
|
};
|
54
49
|
/** Ссылка на корневой элемент */
|
55
50
|
rootRef?: React.Ref<HTMLDivElement>;
|
56
51
|
/** Заголовок */
|
57
|
-
title
|
52
|
+
title?: string | React.ReactNode | React.ReactNode[];
|
58
53
|
/** Текст-описание */
|
59
54
|
description?: string | React.ReactNode | React.ReactNode[];
|
60
55
|
/** Строка со стоимостью услуги */
|
61
56
|
cost?: string;
|
57
|
+
/** Тег заголовка на разрешении экрана 0-767 */
|
58
|
+
headerLevelMobile?: 'h1' | 'h2';
|
59
|
+
/** Тег заголовка на разрешении экрана 768+ */
|
60
|
+
headerLevel?: 'h1' | 'h2';
|
62
61
|
/** Фоновый цвет */
|
63
62
|
backgroundColor?: BackgroundColorType;
|
64
63
|
/** Радиус границы */
|
@@ -79,12 +78,11 @@ export interface IImageBannerProps {
|
|
79
78
|
autoHeight?: boolean;
|
80
79
|
/** Изображение растягивается на всю ширину или вписывается в фиксированный фрейм (по умолчанию фрейм) */
|
81
80
|
isImageFullWidth?: boolean;
|
82
|
-
/**
|
83
|
-
badges?:
|
84
|
-
/** Дополнительный отступ снизу при использовании в баннере */
|
85
|
-
hasBottomOffset?: boolean;
|
81
|
+
/** Бейджи */
|
82
|
+
badges?: JSX.Element[] | JSX.Element;
|
86
83
|
/** Элемент блока с рекламой */
|
87
|
-
adBlock?: JSX.Element;
|
84
|
+
adBlock?: JSX.Element | null;
|
85
|
+
children?: React.ReactNode;
|
88
86
|
}
|
89
|
-
declare const ImageBanner: React.FC<
|
87
|
+
declare const ImageBanner: React.FC<IImageBannerProps>;
|
90
88
|
export default ImageBanner;
|
@@ -1,10 +1,10 @@
|
|
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.concat.js";
|
5
|
-
import "core-js/modules/es.array.map.js";
|
6
6
|
import * as React from 'react';
|
7
|
-
import { Header
|
7
|
+
import { Header } from '@megafon/ui-core';
|
8
8
|
import { breakpoints, cnCreate, filterDataAttrs, convert, titleConvertConfig } from '@megafon/ui-helpers';
|
9
9
|
import "./ImageBanner.css";
|
10
10
|
export var BackgroundColor = {
|
@@ -71,32 +71,41 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
71
71
|
title = _ref2.title,
|
72
72
|
description = _ref2.description,
|
73
73
|
cost = _ref2.cost,
|
74
|
+
_ref2$headerLevelMobi = _ref2.headerLevelMobile,
|
75
|
+
headerLevelMobile = _ref2$headerLevelMobi === void 0 ? 'h1' : _ref2$headerLevelMobi,
|
76
|
+
_ref2$headerLevel = _ref2.headerLevel,
|
77
|
+
headerLevel = _ref2$headerLevel === void 0 ? 'h1' : _ref2$headerLevel,
|
74
78
|
_ref2$backgroundColor = _ref2.backgroundColor,
|
75
79
|
backgroundColor = _ref2$backgroundColor === void 0 ? BackgroundColor.TRANSPARENT : _ref2$backgroundColor,
|
76
80
|
_ref2$radius = _ref2.radius,
|
77
81
|
radius = _ref2$radius === void 0 ? Radius.CORNERS : _ref2$radius,
|
78
82
|
autoHeight = _ref2.autoHeight,
|
79
83
|
isImageFullWidth = _ref2.isImageFullWidth,
|
80
|
-
|
81
|
-
badges = _ref2$badges === void 0 ? [] : _ref2$badges,
|
82
|
-
hasBottomOffset = _ref2.hasBottomOffset,
|
84
|
+
badges = _ref2.badges,
|
83
85
|
adBlock = _ref2.adBlock,
|
84
86
|
_ref2$children = _ref2.children,
|
85
87
|
children = _ref2$children === void 0 ? [] : _ref2$children;
|
88
|
+
var _React$useState = React.useState(false),
|
89
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
90
|
+
isMobile = _React$useState2[0],
|
91
|
+
setIsMobile = _React$useState2[1];
|
92
|
+
React.useEffect(function () {
|
93
|
+
var mediaQuery = window.matchMedia("(max-width: ".concat(breakpoints.MOBILE_MIDDLE_END, "px)"));
|
94
|
+
var handleMediaChange = function handleMediaChange(_ref3) {
|
95
|
+
var matches = _ref3.matches;
|
96
|
+
setIsMobile(matches);
|
97
|
+
};
|
98
|
+
setIsMobile(mediaQuery.matches);
|
99
|
+
mediaQuery.addEventListener('change', handleMediaChange);
|
100
|
+
return function () {
|
101
|
+
mediaQuery.removeEventListener('change', handleMediaChange);
|
102
|
+
};
|
103
|
+
}, []);
|
86
104
|
var navTheme = getTheme(backgroundColor);
|
87
105
|
var hasImage = !!(imageMobile || imageMobile2x || imageDesktop || imageDesktop2x);
|
88
|
-
var renderBadges = !!badges
|
106
|
+
var renderBadges = !!badges && /*#__PURE__*/React.createElement("div", {
|
89
107
|
className: cn('badges', [classes.badges])
|
90
|
-
}, badges
|
91
|
-
var text = _ref3.text,
|
92
|
-
iconType = _ref3.iconType;
|
93
|
-
return /*#__PURE__*/React.createElement(PriceBadge, {
|
94
|
-
className: classes.badge,
|
95
|
-
theme: navTheme,
|
96
|
-
iconType: iconType,
|
97
|
-
key: text
|
98
|
-
}, text);
|
99
|
-
}));
|
108
|
+
}, badges);
|
100
109
|
var renderAdBlock = !!adBlock && /*#__PURE__*/React.createElement("div", {
|
101
110
|
className: cn('ad-block', [classes.adBlock])
|
102
111
|
}, adBlock);
|
@@ -106,7 +115,8 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
106
115
|
className: cn('badges-container', [classes.badgesContainer])
|
107
116
|
}, renderBadges, renderAdBlock), !!title && /*#__PURE__*/React.createElement(Header, {
|
108
117
|
className: cn('title', [classes.title]),
|
109
|
-
color: "inherit"
|
118
|
+
color: "inherit",
|
119
|
+
as: isMobile ? headerLevelMobile : headerLevel
|
110
120
|
}, typeof title === 'string' ? convert(title, titleConvertConfig) : title), !!description && /*#__PURE__*/React.createElement(Header, {
|
111
121
|
className: cn('description', [classes.description]),
|
112
122
|
as: "h5",
|
@@ -114,17 +124,18 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
114
124
|
}, typeof description === 'string' ? convert(description, titleConvertConfig) : description), !!cost && /*#__PURE__*/React.createElement("div", {
|
115
125
|
className: cn('cost', [classes.cost])
|
116
126
|
}, convert(cost, typographyConfig)), !!children && !!React.Children.count(children) && /*#__PURE__*/React.createElement("div", {
|
117
|
-
className: cn('children')
|
127
|
+
className: cn('children', [classes.children])
|
118
128
|
}, children));
|
119
129
|
var renderImage = /*#__PURE__*/React.createElement("picture", {
|
120
130
|
className: cn('picture', {
|
121
131
|
'v-align': imageVerticalAlign
|
122
132
|
})
|
123
133
|
}, /*#__PURE__*/React.createElement("source", {
|
134
|
+
className: classes.imageSource,
|
124
135
|
media: "(min-width: ".concat(breakpoints.DESKTOP_SMALL_START, "px)"),
|
125
136
|
srcSet: "".concat(imageDesktop, ", ").concat(imageDesktop2x, " 2x")
|
126
137
|
}), /*#__PURE__*/React.createElement("img", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.image), {
|
127
|
-
className: cn('
|
138
|
+
className: cn('image', [classes.image]),
|
128
139
|
src: imageMobile || imageMobile2x,
|
129
140
|
srcSet: imageMobile2x ? "".concat(imageMobile2x, " 2x") : undefined,
|
130
141
|
alt: imageAlt
|
@@ -136,12 +147,9 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
136
147
|
'has-image': hasImage,
|
137
148
|
'auto-height': autoHeight,
|
138
149
|
'full-width': isImageFullWidth,
|
139
|
-
'bottom-offset': hasBottomOffset && !hasImage,
|
140
150
|
radius: radius
|
141
151
|
}, [className, classes.root]),
|
142
152
|
ref: rootRef
|
143
|
-
}),
|
144
|
-
className: cn('wrapper')
|
145
|
-
}, renderContent, hasImage && renderImage));
|
153
|
+
}), renderContent, hasImage && renderImage);
|
146
154
|
};
|
147
155
|
export default ImageBanner;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import './Card.scss';
|
3
|
-
import { ButtonType, FeaturesList, IconsList, Image, Link, Price, TextsList, Title } from './types';
|
3
|
+
import { ButtonType, FeaturesList, IconsList, Image, Link, MarkerList, Price, TextsList, Title } from './types';
|
4
4
|
export interface ICard {
|
5
5
|
/** Дополнительные data атрибуты к внутренним элементам */
|
6
6
|
dataAttrs?: {
|
@@ -22,7 +22,7 @@ export interface ICard {
|
|
22
22
|
rootRef?: React.Ref<HTMLDivElement | HTMLAnchorElement>;
|
23
23
|
isFullHeight?: boolean;
|
24
24
|
/** Вид */
|
25
|
-
view?: 'shadow' | 'background';
|
25
|
+
view?: 'shadow' | 'hover-shadow' | 'background';
|
26
26
|
/** Ссылка для карточки */
|
27
27
|
link?: Link;
|
28
28
|
/** Изображение */
|
@@ -31,6 +31,8 @@ export interface ICard {
|
|
31
31
|
icon?: React.ReactNode;
|
32
32
|
/** Заголовок */
|
33
33
|
title: Title;
|
34
|
+
/** Маркированный список */
|
35
|
+
markerList?: MarkerList;
|
34
36
|
/** Список текстов */
|
35
37
|
textsList?: TextsList;
|
36
38
|
/** Список характеристик */
|
@@ -43,6 +45,8 @@ export interface ICard {
|
|
43
45
|
button?: ButtonType;
|
44
46
|
/** Дополнительная кнопка */
|
45
47
|
extraButton?: ButtonType;
|
48
|
+
/** Бейдж */
|
49
|
+
badge?: React.ReactElement;
|
46
50
|
/** Обработчик клика по карточке */
|
47
51
|
onClick?: () => void;
|
48
52
|
}
|
@@ -54,14 +54,16 @@ var Card = function Card(_ref5) {
|
|
54
54
|
image = _ref5.image,
|
55
55
|
icon = _ref5.icon,
|
56
56
|
title = _ref5.title,
|
57
|
+
markerList = _ref5.markerList,
|
57
58
|
textsList = _ref5.textsList,
|
58
59
|
featuresList = _ref5.featuresList,
|
59
60
|
iconsList = _ref5.iconsList,
|
60
61
|
price = _ref5.price,
|
61
62
|
button = _ref5.button,
|
62
63
|
extraButton = _ref5.extraButton,
|
64
|
+
badge = _ref5.badge,
|
63
65
|
onClick = _ref5.onClick;
|
64
|
-
var isOnlyTitle = !image && !icon && !textsList && !featuresList && !iconsList && !price && !button && !extraButton;
|
66
|
+
var isOnlyTitle = !image && !icon && !markerList && !textsList && !featuresList && !iconsList && !price && !button && !extraButton;
|
65
67
|
var isLink = (link === null || link === void 0 ? void 0 : link.href) && !button && !extraButton;
|
66
68
|
var isBottomImage = (image === null || image === void 0 ? void 0 : image.position) === 'bottom';
|
67
69
|
var ElementType = isLink ? 'a' : 'div';
|
@@ -69,14 +71,18 @@ var Card = function Card(_ref5) {
|
|
69
71
|
if (!image) {
|
70
72
|
return null;
|
71
73
|
}
|
74
|
+
var _image$position = image.position,
|
75
|
+
position = _image$position === void 0 ? 'top' : _image$position,
|
76
|
+
src = image.src,
|
77
|
+
alt = image.alt;
|
72
78
|
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.imgBox), {
|
73
79
|
className: cn('img-box', {
|
74
|
-
position:
|
80
|
+
position: position
|
75
81
|
})
|
76
82
|
}), /*#__PURE__*/React.createElement("img", {
|
77
83
|
className: cn('img'),
|
78
|
-
src:
|
79
|
-
alt:
|
84
|
+
src: src,
|
85
|
+
alt: alt
|
80
86
|
}));
|
81
87
|
};
|
82
88
|
var renderIcon = function renderIcon() {
|
@@ -88,6 +94,18 @@ var Card = function Card(_ref5) {
|
|
88
94
|
}), icon);
|
89
95
|
};
|
90
96
|
var renderContent = function renderContent() {
|
97
|
+
if (markerList) {
|
98
|
+
return /*#__PURE__*/React.createElement("ul", {
|
99
|
+
className: cn('marker-list')
|
100
|
+
}, markerList.map(function (item, i) {
|
101
|
+
return /*#__PURE__*/React.createElement("li", {
|
102
|
+
className: cn('marker-item'),
|
103
|
+
key: i
|
104
|
+
}, (0, _uiHelpers.convert)(item.title, {}), !!item.note && /*#__PURE__*/React.createElement("span", {
|
105
|
+
className: cn('marker-note')
|
106
|
+
}, (0, _uiHelpers.convert)(item.note, {})));
|
107
|
+
}));
|
108
|
+
}
|
91
109
|
if (textsList) {
|
92
110
|
return /*#__PURE__*/React.createElement("div", {
|
93
111
|
className: cn('texts')
|
@@ -202,10 +220,12 @@ var Card = function Card(_ref5) {
|
|
202
220
|
target: isLink ? link === null || link === void 0 ? void 0 : link.target : undefined,
|
203
221
|
onClick: isLink ? onClick : undefined,
|
204
222
|
ref: rootRef
|
205
|
-
}), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/React.createElement(
|
223
|
+
}), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/React.createElement("div", {
|
224
|
+
className: cn('header')
|
225
|
+
}, /*#__PURE__*/React.createElement(_uiCore.Header, {
|
206
226
|
className: cn('title'),
|
207
227
|
as: "h3",
|
208
228
|
align: title.align
|
209
|
-
}, title.text), renderContent(), renderFooter());
|
229
|
+
}, title.text), badge), renderContent(), renderFooter());
|
210
230
|
};
|
211
231
|
var _default = exports["default"] = Card;
|
@@ -20,6 +20,12 @@ export type Title = {
|
|
20
20
|
/** Выравнивание */
|
21
21
|
align?: 'left' | 'center';
|
22
22
|
};
|
23
|
+
export type MarkerList = {
|
24
|
+
/** Заголовок */
|
25
|
+
title: string;
|
26
|
+
/** Примечание */
|
27
|
+
note?: string;
|
28
|
+
}[];
|
23
29
|
export type TextsList = {
|
24
30
|
/** Заголовок */
|
25
31
|
title?: string;
|
@@ -38,6 +38,8 @@ var Container = function Container(_ref) {
|
|
38
38
|
}, [className]),
|
39
39
|
ref: rootRef,
|
40
40
|
id: id
|
41
|
-
}, /*#__PURE__*/React.createElement(
|
41
|
+
}, /*#__PURE__*/React.createElement("div", {
|
42
|
+
className: cn('inner')
|
43
|
+
}, /*#__PURE__*/React.createElement(_uiCore.ContentArea, null, children)));
|
42
44
|
};
|
43
45
|
var _default = exports["default"] = Container;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { PriceBadge } from '@megafon/ui-core';
|
3
2
|
import './ImageBanner.scss';
|
4
3
|
export declare const BackgroundColor: {
|
5
4
|
readonly TRANSPARENT: "transparent";
|
@@ -26,11 +25,6 @@ export declare const ImageVerticalAlign: {
|
|
26
25
|
readonly BOTTOM: "bottom";
|
27
26
|
};
|
28
27
|
export type ImageVerticalAlignType = (typeof ImageVerticalAlign)[keyof typeof ImageVerticalAlign];
|
29
|
-
type PriceBadgeTypes = React.ComponentProps<typeof PriceBadge>;
|
30
|
-
export type PriceBadgePropsType = Pick<PriceBadgeTypes, 'iconType'> & {
|
31
|
-
/** Текст бейджа */
|
32
|
-
text: string;
|
33
|
-
};
|
34
28
|
export interface IImageBannerProps {
|
35
29
|
/** Дополнительные data атрибуты к внутренним элементам */
|
36
30
|
dataAttrs?: {
|
@@ -43,22 +37,27 @@ export interface IImageBannerProps {
|
|
43
37
|
classes?: {
|
44
38
|
root?: string;
|
45
39
|
image?: string;
|
40
|
+
imageSource?: string;
|
46
41
|
title?: string;
|
47
42
|
description?: string;
|
48
43
|
cost?: string;
|
49
44
|
badgesContainer?: string;
|
50
45
|
badges?: string;
|
51
|
-
badge?: string;
|
52
46
|
adBlock?: string;
|
47
|
+
children?: string;
|
53
48
|
};
|
54
49
|
/** Ссылка на корневой элемент */
|
55
50
|
rootRef?: React.Ref<HTMLDivElement>;
|
56
51
|
/** Заголовок */
|
57
|
-
title
|
52
|
+
title?: string | React.ReactNode | React.ReactNode[];
|
58
53
|
/** Текст-описание */
|
59
54
|
description?: string | React.ReactNode | React.ReactNode[];
|
60
55
|
/** Строка со стоимостью услуги */
|
61
56
|
cost?: string;
|
57
|
+
/** Тег заголовка на разрешении экрана 0-767 */
|
58
|
+
headerLevelMobile?: 'h1' | 'h2';
|
59
|
+
/** Тег заголовка на разрешении экрана 768+ */
|
60
|
+
headerLevel?: 'h1' | 'h2';
|
62
61
|
/** Фоновый цвет */
|
63
62
|
backgroundColor?: BackgroundColorType;
|
64
63
|
/** Радиус границы */
|
@@ -79,12 +78,11 @@ export interface IImageBannerProps {
|
|
79
78
|
autoHeight?: boolean;
|
80
79
|
/** Изображение растягивается на всю ширину или вписывается в фиксированный фрейм (по умолчанию фрейм) */
|
81
80
|
isImageFullWidth?: boolean;
|
82
|
-
/**
|
83
|
-
badges?:
|
84
|
-
/** Дополнительный отступ снизу при использовании в баннере */
|
85
|
-
hasBottomOffset?: boolean;
|
81
|
+
/** Бейджи */
|
82
|
+
badges?: JSX.Element[] | JSX.Element;
|
86
83
|
/** Элемент блока с рекламой */
|
87
|
-
adBlock?: JSX.Element;
|
84
|
+
adBlock?: JSX.Element | null;
|
85
|
+
children?: React.ReactNode;
|
88
86
|
}
|
89
|
-
declare const ImageBanner: React.FC<
|
87
|
+
declare const ImageBanner: React.FC<IImageBannerProps>;
|
90
88
|
export default ImageBanner;
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports["default"] = exports.Radius = exports.NavTheme = exports.ImageVerticalAlign = exports.BackgroundColor = void 0;
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
9
10
|
require("core-js/modules/es.symbol.js");
|
10
11
|
require("core-js/modules/es.symbol.description.js");
|
11
12
|
require("core-js/modules/es.array.concat.js");
|
12
|
-
require("core-js/modules/es.array.map.js");
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
14
14
|
var _uiCore = require("@megafon/ui-core");
|
15
15
|
var _uiHelpers = require("@megafon/ui-helpers");
|
@@ -80,32 +80,41 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
80
80
|
title = _ref2.title,
|
81
81
|
description = _ref2.description,
|
82
82
|
cost = _ref2.cost,
|
83
|
+
_ref2$headerLevelMobi = _ref2.headerLevelMobile,
|
84
|
+
headerLevelMobile = _ref2$headerLevelMobi === void 0 ? 'h1' : _ref2$headerLevelMobi,
|
85
|
+
_ref2$headerLevel = _ref2.headerLevel,
|
86
|
+
headerLevel = _ref2$headerLevel === void 0 ? 'h1' : _ref2$headerLevel,
|
83
87
|
_ref2$backgroundColor = _ref2.backgroundColor,
|
84
88
|
backgroundColor = _ref2$backgroundColor === void 0 ? BackgroundColor.TRANSPARENT : _ref2$backgroundColor,
|
85
89
|
_ref2$radius = _ref2.radius,
|
86
90
|
radius = _ref2$radius === void 0 ? Radius.CORNERS : _ref2$radius,
|
87
91
|
autoHeight = _ref2.autoHeight,
|
88
92
|
isImageFullWidth = _ref2.isImageFullWidth,
|
89
|
-
|
90
|
-
badges = _ref2$badges === void 0 ? [] : _ref2$badges,
|
91
|
-
hasBottomOffset = _ref2.hasBottomOffset,
|
93
|
+
badges = _ref2.badges,
|
92
94
|
adBlock = _ref2.adBlock,
|
93
95
|
_ref2$children = _ref2.children,
|
94
96
|
children = _ref2$children === void 0 ? [] : _ref2$children;
|
97
|
+
var _React$useState = React.useState(false),
|
98
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
99
|
+
isMobile = _React$useState2[0],
|
100
|
+
setIsMobile = _React$useState2[1];
|
101
|
+
React.useEffect(function () {
|
102
|
+
var mediaQuery = window.matchMedia("(max-width: ".concat(_uiHelpers.breakpoints.MOBILE_MIDDLE_END, "px)"));
|
103
|
+
var handleMediaChange = function handleMediaChange(_ref3) {
|
104
|
+
var matches = _ref3.matches;
|
105
|
+
setIsMobile(matches);
|
106
|
+
};
|
107
|
+
setIsMobile(mediaQuery.matches);
|
108
|
+
mediaQuery.addEventListener('change', handleMediaChange);
|
109
|
+
return function () {
|
110
|
+
mediaQuery.removeEventListener('change', handleMediaChange);
|
111
|
+
};
|
112
|
+
}, []);
|
95
113
|
var navTheme = getTheme(backgroundColor);
|
96
114
|
var hasImage = !!(imageMobile || imageMobile2x || imageDesktop || imageDesktop2x);
|
97
|
-
var renderBadges = !!badges
|
115
|
+
var renderBadges = !!badges && /*#__PURE__*/React.createElement("div", {
|
98
116
|
className: cn('badges', [classes.badges])
|
99
|
-
}, badges
|
100
|
-
var text = _ref3.text,
|
101
|
-
iconType = _ref3.iconType;
|
102
|
-
return /*#__PURE__*/React.createElement(_uiCore.PriceBadge, {
|
103
|
-
className: classes.badge,
|
104
|
-
theme: navTheme,
|
105
|
-
iconType: iconType,
|
106
|
-
key: text
|
107
|
-
}, text);
|
108
|
-
}));
|
117
|
+
}, badges);
|
109
118
|
var renderAdBlock = !!adBlock && /*#__PURE__*/React.createElement("div", {
|
110
119
|
className: cn('ad-block', [classes.adBlock])
|
111
120
|
}, adBlock);
|
@@ -115,7 +124,8 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
115
124
|
className: cn('badges-container', [classes.badgesContainer])
|
116
125
|
}, renderBadges, renderAdBlock), !!title && /*#__PURE__*/React.createElement(_uiCore.Header, {
|
117
126
|
className: cn('title', [classes.title]),
|
118
|
-
color: "inherit"
|
127
|
+
color: "inherit",
|
128
|
+
as: isMobile ? headerLevelMobile : headerLevel
|
119
129
|
}, typeof title === 'string' ? (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig) : title), !!description && /*#__PURE__*/React.createElement(_uiCore.Header, {
|
120
130
|
className: cn('description', [classes.description]),
|
121
131
|
as: "h5",
|
@@ -123,17 +133,18 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
123
133
|
}, typeof description === 'string' ? (0, _uiHelpers.convert)(description, _uiHelpers.titleConvertConfig) : description), !!cost && /*#__PURE__*/React.createElement("div", {
|
124
134
|
className: cn('cost', [classes.cost])
|
125
135
|
}, (0, _uiHelpers.convert)(cost, typographyConfig)), !!children && !!React.Children.count(children) && /*#__PURE__*/React.createElement("div", {
|
126
|
-
className: cn('children')
|
136
|
+
className: cn('children', [classes.children])
|
127
137
|
}, children));
|
128
138
|
var renderImage = /*#__PURE__*/React.createElement("picture", {
|
129
139
|
className: cn('picture', {
|
130
140
|
'v-align': imageVerticalAlign
|
131
141
|
})
|
132
142
|
}, /*#__PURE__*/React.createElement("source", {
|
143
|
+
className: classes.imageSource,
|
133
144
|
media: "(min-width: ".concat(_uiHelpers.breakpoints.DESKTOP_SMALL_START, "px)"),
|
134
145
|
srcSet: "".concat(imageDesktop, ", ").concat(imageDesktop2x, " 2x")
|
135
146
|
}), /*#__PURE__*/React.createElement("img", (0, _extends2["default"])({}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.image), {
|
136
|
-
className: cn('
|
147
|
+
className: cn('image', [classes.image]),
|
137
148
|
src: imageMobile || imageMobile2x,
|
138
149
|
srcSet: imageMobile2x ? "".concat(imageMobile2x, " 2x") : undefined,
|
139
150
|
alt: imageAlt
|
@@ -145,12 +156,9 @@ var ImageBanner = function ImageBanner(_ref2) {
|
|
145
156
|
'has-image': hasImage,
|
146
157
|
'auto-height': autoHeight,
|
147
158
|
'full-width': isImageFullWidth,
|
148
|
-
'bottom-offset': hasBottomOffset && !hasImage,
|
149
159
|
radius: radius
|
150
160
|
}, [className, classes.root]),
|
151
161
|
ref: rootRef
|
152
|
-
}),
|
153
|
-
className: cn('wrapper')
|
154
|
-
}, renderContent, hasImage && renderImage));
|
162
|
+
}), renderContent, hasImage && renderImage);
|
155
163
|
};
|
156
164
|
var _default = exports["default"] = ImageBanner;
|