@gravity-ui/page-constructor 1.16.3 → 1.17.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 +20 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/cjs/components/BackLink/__tests__/BackLink.test.js +63 -0
- package/build/cjs/components/OverflowScroller/OverflowScroller.css +16 -5
- package/build/cjs/components/OverflowScroller/OverflowScroller.d.ts +1 -1
- package/build/cjs/components/OverflowScroller/OverflowScroller.js +13 -5
- package/build/cjs/models/constructor-items/sub-blocks.d.ts +1 -0
- package/build/cjs/models/navigation.d.ts +9 -3
- package/build/cjs/models/navigation.js +1 -0
- package/build/cjs/navigation/components/Header/Header.css +2 -2
- package/build/cjs/navigation/components/Header/Header.js +1 -1
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.css +0 -35
- package/build/cjs/navigation/components/NavigationItem/NavigationItem.js +9 -39
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.css +7 -0
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js +12 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +10 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +5 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +11 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.css +3 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +15 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.css +4 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +19 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.css +21 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +6 -0
- package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +30 -0
- package/build/cjs/sub-blocks/BasicCard/BasicCard.js +2 -2
- package/build/cjs/sub-blocks/BasicCard/schema.d.ts +4 -0
- package/build/cjs/sub-blocks/BasicCard/schema.js +4 -1
- package/build/cjs/utils/url.d.ts +1 -0
- package/build/cjs/utils/url.js +13 -10
- package/build/cjs/utils/url.test.d.ts +1 -0
- package/build/cjs/utils/url.test.js +76 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.d.ts +1 -0
- package/build/esm/components/BackLink/__tests__/BackLink.test.js +60 -0
- package/build/esm/components/OverflowScroller/OverflowScroller.css +16 -5
- package/build/esm/components/OverflowScroller/OverflowScroller.d.ts +1 -1
- package/build/esm/components/OverflowScroller/OverflowScroller.js +13 -5
- package/build/esm/models/constructor-items/sub-blocks.d.ts +1 -0
- package/build/esm/models/navigation.d.ts +9 -3
- package/build/esm/models/navigation.js +1 -0
- package/build/esm/navigation/components/Header/Header.css +2 -2
- package/build/esm/navigation/components/Header/Header.js +1 -1
- package/build/esm/navigation/components/NavigationItem/NavigationItem.css +0 -35
- package/build/esm/navigation/components/NavigationItem/NavigationItem.js +9 -39
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.css +7 -0
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js +8 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.css +10 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts +6 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubStars/GithubStars.js +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.css +3 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.js +11 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.css +4 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +16 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.css +21 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts +7 -0
- package/build/esm/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js +27 -0
- package/build/esm/sub-blocks/BasicCard/BasicCard.js +3 -2
- package/build/esm/sub-blocks/BasicCard/schema.d.ts +4 -0
- package/build/esm/sub-blocks/BasicCard/schema.js +4 -1
- package/build/esm/utils/url.d.ts +1 -0
- package/build/esm/utils/url.js +11 -9
- package/build/esm/utils/url.test.d.ts +1 -0
- package/build/esm/utils/url.test.js +74 -0
- package/package.json +2 -1
- package/server/models/constructor-items/sub-blocks.d.ts +1 -0
- package/server/models/navigation.d.ts +9 -3
- package/server/models/navigation.js +1 -0
- package/server/utils/url.d.ts +1 -0
- package/server/utils/url.js +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.17.0](https://github.com/gravity-ui/page-constructor/compare/v1.16.4...v1.17.0) (2023-02-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **Navigation:** add github star button in navigation ([#159](https://github.com/gravity-ui/page-constructor/issues/159)) ([829d358](https://github.com/gravity-ui/page-constructor/commit/829d3582772378940993c4f676fe08676693266a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove background from Overlowscroller ([#153](https://github.com/gravity-ui/page-constructor/issues/153)) ([652adfa](https://github.com/gravity-ui/page-constructor/commit/652adfaf92156e1f96a9292d034c5139aac7894c))
|
|
14
|
+
|
|
15
|
+
## [1.16.4](https://github.com/gravity-ui/page-constructor/compare/v1.16.3...v1.16.4) (2023-02-22)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **BasicCard:** add target ([#162](https://github.com/gravity-ui/page-constructor/issues/162)) ([569038c](https://github.com/gravity-ui/page-constructor/commit/569038c8ef1c43b7c8b9d6462126997155605b4c))
|
|
21
|
+
* do not set "rel: 'noopener noreferrer'" for local links ([#160](https://github.com/gravity-ui/page-constructor/issues/160)) ([81173a7](https://github.com/gravity-ui/page-constructor/commit/81173a7e237104463971a80e386f5bad37caa551))
|
|
22
|
+
|
|
3
23
|
## [1.16.3](https://github.com/gravity-ui/page-constructor/compare/v1.16.2...v1.16.3) (2023-02-17)
|
|
4
24
|
|
|
5
25
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const react_2 = require("@testing-library/react");
|
|
6
|
+
const user_event_1 = tslib_1.__importDefault(require("@testing-library/user-event"));
|
|
7
|
+
const BackLink_1 = tslib_1.__importDefault(require("../BackLink"));
|
|
8
|
+
const locationContext_1 = require("../../../context/locationContext");
|
|
9
|
+
const backLinkProps = {
|
|
10
|
+
url: '#',
|
|
11
|
+
title: 'Button Title',
|
|
12
|
+
theme: 'default',
|
|
13
|
+
size: 's',
|
|
14
|
+
className: 'customClassName',
|
|
15
|
+
shouldHandleBackAction: true,
|
|
16
|
+
onClick: () => { },
|
|
17
|
+
};
|
|
18
|
+
describe('BackLink', () => {
|
|
19
|
+
test('Default render', async () => {
|
|
20
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
21
|
+
const backLink = react_2.screen.getByRole('button');
|
|
22
|
+
expect(backLink).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
test('Has custom class', async () => {
|
|
25
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
26
|
+
const backLink = react_2.screen.getByRole('button');
|
|
27
|
+
expect(backLink).toHaveClass(backLinkProps.className);
|
|
28
|
+
});
|
|
29
|
+
test('Should render <a /> tag', async () => {
|
|
30
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { shouldHandleBackAction: false })));
|
|
31
|
+
const backLink = react_2.screen.getByRole('link');
|
|
32
|
+
expect(backLink).toBeVisible();
|
|
33
|
+
expect(backLink).toHaveAttribute('href', backLinkProps.url);
|
|
34
|
+
});
|
|
35
|
+
test('Should render title', async () => {
|
|
36
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps)));
|
|
37
|
+
const backLink = react_2.screen.getByText(backLinkProps.title);
|
|
38
|
+
expect(backLink).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
test('Call onClick', async () => {
|
|
41
|
+
const user = user_event_1.default.setup();
|
|
42
|
+
const handleClick = jest.fn();
|
|
43
|
+
(0, react_2.render)(react_1.default.createElement(locationContext_1.LocationContext.Provider, { value: { history: { push: jest.fn() } } },
|
|
44
|
+
react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { onClick: handleClick }))));
|
|
45
|
+
const backLink = react_2.screen.getByRole('button');
|
|
46
|
+
await user.click(backLink);
|
|
47
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
48
|
+
});
|
|
49
|
+
test.each(new Array('s', 'm', 'l', 'xl'))('Render with given "%s" size', (size) => {
|
|
50
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { size: size })));
|
|
51
|
+
const backLink = react_2.screen.getByRole('button');
|
|
52
|
+
expect(backLink).toHaveClass(`yc-button_size_${size}`);
|
|
53
|
+
});
|
|
54
|
+
test.each(new Array('default', 'special'))('Render with given "%s" theme', (theme) => {
|
|
55
|
+
const matchView = {
|
|
56
|
+
default: 'flat-secondary',
|
|
57
|
+
special: 'flat-contrast',
|
|
58
|
+
};
|
|
59
|
+
(0, react_2.render)(react_1.default.createElement(BackLink_1.default, Object.assign({}, backLinkProps, { theme: theme })));
|
|
60
|
+
const backLink = react_2.screen.getByRole('button');
|
|
61
|
+
expect(backLink).toHaveClass(`yc-button_view_${matchView[theme]}`);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
.pc-overflow-scroller {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
2
4
|
position: relative;
|
|
3
5
|
overflow-x: hidden;
|
|
4
6
|
}
|
|
7
|
+
.pc-overflow-scroller__container {
|
|
8
|
+
width: 100%;
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
.pc-overflow-scroller__container_padding-left {
|
|
12
|
+
padding-left: 24px;
|
|
13
|
+
}
|
|
14
|
+
.pc-overflow-scroller__container_padding-right {
|
|
15
|
+
padding-right: 24px;
|
|
16
|
+
}
|
|
5
17
|
.pc-overflow-scroller__wrapper {
|
|
6
18
|
position: relative;
|
|
7
|
-
transition: left 0.
|
|
19
|
+
transition: left 0.6s;
|
|
8
20
|
}
|
|
9
|
-
.pc-overflow-
|
|
21
|
+
.pc-overflow-scroller__arrow {
|
|
10
22
|
position: absolute;
|
|
11
23
|
z-index: 10;
|
|
12
24
|
top: 0;
|
|
@@ -17,12 +29,11 @@
|
|
|
17
29
|
height: calc(100% - 1px);
|
|
18
30
|
cursor: pointer;
|
|
19
31
|
color: var(--yc-color-text-secondary);
|
|
20
|
-
background: linear-gradient(to left, var(--yc-color-base-background) 70%, var(--pc-transparent) 100%) no-repeat;
|
|
21
32
|
}
|
|
22
|
-
.pc-overflow-
|
|
33
|
+
.pc-overflow-scroller__arrow_type_left {
|
|
23
34
|
left: 0;
|
|
24
35
|
transform: rotate(180deg);
|
|
25
36
|
}
|
|
26
|
-
.pc-overflow-
|
|
37
|
+
.pc-overflow-scroller__arrow_type_right {
|
|
27
38
|
right: 0;
|
|
28
39
|
}
|
|
@@ -11,7 +11,7 @@ export interface OverflowScrollerState {
|
|
|
11
11
|
}
|
|
12
12
|
export default class OverflowScroller extends React.Component<PropsWithChildren<OverflowScrollerProps>, OverflowScrollerState> {
|
|
13
13
|
state: {
|
|
14
|
-
arrows:
|
|
14
|
+
arrows: Arrow[];
|
|
15
15
|
scrollValue: number;
|
|
16
16
|
};
|
|
17
17
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
@@ -7,6 +7,7 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const __1 = require("..");
|
|
8
8
|
const b = (0, utils_1.block)('overflow-scroller');
|
|
9
9
|
const TRANSITION_TIME = 300;
|
|
10
|
+
const PADDING_SIZE = 24;
|
|
10
11
|
class OverflowScroller extends react_1.default.Component {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
@@ -30,7 +31,7 @@ class OverflowScroller extends react_1.default.Component {
|
|
|
30
31
|
}
|
|
31
32
|
}, 100);
|
|
32
33
|
this.handleScrollClick = (e, arrow) => {
|
|
33
|
-
const { scrollValue } = this.state;
|
|
34
|
+
const { scrollValue, arrows } = this.state;
|
|
34
35
|
const { onScrollStart } = this.props;
|
|
35
36
|
if (this.containerRef &&
|
|
36
37
|
this.containerRef.current &&
|
|
@@ -39,8 +40,9 @@ class OverflowScroller extends react_1.default.Component {
|
|
|
39
40
|
const containerWidth = this.containerRef.current.offsetWidth;
|
|
40
41
|
const wrapperWidth = this.wrapperRef.current.offsetWidth;
|
|
41
42
|
const hiddenWidth = arrow === 'right' ? wrapperWidth - (containerWidth + scrollValue) : scrollValue;
|
|
43
|
+
const padding = arrows.length > 1 && hiddenWidth + PADDING_SIZE > containerWidth ? PADDING_SIZE : 0;
|
|
42
44
|
const delta = containerWidth > hiddenWidth ? hiddenWidth : containerWidth;
|
|
43
|
-
const newScrollValue = arrow === 'right' ? scrollValue + delta : scrollValue - delta;
|
|
45
|
+
const newScrollValue = arrow === 'right' ? scrollValue + delta + padding : scrollValue - delta - padding;
|
|
44
46
|
let newArrows = ['left', 'right'];
|
|
45
47
|
if (newScrollValue + containerWidth >= wrapperWidth) {
|
|
46
48
|
newArrows = ['left'];
|
|
@@ -73,9 +75,15 @@ class OverflowScroller extends react_1.default.Component {
|
|
|
73
75
|
const { className, children } = this.props;
|
|
74
76
|
const { arrows, scrollValue } = this.state;
|
|
75
77
|
const wrapperStyle = arrows.length ? { left: -scrollValue } : { left: 0 };
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
const paddingLeft = arrows.includes('left');
|
|
79
|
+
const paddingRight = arrows.includes('right');
|
|
80
|
+
return (react_1.default.createElement("div", { className: b('container', {
|
|
81
|
+
'padding-left': paddingLeft,
|
|
82
|
+
'padding-right': paddingRight,
|
|
83
|
+
}) },
|
|
84
|
+
react_1.default.createElement("div", { className: b(null, className), ref: this.containerRef },
|
|
85
|
+
react_1.default.createElement("div", { className: b('wrapper'), style: wrapperStyle, ref: this.wrapperRef }, children)),
|
|
86
|
+
arrows.map((direction) => (react_1.default.createElement("div", { key: direction, className: b('arrow', { type: direction }), onClick: (e) => this.handleScrollClick(e, direction) },
|
|
79
87
|
react_1.default.createElement(__1.ToggleArrow, { size: 18, type: 'horizontal', iconType: "navigation" }))))));
|
|
80
88
|
}
|
|
81
89
|
}
|
|
@@ -106,6 +106,7 @@ export interface BackgroundCardProps extends CardBaseProps, Omit<ContentBlockPro
|
|
|
106
106
|
export interface BasicCardProps extends CardBaseProps, Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
|
|
107
107
|
url: string;
|
|
108
108
|
icon?: ImageProps;
|
|
109
|
+
target?: string;
|
|
109
110
|
}
|
|
110
111
|
export interface BannerCardProps {
|
|
111
112
|
title: string;
|
|
@@ -4,13 +4,19 @@ export declare enum NavigationItemType {
|
|
|
4
4
|
Link = "link",
|
|
5
5
|
Dropdown = "dropdown",
|
|
6
6
|
Button = "button",
|
|
7
|
-
Social = "social"
|
|
7
|
+
Social = "social",
|
|
8
|
+
GithubStars = "github-stars"
|
|
8
9
|
}
|
|
9
10
|
export interface NavigationItemBase {
|
|
10
11
|
text: string;
|
|
11
12
|
icon?: ImageProps;
|
|
12
13
|
url?: string;
|
|
13
14
|
}
|
|
15
|
+
export interface NavigationGithubButton extends Omit<NavigationItemBase, 'icon'> {
|
|
16
|
+
type: NavigationItemType.GithubStars;
|
|
17
|
+
url: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
14
20
|
export interface NavigationLinkItem extends Omit<NavigationItemBase, 'url'> {
|
|
15
21
|
type: NavigationItemType.Link;
|
|
16
22
|
url: string;
|
|
@@ -29,8 +35,8 @@ export interface NavigationSocialItem extends Omit<NavigationItemBase, 'text'> {
|
|
|
29
35
|
icon: ImageProps;
|
|
30
36
|
url: string;
|
|
31
37
|
}
|
|
32
|
-
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem;
|
|
33
|
-
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData;
|
|
38
|
+
export type NavigationItemModel = NavigationLinkItem | NavigationButtonItem | NavigationDropdownItem | NavigationGithubButton;
|
|
39
|
+
export type NavigationItemData = NavigationLinkItem | NavigationButtonItem | NavigationSocialItem | DropdownItemData | NavigationGithubButton;
|
|
34
40
|
export type DropdownItemData = Omit<NavigationDropdownItem, 'items'>;
|
|
35
41
|
export interface NavigationLogoData {
|
|
36
42
|
icon: ImageProps;
|
|
@@ -7,4 +7,5 @@ var NavigationItemType;
|
|
|
7
7
|
NavigationItemType["Dropdown"] = "dropdown";
|
|
8
8
|
NavigationItemType["Button"] = "button";
|
|
9
9
|
NavigationItemType["Social"] = "social";
|
|
10
|
+
NavigationItemType["GithubStars"] = "github-stars";
|
|
10
11
|
})(NavigationItemType = exports.NavigationItemType || (exports.NavigationItemType = {}));
|
|
@@ -29,7 +29,6 @@ unpredictable css rules order in build */
|
|
|
29
29
|
}
|
|
30
30
|
.pc-header__navigation.pc-header__navigation {
|
|
31
31
|
position: relative;
|
|
32
|
-
margin-right: 20px;
|
|
33
32
|
flex: 1 0 0;
|
|
34
33
|
justify-content: flex-start;
|
|
35
34
|
}
|
|
@@ -49,10 +48,11 @@ unpredictable css rules order in build */
|
|
|
49
48
|
flex: 1 0 0;
|
|
50
49
|
justify-content: space-between;
|
|
51
50
|
align-items: center;
|
|
52
|
-
margin-right:
|
|
51
|
+
margin-right: 32px;
|
|
53
52
|
}
|
|
54
53
|
.pc-header__buttons {
|
|
55
54
|
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
56
|
}
|
|
57
57
|
@media (max-width: 768px) {
|
|
58
58
|
.pc-header__buttons {
|
|
@@ -47,7 +47,7 @@ const Header = ({ data, logo }) => {
|
|
|
47
47
|
react_1.default.createElement(Navigation_1.default, { className: b('navigation'), links: leftItems, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange })),
|
|
48
48
|
react_1.default.createElement("div", { className: b('right') },
|
|
49
49
|
react_1.default.createElement(MobileMenuButton, { isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }),
|
|
50
|
-
rightItems && (react_1.default.createElement("div", { className: b('buttons') }, rightItems.map((button) => (react_1.default.createElement(NavigationItem_1.default, { key: button.text, data: button
|
|
50
|
+
rightItems && (react_1.default.createElement("div", { className: b('buttons') }, rightItems.map((button) => (react_1.default.createElement(NavigationItem_1.default, { key: button.text, data: button })))))),
|
|
51
51
|
react_1.default.createElement(OutsideClick_1.default, { onOutsideClick: () => onSidebarOpenedChange(false) },
|
|
52
52
|
react_1.default.createElement(MobileNavigation_1.default, { topItems: leftItems, bottomItems: rightItems, isOpened: isSidebarOpened, activeItemIndex: activeItemIndex, onActiveItemChange: onActiveItemChange, onClose: hideSidebar })))))));
|
|
53
53
|
};
|
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
/* use this for style redefinitions to awoid problems with
|
|
2
|
-
unpredictable css rules order in build */
|
|
3
1
|
.pc-navigation-item {
|
|
4
2
|
position: relative;
|
|
5
3
|
display: flex;
|
|
6
4
|
align-items: center;
|
|
7
5
|
white-space: nowrap;
|
|
8
|
-
}
|
|
9
|
-
.pc-navigation-item_type_link {
|
|
10
|
-
color: var(--yc-color-text-primary);
|
|
11
|
-
color: inherit;
|
|
12
|
-
text-decoration: none;
|
|
13
|
-
outline: none;
|
|
14
|
-
}
|
|
15
|
-
.utilityfocus .pc-navigation-item_type_link:focus {
|
|
16
|
-
outline: 2px solid #ffdb4d;
|
|
17
|
-
}
|
|
18
|
-
.pc-navigation-item_type_link:hover, .pc-navigation-item_type_link_active {
|
|
19
|
-
color: var(--yc-color-text-link);
|
|
20
|
-
}
|
|
21
|
-
.pc-navigation-item_type_button {
|
|
22
|
-
display: inline-block;
|
|
23
|
-
}
|
|
24
|
-
.pc-navigation-item__arrow {
|
|
25
|
-
position: relative;
|
|
26
|
-
top: -2px;
|
|
27
|
-
width: 9px;
|
|
28
|
-
height: 9px;
|
|
29
|
-
margin-left: 5px;
|
|
30
|
-
}
|
|
31
|
-
.pc-navigation-item__icon {
|
|
32
|
-
display: flex;
|
|
33
|
-
width: 20px;
|
|
34
|
-
height: 20px;
|
|
35
|
-
margin-right: 8px;
|
|
36
|
-
object-fit: cover;
|
|
37
|
-
}
|
|
38
|
-
.pc-navigation-item__dropdown {
|
|
39
|
-
margin-left: 7px;
|
|
40
|
-
color: var(--yc-color-text-secondary);
|
|
41
6
|
}
|
|
@@ -3,57 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
-
const components_1 = require("../../../components");
|
|
7
|
-
const locationContext_1 = require("../../../context/locationContext");
|
|
8
6
|
const models_1 = require("../../../models");
|
|
9
|
-
const icons_1 = require("../../../icons");
|
|
10
7
|
const SocialIcon_1 = tslib_1.__importDefault(require("../SocialIcon/SocialIcon"));
|
|
11
|
-
const
|
|
8
|
+
const NavigationButton_1 = require("./components/NavigationButton/NavigationButton");
|
|
9
|
+
const NavigationDropdown_1 = require("./components/NavigationDropdown/NavigationDropdown");
|
|
10
|
+
const NavigationLink_1 = require("./components/NavigationLink/NavigationLink");
|
|
11
|
+
const GithubStars_1 = require("./components/GithubStars/GithubStars");
|
|
12
12
|
const b = (0, utils_1.block)('navigation-item');
|
|
13
|
-
const Content = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
|
|
14
|
-
icon && typeof icon !== 'string' && react_1.default.createElement(components_1.Image, Object.assign({ className: b('icon') }, icon)),
|
|
15
|
-
react_1.default.createElement("span", { className: b('text') }, text)));
|
|
16
|
-
const NavigationDropdown = (_a) => {
|
|
17
|
-
var { text, icon, isOpened } = _a, props = tslib_1.__rest(_a, ["text", "icon", "isOpened"]);
|
|
18
|
-
const iconData = icon && (0, utils_2.getMediaImage)(icon);
|
|
19
|
-
return (react_1.default.createElement("span", Object.assign({}, props),
|
|
20
|
-
react_1.default.createElement(Content, { text: text, icon: iconData }),
|
|
21
|
-
react_1.default.createElement(components_1.ToggleArrow, { className: b('dropdown'), size: 12, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
22
|
-
};
|
|
23
|
-
const NavigationLink = (props) => {
|
|
24
|
-
const { hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
25
|
-
const { url, text, icon, arrow, target } = props, rest = tslib_1.__rest(props, ["url", "text", "icon", "arrow", "target"]);
|
|
26
|
-
const linkExtraProps = (0, utils_1.getLinkProps)(url, hostname, target);
|
|
27
|
-
const iconData = icon && (0, utils_2.getMediaImage)(icon);
|
|
28
|
-
const content = (react_1.default.createElement(react_1.Fragment, null,
|
|
29
|
-
react_1.default.createElement(Content, { text: text, icon: iconData }),
|
|
30
|
-
arrow && react_1.default.createElement(icons_1.NavigationArrow, { className: b('arrow') })));
|
|
31
|
-
if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
|
|
32
|
-
return (react_1.default.createElement("a", Object.assign({ href: url, title: text }, rest, linkExtraProps), content));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return (react_1.default.createElement(components_1.RouterLink, { href: url, passHref: true },
|
|
36
|
-
react_1.default.createElement("a", Object.assign({}, rest), content)));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const NavigationButton = (props) => {
|
|
40
|
-
const { url, target } = props;
|
|
41
|
-
return target ? (react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))) : (react_1.default.createElement(components_1.RouterLink, { href: url },
|
|
42
|
-
react_1.default.createElement(components_1.Button, Object.assign({}, props, { url: url }))));
|
|
43
|
-
};
|
|
44
13
|
//todo: add types support form component in map
|
|
45
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
15
|
const NavigationItemsMap = {
|
|
47
|
-
[models_1.NavigationItemType.Button]: NavigationButton,
|
|
16
|
+
[models_1.NavigationItemType.Button]: NavigationButton_1.NavigationButton,
|
|
48
17
|
[models_1.NavigationItemType.Social]: SocialIcon_1.default,
|
|
49
|
-
[models_1.NavigationItemType.Dropdown]: NavigationDropdown,
|
|
50
|
-
[models_1.NavigationItemType.Link]: NavigationLink,
|
|
18
|
+
[models_1.NavigationItemType.Dropdown]: NavigationDropdown_1.NavigationDropdown,
|
|
19
|
+
[models_1.NavigationItemType.Link]: NavigationLink_1.NavigationLink,
|
|
20
|
+
[models_1.NavigationItemType.GithubStars]: GithubStars_1.GithubStars,
|
|
51
21
|
};
|
|
52
22
|
const NavigationItem = (_a) => {
|
|
53
23
|
var { data, className } = _a, props = tslib_1.__rest(_a, ["data", "className"]);
|
|
54
24
|
const { type = models_1.NavigationItemType.Link } = data;
|
|
55
25
|
const Component = NavigationItemsMap[type];
|
|
56
|
-
const componentProps = (0, react_1.useMemo)(() => (Object.assign(Object.assign({ className: b(
|
|
26
|
+
const componentProps = (0, react_1.useMemo)(() => (Object.assign(Object.assign({ className: b(null, className) }, data), props)), [className, data, props]);
|
|
57
27
|
return react_1.default.createElement(Component, Object.assign({}, componentProps));
|
|
58
28
|
};
|
|
59
29
|
exports.default = NavigationItem;
|
package/build/cjs/navigation/components/NavigationItem/components/ContentWrapper/ContentWrapper.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentWrapper = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const utils_1 = require("../../../../../utils");
|
|
7
|
+
const components_1 = require("../../../../../components");
|
|
8
|
+
const b = (0, utils_1.block)('content-wrapper');
|
|
9
|
+
const ContentWrapper = ({ text, icon }) => (react_1.default.createElement(react_1.Fragment, null,
|
|
10
|
+
icon && typeof icon !== 'string' && react_1.default.createElement(components_1.Image, Object.assign({ className: b('icon') }, icon)),
|
|
11
|
+
react_1.default.createElement("span", { className: b('text') }, text)));
|
|
12
|
+
exports.ContentWrapper = ContentWrapper;
|
package/build/cjs/navigation/components/NavigationItem/components/GithubStars/GithubStars.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NavigationItemProps } from '../../NavigationItem';
|
|
2
|
+
import { NavigationGithubButton } from '../../../../../models';
|
|
3
|
+
type NavigationGithubButtonProps = NavigationItemProps & NavigationGithubButton;
|
|
4
|
+
export declare const GithubStars: ({ text, url, className, label }: NavigationGithubButtonProps) => JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GithubStars = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const react_github_btn_1 = tslib_1.__importDefault(require("react-github-btn"));
|
|
7
|
+
const utils_1 = require("../../../../../utils");
|
|
8
|
+
const b = (0, utils_1.block)('github-stars');
|
|
9
|
+
const GithubStars = ({ text, url, className, label }) => (react_1.default.createElement("div", { className: b(null, className) },
|
|
10
|
+
react_1.default.createElement(react_github_btn_1.default, { href: url, "data-show-count": "true", "aria-label": label || 'Stars on GitHub' }, text)));
|
|
11
|
+
exports.GithubStars = GithubStars;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonProps } from '../../../../../models';
|
|
3
|
+
import { NavigationItemProps } from '../../NavigationItem';
|
|
4
|
+
type NavigationButtonProps = Pick<NavigationItemProps, 'className'> & ButtonProps;
|
|
5
|
+
export declare const NavigationButton: React.FC<NavigationButtonProps>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationButton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const utils_1 = require("../../../../../utils");
|
|
7
|
+
const components_1 = require("../../../../../components");
|
|
8
|
+
const b = (0, utils_1.block)('navigation-button');
|
|
9
|
+
const NavigationButton = (props) => {
|
|
10
|
+
const { url, target, className } = props;
|
|
11
|
+
const classes = b(null, className);
|
|
12
|
+
return target ? (react_1.default.createElement(components_1.Button, Object.assign({ className: classes }, props, { url: url }))) : (react_1.default.createElement(components_1.RouterLink, { href: url },
|
|
13
|
+
react_1.default.createElement(components_1.Button, Object.assign({}, props, { className: classes, url: url }))));
|
|
14
|
+
};
|
|
15
|
+
exports.NavigationButton = NavigationButton;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavigationItemProps } from '../../NavigationItem';
|
|
3
|
+
import { DropdownItemData } from '../../../../../models';
|
|
4
|
+
type NavigationDropdownProps = NavigationItemProps & DropdownItemData;
|
|
5
|
+
export declare const NavigationDropdown: React.FC<NavigationDropdownProps>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationDropdown = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const ContentWrapper_1 = require("../ContentWrapper/ContentWrapper");
|
|
7
|
+
const components_1 = require("../../../../../components");
|
|
8
|
+
const utils_1 = require("../../../../../utils");
|
|
9
|
+
const utils_2 = require("../../../../../components/Media/Image/utils");
|
|
10
|
+
const b = (0, utils_1.block)('navigation-dropdown');
|
|
11
|
+
const TOGGLE_ARROW_SIZE = 12;
|
|
12
|
+
const NavigationDropdown = (_a) => {
|
|
13
|
+
var { text, icon, isOpened } = _a, props = tslib_1.__rest(_a, ["text", "icon", "isOpened"]);
|
|
14
|
+
const iconData = icon && (0, utils_2.getMediaImage)(icon);
|
|
15
|
+
return (react_1.default.createElement("span", Object.assign({}, props),
|
|
16
|
+
react_1.default.createElement(ContentWrapper_1.ContentWrapper, { text: text, icon: iconData }),
|
|
17
|
+
react_1.default.createElement(components_1.ToggleArrow, { className: b(), size: TOGGLE_ARROW_SIZE, type: 'vertical', iconType: "navigation", open: isOpened })));
|
|
18
|
+
};
|
|
19
|
+
exports.NavigationDropdown = NavigationDropdown;
|
package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.css
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-navigation-link {
|
|
4
|
+
color: var(--yc-color-text-primary);
|
|
5
|
+
color: inherit;
|
|
6
|
+
text-decoration: none;
|
|
7
|
+
outline: none;
|
|
8
|
+
}
|
|
9
|
+
.utilityfocus .pc-navigation-link:focus {
|
|
10
|
+
outline: 2px solid #ffdb4d;
|
|
11
|
+
}
|
|
12
|
+
.pc-navigation-link:hover, .pc-navigation-link_active {
|
|
13
|
+
color: var(--yc-color-text-link);
|
|
14
|
+
}
|
|
15
|
+
.pc-navigation-link__arrow {
|
|
16
|
+
position: relative;
|
|
17
|
+
top: -2px;
|
|
18
|
+
width: 9px;
|
|
19
|
+
height: 9px;
|
|
20
|
+
margin-left: 5px;
|
|
21
|
+
}
|
package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NavigationItemProps } from '../../NavigationItem';
|
|
3
|
+
import { NavigationLinkItem } from '../../../../../models';
|
|
4
|
+
type NavigationLinkProps = NavigationItemProps & NavigationLinkItem;
|
|
5
|
+
export declare const NavigationLink: React.FC<NavigationLinkProps>;
|
|
6
|
+
export {};
|
package/build/cjs/navigation/components/NavigationItem/components/NavigationLink/NavigationLink.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationLink = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const ContentWrapper_1 = require("../ContentWrapper/ContentWrapper");
|
|
7
|
+
const icons_1 = require("../../../../../icons");
|
|
8
|
+
const components_1 = require("../../../../../components");
|
|
9
|
+
const utils_1 = require("../../../../../utils");
|
|
10
|
+
const utils_2 = require("../../../../../components/Media/Image/utils");
|
|
11
|
+
const locationContext_1 = require("../../../../../context/locationContext");
|
|
12
|
+
const b = (0, utils_1.block)('navigation-link');
|
|
13
|
+
const NavigationLink = (props) => {
|
|
14
|
+
const { hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
15
|
+
const { url, text, icon, arrow, target, className } = props, rest = tslib_1.__rest(props, ["url", "text", "icon", "arrow", "target", "className"]);
|
|
16
|
+
const linkExtraProps = (0, utils_1.getLinkProps)(url, hostname, target);
|
|
17
|
+
const iconData = icon && (0, utils_2.getMediaImage)(icon);
|
|
18
|
+
const classes = b(null, className);
|
|
19
|
+
const content = (react_1.default.createElement(react_1.Fragment, null,
|
|
20
|
+
react_1.default.createElement(ContentWrapper_1.ContentWrapper, { text: text, icon: iconData }),
|
|
21
|
+
arrow && react_1.default.createElement(icons_1.NavigationArrow, { className: b('arrow') })));
|
|
22
|
+
if ((linkExtraProps === null || linkExtraProps === void 0 ? void 0 : linkExtraProps.target) || !Link) {
|
|
23
|
+
return (react_1.default.createElement("a", Object.assign({ href: url, title: text, className: classes }, rest, linkExtraProps), content));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return (react_1.default.createElement(components_1.RouterLink, { href: url, passHref: true },
|
|
27
|
+
react_1.default.createElement("a", Object.assign({}, rest, { className: classes }), content)));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.NavigationLink = NavigationLink;
|
|
@@ -9,9 +9,9 @@ const __1 = require("../");
|
|
|
9
9
|
const utils_2 = require("../../components/Media/Image/utils");
|
|
10
10
|
const b = (0, utils_1.block)('basic-card');
|
|
11
11
|
const BasicCard = (props) => {
|
|
12
|
-
const {
|
|
12
|
+
const { title, text, icon, additionalInfo, links, buttons } = props, cardParams = tslib_1.__rest(props, ["title", "text", "icon", "additionalInfo", "links", "buttons"]);
|
|
13
13
|
const iconProps = icon && (0, utils_2.getMediaImage)(icon);
|
|
14
|
-
return (react_1.default.createElement(CardBase_1.default, { className: b()
|
|
14
|
+
return (react_1.default.createElement(CardBase_1.default, Object.assign({ className: b() }, cardParams),
|
|
15
15
|
react_1.default.createElement(CardBase_1.default.Content, null,
|
|
16
16
|
iconProps && react_1.default.createElement(Image_1.default, Object.assign({}, iconProps, { className: b('icon') })),
|
|
17
17
|
react_1.default.createElement(__1.Content, { title: title, text: text, additionalInfo: additionalInfo, links: links, buttons: buttons, colSizes: { all: 12, md: 12 }, size: "s" }))));
|
|
@@ -13,6 +13,9 @@ exports.BasicCard = {
|
|
|
13
13
|
required: ['url'],
|
|
14
14
|
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, common_1.BaseProps), common_1.CardBase), BasicCardContentProps), { url: {
|
|
15
15
|
type: 'string',
|
|
16
|
-
}, icon: schema_2.ImageProps
|
|
16
|
+
}, icon: schema_2.ImageProps, target: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
enum: ['_blank', '_parent', '_top', '_self'],
|
|
19
|
+
} }),
|
|
17
20
|
},
|
|
18
21
|
};
|
package/build/cjs/utils/url.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const EXTERNAL_LINK_PROPS: {
|
|
|
6
6
|
export declare function getLinkProps(url: string, hostname?: string, target?: string): {
|
|
7
7
|
target: string | undefined;
|
|
8
8
|
};
|
|
9
|
+
export declare function isAbsoluteUrl(url: string | URL): boolean;
|
|
9
10
|
export declare function isLinkExternal(url: string, routerHostname?: string): boolean;
|
|
10
11
|
export declare function getNonLocaleHostName(hostname: string): string;
|
|
11
12
|
export declare function setUrlTld(url: string, tld?: string): string;
|