@gravity-ui/page-constructor 1.26.0 → 1.26.2-alpha.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 +41 -8
- package/README.md +7 -0
- package/build/cjs/blocks/Map/schema.d.ts +0 -12
- package/build/cjs/blocks/Share/Share.css +12 -11
- package/build/cjs/components/BlockHeader/BlockHeader.css +2 -2
- package/build/cjs/components/Button/Button.d.ts +1 -0
- package/build/cjs/components/Button/Button.js +1 -1
- package/build/cjs/components/Button/__tests__/Button.test.d.ts +1 -0
- package/build/cjs/components/Button/__tests__/Button.test.js +91 -0
- package/build/cjs/components/Button/utils.d.ts +1 -0
- package/build/cjs/components/Button/utils.js +2 -1
- package/build/cjs/components/ButtonTabs/ButtonTabs.css +6 -6
- package/build/cjs/components/HTML/HTML.d.ts +1 -1
- package/build/cjs/components/Map/GoogleMap.js +7 -5
- package/build/cjs/components/Map/Map.css +5 -0
- package/build/cjs/components/Map/YMap/YMap.d.ts +4 -2
- package/build/cjs/components/Map/YMap/YMap.js +18 -10
- package/build/cjs/components/Map/YMap/YandexMap.js +18 -9
- package/build/cjs/components/ReactPlayer/utils.js +13 -12
- package/build/cjs/components/Title/Title.css +20 -5
- package/build/cjs/components/Title/Title.d.ts +1 -1
- package/build/cjs/components/Title/Title.js +4 -2
- package/build/cjs/models/constructor-items/common.d.ts +5 -5
- package/build/cjs/navigation/components/Navigation/Navigation.js +7 -6
- package/build/cjs/schema/validators/common.d.ts +0 -6
- package/build/cjs/schema/validators/common.js +0 -4
- package/build/cjs/sub-blocks/BannerCard/BannerCard.css +2 -1
- package/build/cjs/sub-blocks/Content/Content.css +6 -0
- package/build/cjs/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/build/cjs/utils/blocks.d.ts +1 -1
- package/build/cjs/utils/blocks.js +2 -0
- package/build/esm/blocks/Map/schema.d.ts +0 -12
- package/build/esm/blocks/Share/Share.css +12 -11
- package/build/esm/components/BlockHeader/BlockHeader.css +2 -2
- package/build/esm/components/Button/Button.d.ts +1 -0
- package/build/esm/components/Button/Button.js +2 -2
- package/build/esm/components/Button/__tests__/Button.test.d.ts +1 -0
- package/build/esm/components/Button/__tests__/Button.test.js +88 -0
- package/build/esm/components/Button/utils.d.ts +1 -0
- package/build/esm/components/Button/utils.js +1 -0
- package/build/esm/components/ButtonTabs/ButtonTabs.css +6 -6
- package/build/esm/components/HTML/HTML.d.ts +1 -1
- package/build/esm/components/Map/GoogleMap.js +7 -5
- package/build/esm/components/Map/Map.css +5 -0
- package/build/esm/components/Map/YMap/YMap.d.ts +4 -2
- package/build/esm/components/Map/YMap/YMap.js +18 -10
- package/build/esm/components/Map/YMap/YandexMap.js +18 -9
- package/build/esm/components/ReactPlayer/utils.js +13 -12
- package/build/esm/components/Title/Title.css +20 -5
- package/build/esm/components/Title/Title.d.ts +1 -1
- package/build/esm/components/Title/Title.js +4 -2
- package/build/esm/models/constructor-items/common.d.ts +5 -5
- package/build/esm/navigation/components/Navigation/Navigation.js +7 -6
- package/build/esm/schema/validators/common.d.ts +0 -6
- package/build/esm/schema/validators/common.js +0 -4
- package/build/esm/sub-blocks/BannerCard/BannerCard.css +2 -1
- package/build/esm/sub-blocks/Content/Content.css +6 -0
- package/build/esm/sub-blocks/HubspotForm/HubspotForm.css +1 -0
- package/build/esm/utils/blocks.d.ts +1 -1
- package/build/esm/utils/blocks.js +2 -0
- package/package.json +7 -6
- package/server/models/constructor-items/common.d.ts +5 -5
- package/server/utils/blocks.d.ts +1 -1
- package/server/utils/blocks.js +2 -0
- package/styles/mixins.scss +9 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextSize, TitleProps } from '../../models';
|
|
2
|
-
export declare function getArrowSize(size: TextSize, isMobile: boolean): 16 | 20 | 24;
|
|
2
|
+
export declare function getArrowSize(size: TextSize, isMobile: boolean): 16 | 13 | 20 | 24 | 22 | 26 | 38;
|
|
3
3
|
export interface TitleFullProps extends TitleProps {
|
|
4
4
|
className?: string;
|
|
5
5
|
onClick?: () => void;
|
|
@@ -11,12 +11,14 @@ const mobileContext_1 = require("../../context/mobileContext");
|
|
|
11
11
|
const b = (0, utils_1.block)('title-block');
|
|
12
12
|
function getArrowSize(size, isMobile) {
|
|
13
13
|
switch (size) {
|
|
14
|
+
case 'xs':
|
|
15
|
+
return 13;
|
|
14
16
|
case 's':
|
|
15
17
|
return 16;
|
|
16
18
|
case 'm':
|
|
17
|
-
return isMobile ?
|
|
19
|
+
return isMobile ? 22 : 24;
|
|
18
20
|
case 'l':
|
|
19
|
-
return isMobile ?
|
|
21
|
+
return isMobile ? 26 : 38;
|
|
20
22
|
default:
|
|
21
23
|
return 20;
|
|
22
24
|
}
|
|
@@ -38,7 +38,7 @@ export declare enum MediaVideoControlsType {
|
|
|
38
38
|
Custom = "custom"
|
|
39
39
|
}
|
|
40
40
|
export type TextTheme = 'light' | 'dark';
|
|
41
|
-
export type TextSize = 's' | 'm' | 'l';
|
|
41
|
+
export type TextSize = 'xs' | 's' | 'm' | 'l';
|
|
42
42
|
export type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
|
|
43
43
|
export type HeaderWidth = 's' | 'm' | 'l';
|
|
44
44
|
export type HeaderImageSize = 's' | 'm';
|
|
@@ -130,20 +130,22 @@ export interface FileLinkProps extends ClassNameProps {
|
|
|
130
130
|
theme?: ContentTheme;
|
|
131
131
|
onClick?: () => void;
|
|
132
132
|
}
|
|
133
|
+
export type ButtonTheme = ButtonView | 'github' | 'app-store' | 'google-play' | 'scale' | 'monochrome';
|
|
133
134
|
export interface ButtonProps extends AnalyticsEventsBase {
|
|
134
135
|
text: string;
|
|
135
136
|
url: string;
|
|
136
137
|
primary?: boolean;
|
|
137
138
|
size?: ButtonSize;
|
|
138
|
-
theme?:
|
|
139
|
+
theme?: ButtonTheme;
|
|
139
140
|
img?: ButtonImageProps | string;
|
|
140
141
|
metrikaGoals?: MetrikaGoal;
|
|
141
142
|
pixelEvents?: ButtonPixel;
|
|
142
143
|
target?: string;
|
|
143
144
|
}
|
|
145
|
+
export type ButtonImagePosition = 'left' | 'right';
|
|
144
146
|
export interface ButtonImageProps {
|
|
145
147
|
url: string;
|
|
146
|
-
position?:
|
|
148
|
+
position?: ButtonImagePosition;
|
|
147
149
|
alt?: string;
|
|
148
150
|
}
|
|
149
151
|
export interface PlayButtonProps extends ClassNameProps {
|
|
@@ -189,7 +191,6 @@ export interface MediaProps extends Animatable, Partial<MediaComponentDataLensPr
|
|
|
189
191
|
export type Coordinate = number[];
|
|
190
192
|
export interface MapBaseProps {
|
|
191
193
|
zoom?: number;
|
|
192
|
-
center?: Coordinate;
|
|
193
194
|
}
|
|
194
195
|
export interface GMapProps extends MapBaseProps {
|
|
195
196
|
address: string;
|
|
@@ -197,7 +198,6 @@ export interface GMapProps extends MapBaseProps {
|
|
|
197
198
|
export interface YMapProps extends MapBaseProps {
|
|
198
199
|
markers: YMapMarker[];
|
|
199
200
|
id: string;
|
|
200
|
-
center: Coordinate;
|
|
201
201
|
}
|
|
202
202
|
export interface YMapMarker {
|
|
203
203
|
address?: string;
|
|
@@ -9,6 +9,7 @@ const locationContext_1 = require("../../../context/locationContext");
|
|
|
9
9
|
const constants_1 = require("../../constants");
|
|
10
10
|
const NavigationListItem_1 = require("../NavigationListItem/NavigationListItem");
|
|
11
11
|
const b = (0, utils_1.block)('navigation');
|
|
12
|
+
const EVENT_HANDLE_DELAY = 100;
|
|
12
13
|
const Navigation = ({ className, onActiveItemChange, links, activeItemId, highlightActiveItem, }) => {
|
|
13
14
|
const { asPath, pathname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
14
15
|
const itemRefs = (0, react_1.useRef)([]);
|
|
@@ -24,21 +25,21 @@ const Navigation = ({ className, onActiveItemChange, links, activeItemId, highli
|
|
|
24
25
|
}
|
|
25
26
|
}, []);
|
|
26
27
|
(0, react_1.useEffect)(() => {
|
|
27
|
-
const debouncedCalculateItemPositions = lodash_1.default.debounce(calculateItemPositions,
|
|
28
|
-
const
|
|
28
|
+
const debouncedCalculateItemPositions = lodash_1.default.debounce(calculateItemPositions, EVENT_HANDLE_DELAY);
|
|
29
|
+
const debouncedCalculateOnScroll = lodash_1.default.debounce(() => {
|
|
29
30
|
const curLeftScroll = window.pageXOffset;
|
|
30
31
|
if (curLeftScroll !== lastLeftScroll) {
|
|
31
32
|
setLastLeftScroll(window.pageXOffset);
|
|
32
33
|
calculateItemPositions();
|
|
33
34
|
}
|
|
34
|
-
},
|
|
35
|
+
}, EVENT_HANDLE_DELAY);
|
|
35
36
|
calculateItemPositions();
|
|
36
37
|
setLastLeftScroll(window.pageXOffset);
|
|
37
38
|
window.addEventListener('resize', debouncedCalculateItemPositions);
|
|
38
|
-
window.addEventListener('scroll',
|
|
39
|
+
window.addEventListener('scroll', debouncedCalculateOnScroll);
|
|
39
40
|
return () => {
|
|
40
|
-
window.removeEventListener(`resize`,
|
|
41
|
-
window.removeEventListener('scroll',
|
|
41
|
+
window.removeEventListener(`resize`, debouncedCalculateItemPositions);
|
|
42
|
+
window.removeEventListener('scroll', debouncedCalculateOnScroll);
|
|
42
43
|
};
|
|
43
44
|
}, [calculateItemPositions, itemRefs, lastLeftScroll]);
|
|
44
45
|
(0, react_1.useEffect)(() => {
|
|
@@ -70,9 +70,10 @@ unpredictable css rules order in build */
|
|
|
70
70
|
font-weight: var(--yc-text-accent-font-weight);
|
|
71
71
|
font-weight: normal;
|
|
72
72
|
}
|
|
73
|
-
.pc-banner-card__button {
|
|
73
|
+
.pc-banner-card__button.pc-banner-card__button {
|
|
74
74
|
margin-top: 28px;
|
|
75
75
|
}
|
|
76
|
+
|
|
76
77
|
.pc-banner-card__image {
|
|
77
78
|
border-top-right-radius: var(--pc-border-radius);
|
|
78
79
|
border-bottom-right-radius: var(--pc-border-radius);
|
|
@@ -31,6 +31,9 @@ unpredictable css rules order in build */
|
|
|
31
31
|
margin-top: 0;
|
|
32
32
|
margin-right: 12px;
|
|
33
33
|
}
|
|
34
|
+
.pc-content__button.pc-content__button:last-child {
|
|
35
|
+
margin-right: 0;
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
.pc-content__links {
|
|
36
39
|
display: flex;
|
|
@@ -41,6 +44,9 @@ unpredictable css rules order in build */
|
|
|
41
44
|
display: block;
|
|
42
45
|
margin-right: 32px;
|
|
43
46
|
}
|
|
47
|
+
.pc-content__link:last-child {
|
|
48
|
+
margin-right: 0;
|
|
49
|
+
}
|
|
44
50
|
.pc-content_centered.pc-content_centered {
|
|
45
51
|
margin: 0 auto;
|
|
46
52
|
text-align: center;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConstructorBlock } from '../models/constructor';
|
|
2
2
|
import { TextSize, CustomConfig, PCShareSocialNetwork } from '../models';
|
|
3
|
-
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4";
|
|
3
|
+
export declare function getHeaderTag(size: TextSize): "h1" | "h2" | "h4" | "h5";
|
|
4
4
|
export declare function getBlockKey(block: ConstructorBlock, index: number): string;
|
|
5
5
|
export declare const getCustomBlockTypes: ({ blocks, headers }?: CustomConfig) => string[];
|
|
6
6
|
export declare const getCustomItems: ({ blocks, headers, subBlocks }?: CustomConfig) => {
|
|
@@ -6,12 +6,6 @@ export declare const Map: {
|
|
|
6
6
|
zoom: {
|
|
7
7
|
type: string;
|
|
8
8
|
};
|
|
9
|
-
center: {
|
|
10
|
-
type: string;
|
|
11
|
-
items: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
9
|
address: {
|
|
16
10
|
type: string;
|
|
17
11
|
};
|
|
@@ -70,12 +64,6 @@ export declare const MapBlock: {
|
|
|
70
64
|
zoom: {
|
|
71
65
|
type: string;
|
|
72
66
|
};
|
|
73
|
-
center: {
|
|
74
|
-
type: string;
|
|
75
|
-
items: {
|
|
76
|
-
type: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
67
|
address: {
|
|
80
68
|
type: string;
|
|
81
69
|
};
|
|
@@ -17,46 +17,47 @@ unpredictable css rules order in build */
|
|
|
17
17
|
justify-content: center;
|
|
18
18
|
margin-top: 16px;
|
|
19
19
|
}
|
|
20
|
-
.pc-share-block__item {
|
|
20
|
+
.pc-share-block__item.pc-share-block__item {
|
|
21
21
|
display: flex;
|
|
22
22
|
justify-content: center;
|
|
23
23
|
width: 48px;
|
|
24
24
|
height: 48px;
|
|
25
25
|
border-radius: 100%;
|
|
26
26
|
}
|
|
27
|
-
.pc-share-block__item_type_vk {
|
|
27
|
+
.pc-share-block__item.pc-share-block__item_type_vk {
|
|
28
28
|
background-color: var(--yc-color-vk);
|
|
29
29
|
}
|
|
30
|
-
.pc-share-block__item_type_facebook {
|
|
30
|
+
.pc-share-block__item.pc-share-block__item_type_facebook {
|
|
31
31
|
background-color: var(--yc-color-facebook);
|
|
32
32
|
}
|
|
33
|
-
.pc-share-block__item_type_twitter {
|
|
33
|
+
.pc-share-block__item.pc-share-block__item_type_twitter {
|
|
34
34
|
background-color: var(--yc-color-twitter);
|
|
35
35
|
}
|
|
36
|
-
.pc-share-block__item_type_telegram {
|
|
36
|
+
.pc-share-block__item.pc-share-block__item_type_telegram {
|
|
37
37
|
background-color: var(--yc-color-telegram);
|
|
38
38
|
}
|
|
39
|
-
.pc-share-block__item_type_telegram {
|
|
39
|
+
.pc-share-block__item.pc-share-block__item_type_telegram {
|
|
40
40
|
background-color: var(--yc-color-telegram);
|
|
41
41
|
}
|
|
42
|
-
.pc-share-block__item_type_linkedin {
|
|
42
|
+
.pc-share-block__item.pc-share-block__item_type_linkedin {
|
|
43
43
|
background-color: var(--yc-color-linkedin);
|
|
44
44
|
}
|
|
45
|
-
.pc-share-block__item.pc-share-block__item:before {
|
|
45
|
+
.pc-share-block__item.pc-share-block__item.pc-share-block__item.pc-share-block__item:before {
|
|
46
46
|
border-radius: 100%;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.pc-share-block__item:hover:before {
|
|
49
|
+
.pc-share-block__item.pc-share-block__item:hover:before {
|
|
50
50
|
/* stylelint-disable-next-line declaration-no-important */
|
|
51
51
|
background-color: var(--yc-color-base-generic) !important;
|
|
52
52
|
border-radius: 100%;
|
|
53
53
|
}
|
|
54
|
-
.pc-share-block__item + .pc-share-block__item {
|
|
54
|
+
.pc-share-block__item.pc-share-block__item + .pc-share-block__item.pc-share-block__item {
|
|
55
55
|
margin-left: 12px;
|
|
56
56
|
}
|
|
57
|
-
.pc-share-block__item svg {
|
|
57
|
+
.pc-share-block__item.pc-share-block__item svg {
|
|
58
58
|
color: var(--yc-color-base-background);
|
|
59
59
|
}
|
|
60
|
+
|
|
60
61
|
@media (max-width: 577px) {
|
|
61
62
|
.pc-share-block__items {
|
|
62
63
|
flex-wrap: wrap;
|
|
@@ -7,10 +7,10 @@ unpredictable css rules order in build */
|
|
|
7
7
|
font-size: var(--yc-text-body-3-font-size);
|
|
8
8
|
line-height: var(--yc-text-body-3-line-height);
|
|
9
9
|
}
|
|
10
|
-
.pc-block-header__description_titleSize_s {
|
|
10
|
+
.pc-block-header__description_titleSize_s, .pc-block-header__description_titleSize_xs {
|
|
11
11
|
margin-top: 8px;
|
|
12
12
|
}
|
|
13
|
-
.pc-block-header__description_titleSize_s .yfm {
|
|
13
|
+
.pc-block-header__description_titleSize_s .yfm, .pc-block-header__description_titleSize_xs .yfm {
|
|
14
14
|
font-size: var(--yc-text-body-2-font-size);
|
|
15
15
|
line-height: var(--yc-text-body-2-line-height);
|
|
16
16
|
}
|
|
@@ -3,7 +3,7 @@ import React, { useCallback, useContext } from 'react';
|
|
|
3
3
|
import { Platform, Button as CommonButton, Icon, StoreBadge } from '@gravity-ui/uikit';
|
|
4
4
|
import { block, setUrlTld } from '../../utils';
|
|
5
5
|
import { DefaultEventNames } from '../../models';
|
|
6
|
-
import { toCommonSize, toCommonView } from './utils';
|
|
6
|
+
import { toCommonSize, toCommonView, ICON_QA } from './utils';
|
|
7
7
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
8
8
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
9
9
|
import { useAnalytics } from '../../hooks';
|
|
@@ -37,7 +37,7 @@ const Button = (props) => {
|
|
|
37
37
|
let icon;
|
|
38
38
|
let image = img && React.createElement("img", { className: b('image'), src: buttonImg.url, alt: buttonImg.alt });
|
|
39
39
|
if (theme === 'github') {
|
|
40
|
-
icon = React.createElement(Icon, { className: b('icon'), data: Github, size: 24 });
|
|
40
|
+
icon = React.createElement(Icon, { className: b('icon'), data: Github, size: 24, qa: ICON_QA });
|
|
41
41
|
image = undefined;
|
|
42
42
|
}
|
|
43
43
|
const buttonTheme = theme === 'scale' ? 'accent' : theme;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { ICON_QA } from '../utils';
|
|
5
|
+
import Button from '../Button';
|
|
6
|
+
const qaId = 'button-component';
|
|
7
|
+
const buttonProps = {
|
|
8
|
+
text: 'Button Text',
|
|
9
|
+
url: 'https://github.com/gravity-ui/',
|
|
10
|
+
target: '_blank',
|
|
11
|
+
img: {
|
|
12
|
+
url: 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_light.svg',
|
|
13
|
+
position: 'left',
|
|
14
|
+
alt: 'alt-text',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const buttonViews = [
|
|
18
|
+
'normal',
|
|
19
|
+
'action',
|
|
20
|
+
'outlined',
|
|
21
|
+
'outlined-info',
|
|
22
|
+
'outlined-danger',
|
|
23
|
+
'raised',
|
|
24
|
+
'flat',
|
|
25
|
+
'flat-info',
|
|
26
|
+
'flat-danger',
|
|
27
|
+
'flat-secondary',
|
|
28
|
+
'normal-contrast',
|
|
29
|
+
'outlined-contrast',
|
|
30
|
+
'flat-contrast',
|
|
31
|
+
'github',
|
|
32
|
+
'scale',
|
|
33
|
+
'monochrome',
|
|
34
|
+
];
|
|
35
|
+
describe('Button', () => {
|
|
36
|
+
test('render button by default', async () => {
|
|
37
|
+
render(React.createElement(Button, { text: buttonProps.text }));
|
|
38
|
+
const button = screen.getByRole('button');
|
|
39
|
+
expect(button).toBeInTheDocument();
|
|
40
|
+
expect(button).toBeVisible();
|
|
41
|
+
expect(button).not.toBeDisabled();
|
|
42
|
+
});
|
|
43
|
+
test('should render <a /> tag', async () => {
|
|
44
|
+
render(React.createElement(Button, { text: buttonProps.text, url: buttonProps.url, target: buttonProps.target }));
|
|
45
|
+
const button = screen.getByRole('link');
|
|
46
|
+
expect(button).toBeVisible();
|
|
47
|
+
expect(button).toHaveAttribute('href', buttonProps.url);
|
|
48
|
+
expect(button).toHaveAttribute('target', buttonProps.target);
|
|
49
|
+
});
|
|
50
|
+
test('call onClick', async () => {
|
|
51
|
+
const user = userEvent.setup();
|
|
52
|
+
const handleOnClick = jest.fn();
|
|
53
|
+
render(React.createElement(Button, { text: buttonProps.text, onClick: handleOnClick }));
|
|
54
|
+
const button = screen.getByRole('button');
|
|
55
|
+
await user.click(button);
|
|
56
|
+
expect(handleOnClick).toHaveBeenCalledTimes(1);
|
|
57
|
+
});
|
|
58
|
+
test.each(new Array('s', 'm', 'l', 'xl'))('render with given "%s" size', (size) => {
|
|
59
|
+
render(React.createElement(Button, { text: buttonProps.text, size: size, qa: qaId }));
|
|
60
|
+
const button = screen.getByTestId(qaId);
|
|
61
|
+
expect(button).toHaveClass(`pc-button-block_size_${size}`);
|
|
62
|
+
});
|
|
63
|
+
test.each(new Array(...buttonViews))('render with given "%s" view', (theme) => {
|
|
64
|
+
render(React.createElement(Button, { text: buttonProps.text, theme: theme, qa: qaId }));
|
|
65
|
+
const button = screen.getByTestId(qaId);
|
|
66
|
+
expect(button).toHaveClass(`pc-button-block_theme_${theme}`);
|
|
67
|
+
});
|
|
68
|
+
test('add className', () => {
|
|
69
|
+
const className = 'my-class';
|
|
70
|
+
render(React.createElement(Button, { text: buttonProps.text, className: className, qa: qaId }));
|
|
71
|
+
const button = screen.getByTestId(qaId);
|
|
72
|
+
expect(button).toHaveClass(className);
|
|
73
|
+
});
|
|
74
|
+
test('should render icon', () => {
|
|
75
|
+
render(React.createElement(Button, { text: buttonProps.text, img: buttonProps.img }));
|
|
76
|
+
const button = screen.getByRole('button');
|
|
77
|
+
const iconComponent = screen.getByRole('img');
|
|
78
|
+
expect(iconComponent).toBeVisible();
|
|
79
|
+
expect(button).toContainElement(iconComponent);
|
|
80
|
+
});
|
|
81
|
+
test('should render github icon', () => {
|
|
82
|
+
render(React.createElement(Button, { text: buttonProps.text, img: buttonProps.img, theme: "github" }));
|
|
83
|
+
const button = screen.getByRole('button');
|
|
84
|
+
const iconComponent = screen.getByTestId(ICON_QA);
|
|
85
|
+
expect(iconComponent).toBeVisible();
|
|
86
|
+
expect(button).toContainElement(iconComponent);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ButtonSize, ButtonView } from '@gravity-ui/uikit';
|
|
2
|
+
export declare const ICON_QA = "button-icon";
|
|
2
3
|
export type OldButtonTheme = 'normal' | 'action' | 'flat' | 'light' | 'clear' | 'raised' | 'pseudo' | 'link' | 'accent' | 'websearch' | 'flat-special' | 'normal-special' | 'normal-dark' | 'pseudo-special';
|
|
3
4
|
export type OldButtonSize = 'xs' | 'ns' | 's' | 'm' | 'l' | 'n' | 'head' | 'promo';
|
|
4
5
|
export declare const toCommonView: (theme: OldButtonTheme) => ButtonView;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/* use this for style redefinitions to awoid problems with
|
|
2
2
|
unpredictable css rules order in build */
|
|
3
|
-
.pc-button-tabs__item {
|
|
3
|
+
.pc-button-tabs__item.pc-button-tabs__item {
|
|
4
4
|
margin-right: 8px;
|
|
5
5
|
margin-bottom: 12px;
|
|
6
6
|
--yc-button-background-color: var(--pc-tab-item-background-color);
|
|
7
7
|
--yc-button-background-color-hover: var(--pc-tab-item-background-color-hover);
|
|
8
8
|
}
|
|
9
|
-
.pc-button-tabs__item, .pc-button-tabs__item:link, .pc-button-tabs__item:visited, .pc-button-tabs__item:active, .pc-button-tabs__item:focus {
|
|
9
|
+
.pc-button-tabs__item.pc-button-tabs__item, .pc-button-tabs__item.pc-button-tabs__item:link, .pc-button-tabs__item.pc-button-tabs__item:visited, .pc-button-tabs__item.pc-button-tabs__item:active, .pc-button-tabs__item.pc-button-tabs__item:focus {
|
|
10
10
|
color: var(--pc-tab-item-color);
|
|
11
11
|
}
|
|
12
|
-
.pc-button-tabs__item:hover {
|
|
12
|
+
.pc-button-tabs__item.pc-button-tabs__item:hover {
|
|
13
13
|
color: var(--pc-tab-item-color);
|
|
14
14
|
}
|
|
15
|
-
.pc-button-tabs__item_active {
|
|
15
|
+
.pc-button-tabs__item.pc-button-tabs__item_active {
|
|
16
16
|
pointer-events: none;
|
|
17
17
|
--yc-button-background-color: var(--pc-selected-tab-item-background-color);
|
|
18
18
|
--yc-button-background-color-hover: var(--pc-selected-tab-item-background-color-hover);
|
|
19
19
|
}
|
|
20
|
-
.pc-button-tabs__item_active, .pc-button-tabs__item_active:link, .pc-button-tabs__item_active:visited, .pc-button-tabs__item_active:active, .pc-button-tabs__item_active:focus {
|
|
20
|
+
.pc-button-tabs__item.pc-button-tabs__item_active, .pc-button-tabs__item.pc-button-tabs__item_active:link, .pc-button-tabs__item.pc-button-tabs__item_active:visited, .pc-button-tabs__item.pc-button-tabs__item_active:active, .pc-button-tabs__item.pc-button-tabs__item_active:focus {
|
|
21
21
|
color: var(--pc-selected-tab-item-color);
|
|
22
22
|
}
|
|
23
|
-
.pc-button-tabs__item_active:hover {
|
|
23
|
+
.pc-button-tabs__item.pc-button-tabs__item_active:hover {
|
|
24
24
|
color: var(--pc-selected-tab-item-color);
|
|
25
25
|
}
|
|
@@ -7,7 +7,7 @@ export interface HTMLProps {
|
|
|
7
7
|
}
|
|
8
8
|
declare const HTML: ({ children, block, className }: WithChildren<HTMLProps>) => React.DetailedReactHTMLElement<{
|
|
9
9
|
dangerouslySetInnerHTML: {
|
|
10
|
-
__html: string
|
|
10
|
+
__html: string | (string & React.ReactElement<any, string | React.JSXElementConstructor<any>>) | (string & React.ReactFragment) | (string & React.ReactPortal);
|
|
11
11
|
};
|
|
12
12
|
className: string | undefined;
|
|
13
13
|
}, HTMLElement> | null;
|
|
@@ -5,18 +5,20 @@ import { MapsContext } from '../../context/mapsContext/mapsContext';
|
|
|
5
5
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
6
6
|
import { MobileContext } from '../../context/mobileContext';
|
|
7
7
|
import { getMapHeight } from './helpers';
|
|
8
|
+
import { Lang } from '../../utils/configure';
|
|
8
9
|
const b = block('map');
|
|
9
|
-
function getScriptSrc(
|
|
10
|
-
|
|
10
|
+
function getScriptSrc(params) {
|
|
11
|
+
const { apiKey, scriptSrc, address, lang, zoom } = params;
|
|
12
|
+
return `${scriptSrc}?key=${apiKey}&language=${lang}${zoom ? '&zoom=' + zoom : ''}&q=${encodeURI(address)}`;
|
|
11
13
|
}
|
|
12
14
|
const GoogleMap = (props) => {
|
|
13
|
-
const { address } = props;
|
|
15
|
+
const { address, zoom } = props;
|
|
14
16
|
const { apiKey, scriptSrc } = useContext(MapsContext);
|
|
15
|
-
const { lang =
|
|
17
|
+
const { lang = Lang.Ru } = useContext(LocaleContext);
|
|
16
18
|
const isMobile = useContext(MobileContext);
|
|
17
19
|
const [height, setHeight] = useState(undefined);
|
|
18
20
|
const ref = useRef(null);
|
|
19
|
-
const src = useMemo(() => getScriptSrc(apiKey, scriptSrc, address, lang), [apiKey, scriptSrc, address, lang]);
|
|
21
|
+
const src = useMemo(() => getScriptSrc({ apiKey, scriptSrc, address, lang, zoom }), [apiKey, scriptSrc, address, lang, zoom]);
|
|
20
22
|
useEffect(() => {
|
|
21
23
|
const updateSize = _.debounce(() => {
|
|
22
24
|
if (ref.current) {
|
|
@@ -7,9 +7,13 @@ unpredictable css rules order in build */
|
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
display: flex;
|
|
9
9
|
}
|
|
10
|
+
.pc-map_hidden {
|
|
11
|
+
opacity: 0;
|
|
12
|
+
}
|
|
10
13
|
.pc-map__spinner {
|
|
11
14
|
margin: 0 auto;
|
|
12
15
|
align-self: center;
|
|
16
|
+
position: absolute;
|
|
13
17
|
}
|
|
14
18
|
.pc-map__wrapper {
|
|
15
19
|
min-height: 300px;
|
|
@@ -17,4 +21,5 @@ unpredictable css rules order in build */
|
|
|
17
21
|
flex-direction: column;
|
|
18
22
|
align-items: center;
|
|
19
23
|
justify-content: center;
|
|
24
|
+
position: relative;
|
|
20
25
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { YMapMarker } from '../../../models';
|
|
1
|
+
import { YMapProps, YMapMarker } from '../../../models';
|
|
2
|
+
type PlacemarksProps = Pick<YMapProps, 'zoom' | 'markers'>;
|
|
2
3
|
export declare class YMap {
|
|
3
4
|
private ymap;
|
|
4
5
|
private mapRef;
|
|
5
6
|
private coords;
|
|
6
7
|
constructor(ymap: Ymaps.Map, mapRef: HTMLDivElement | null);
|
|
7
|
-
showPlacemarks(
|
|
8
|
+
showPlacemarks(props: PlacemarksProps): Promise<void>;
|
|
8
9
|
findAddress(marker: YMapMarker): Promise<void>;
|
|
9
10
|
findCoordinate(marker: YMapMarker): void;
|
|
10
11
|
private drawPlaceMarkStyle;
|
|
11
12
|
private recalcZoomAndCenter;
|
|
12
13
|
private clearOldPlacemarks;
|
|
13
14
|
}
|
|
15
|
+
export {};
|
|
@@ -19,9 +19,9 @@ export class YMap {
|
|
|
19
19
|
this.ymap = ymap;
|
|
20
20
|
this.mapRef = mapRef;
|
|
21
21
|
}
|
|
22
|
-
async showPlacemarks(
|
|
22
|
+
async showPlacemarks(props) {
|
|
23
23
|
this.clearOldPlacemarks();
|
|
24
|
-
for (const marker of markers) {
|
|
24
|
+
for (const marker of props.markers) {
|
|
25
25
|
if (marker.address) {
|
|
26
26
|
await this.findAddress(marker);
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ export class YMap {
|
|
|
29
29
|
this.findCoordinate(marker);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
this.recalcZoomAndCenter();
|
|
32
|
+
this.recalcZoomAndCenter(props);
|
|
33
33
|
}
|
|
34
34
|
async findAddress(marker) {
|
|
35
35
|
try {
|
|
@@ -49,10 +49,7 @@ export class YMap {
|
|
|
49
49
|
this.ymap.geoObjects.add(geoObject);
|
|
50
50
|
}
|
|
51
51
|
drawPlaceMarkStyle(geoObject, marker) {
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const { iconColor, preset = DEFAULT_PLACEMARKS_PRESET } = marker.label;
|
|
52
|
+
const { iconColor, preset = DEFAULT_PLACEMARKS_PRESET } = marker.label || {};
|
|
56
53
|
let localIconColor = iconColor;
|
|
57
54
|
// You can set the preset option together with the iconColor option only if it not a 'Stretchy' preset
|
|
58
55
|
if (!preset.includes('Stretchy') && !iconColor) {
|
|
@@ -65,9 +62,10 @@ export class YMap {
|
|
|
65
62
|
}
|
|
66
63
|
});
|
|
67
64
|
}
|
|
68
|
-
recalcZoomAndCenter() {
|
|
65
|
+
recalcZoomAndCenter(props) {
|
|
69
66
|
var _a, _b;
|
|
70
67
|
const coordsLength = this.coords.length;
|
|
68
|
+
const { zoom = 0 } = props;
|
|
71
69
|
if (!coordsLength) {
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
@@ -76,10 +74,20 @@ export class YMap {
|
|
|
76
74
|
leftBottom = [Math.min(leftBottom[0], point[0]), Math.min(leftBottom[1], point[1])];
|
|
77
75
|
rightTop = [Math.max(rightTop[0], point[0]), Math.max(rightTop[1], point[1])];
|
|
78
76
|
});
|
|
79
|
-
|
|
77
|
+
let newMapParams = {
|
|
78
|
+
zoom,
|
|
79
|
+
center: [],
|
|
80
|
+
};
|
|
81
|
+
if (zoom) {
|
|
82
|
+
// compute only the center
|
|
83
|
+
newMapParams.center = window.ymaps.util.bounds.getCenter([leftBottom, rightTop]);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
newMapParams = window.ymaps.util.bounds.getCenterAndZoom([leftBottom, rightTop], [(_a = this.mapRef) === null || _a === void 0 ? void 0 : _a.clientWidth, (_b = this.mapRef) === null || _b === void 0 ? void 0 : _b.clientHeight], undefined, { margin: DEFAULT_MAP_CONTROL_BUTTON_HEIGHT });
|
|
87
|
+
}
|
|
80
88
|
this.ymap.setCenter(newMapParams.center);
|
|
81
89
|
// Use default zoom for one placemark
|
|
82
|
-
if (coordsLength > 1) {
|
|
90
|
+
if (coordsLength > 1 && !zoom) {
|
|
83
91
|
this.ymap.setZoom(newMapParams.zoom);
|
|
84
92
|
}
|
|
85
93
|
}
|