@gravity-ui/page-constructor 1.22.1 → 1.24.0-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 +7 -0
- package/README.md +18 -0
- package/build/cjs/blocks/Icons/Icons.js +7 -4
- package/build/cjs/blocks/Share/Share.js +2 -2
- package/build/cjs/components/BackLink/BackLink.js +2 -2
- package/build/cjs/components/Button/Button.js +3 -1
- package/build/cjs/components/FileLink/FileLink.js +2 -1
- package/build/cjs/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +2 -1
- package/build/cjs/components/Link/Link.js +2 -1
- package/build/cjs/components/Link/LinkBase/LinkBase.d.ts +2 -0
- package/build/cjs/components/Link/LinkBase/LinkBase.js +18 -0
- package/build/cjs/components/Title/Title.js +2 -1
- package/build/cjs/models/constructor-items/common.d.ts +2 -0
- package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +2 -1
- package/build/cjs/navigation/components/SocialIcon/SocialIcon.js +2 -1
- package/build/cjs/sub-blocks/Quote/Quote.js +3 -1
- package/build/esm/blocks/Icons/Icons.js +8 -5
- package/build/esm/blocks/Share/Share.js +2 -2
- package/build/esm/components/BackLink/BackLink.js +2 -2
- package/build/esm/components/Button/Button.js +3 -1
- package/build/esm/components/FileLink/FileLink.js +2 -1
- package/build/esm/components/HeaderBreadcrumbs/HeaderBreadcrumbs.js +2 -1
- package/build/esm/components/Link/Link.js +2 -1
- package/build/esm/components/Link/LinkBase/LinkBase.d.ts +2 -0
- package/build/esm/components/Link/LinkBase/LinkBase.js +14 -0
- package/build/esm/components/Title/Title.js +2 -1
- package/build/esm/models/constructor-items/common.d.ts +2 -0
- package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.js +2 -1
- package/build/esm/navigation/components/SocialIcon/SocialIcon.js +2 -1
- package/build/esm/sub-blocks/Quote/Quote.js +3 -1
- package/package.json +1 -1
- package/server/models/constructor-items/common.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.23.0](https://github.com/gravity-ui/page-constructor/compare/v1.22.1...v1.23.0) (2023-03-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add release flow to README.md ([#183](https://github.com/gravity-ui/page-constructor/issues/183)) ([c7d7923](https://github.com/gravity-ui/page-constructor/commit/c7d7923c034b88a8e8167023448d8a071926cc26))
|
|
9
|
+
|
|
3
10
|
## [1.22.1](https://github.com/gravity-ui/page-constructor/compare/v1.22.0...v1.22.1) (2023-03-07)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -298,3 +298,21 @@ enum PredefinedEventTypes {
|
|
|
298
298
|
npm ci
|
|
299
299
|
npm run dev
|
|
300
300
|
```
|
|
301
|
+
|
|
302
|
+
## Release flow
|
|
303
|
+
|
|
304
|
+
In usual cases we use two types of commits:
|
|
305
|
+
|
|
306
|
+
1. fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
|
|
307
|
+
2. feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
|
|
308
|
+
3. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
|
|
309
|
+
|
|
310
|
+
You can see all information [here](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
311
|
+
|
|
312
|
+
When you receive the approval of your pull-request from the code owners and pass all the checks, please do the following:
|
|
313
|
+
|
|
314
|
+
1. You should check if there is a release pull-request from robot with changes from another contributor (it looks like `chore(main): release 0.0.0`). If it exists, you should check why it is not merged. If the contributor agrees to release a shared version, follow the next step. If not, ask him to release his version, then follow the next step.
|
|
315
|
+
2. Squash and merge your PR (It is important to release a new version with Github-Actions)
|
|
316
|
+
3. Wait until robot creates a PR with a new version of the package and information about your changes in CHANGELOG.md. You can see the process on [the Actions tab](https://github.com/gravity-ui/page-constructor/actions).
|
|
317
|
+
4. Check your changes in CHANGELOG.md and approve robot's PR.
|
|
318
|
+
5. Squash and merge PR. You can see release process on [the Actions tab](https://github.com/gravity-ui/page-constructor/actions).
|
|
@@ -6,12 +6,15 @@ const utils_1 = require("../../utils");
|
|
|
6
6
|
const components_1 = require("../../components");
|
|
7
7
|
const locationContext_1 = require("../../context/locationContext");
|
|
8
8
|
const b = (0, utils_1.block)('icons-block');
|
|
9
|
+
const IconChildren = ({ src, text }) => (react_1.default.createElement(react_1.Fragment, null,
|
|
10
|
+
react_1.default.createElement(components_1.Image, { className: b('image'), src: src }),
|
|
11
|
+
react_1.default.createElement("p", { className: b('text') }, text)));
|
|
9
12
|
const Icons = ({ title, size = 's', items }) => {
|
|
10
|
-
const { hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
13
|
+
const { hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
11
14
|
return (react_1.default.createElement("div", { className: b({ size }) },
|
|
12
15
|
title && react_1.default.createElement(components_1.BlockHeader, { className: b('header'), title: title, colSizes: { all: 12 } }),
|
|
13
|
-
items.map((item) =>
|
|
14
|
-
react_1.default.createElement(
|
|
15
|
-
|
|
16
|
+
items.map((item) => {
|
|
17
|
+
return react_1.default.createElement(Link || 'a', Object.assign({ className: b('item'), key: item.url, href: item.url }, (Link ? {} : (0, utils_1.getLinkProps)(item.url, hostname))), react_1.default.createElement(IconChildren, { text: item.text, src: item.src }));
|
|
18
|
+
})));
|
|
16
19
|
};
|
|
17
20
|
exports.default = Icons;
|
|
@@ -22,7 +22,7 @@ const icons = {
|
|
|
22
22
|
};
|
|
23
23
|
const b = (0, utils_1.block)('share-block');
|
|
24
24
|
const Share = ({ items, title }) => {
|
|
25
|
-
const { pathname, hostname } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
25
|
+
const { pathname, hostname, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
26
26
|
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton);
|
|
27
27
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
28
28
|
return (react_1.default.createElement("div", { className: b() },
|
|
@@ -31,7 +31,7 @@ const Share = ({ items, title }) => {
|
|
|
31
31
|
const url = (0, utils_1.getAbsolutePath)(hostname, pathname);
|
|
32
32
|
const socialUrl = (0, utils_1.getShareLink)(url, type);
|
|
33
33
|
const icon = icons[type];
|
|
34
|
-
return (react_1.default.createElement(uikit_1.Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && react_1.default.createElement(uikit_1.Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
34
|
+
return (react_1.default.createElement(uikit_1.Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, component: Link, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && react_1.default.createElement(uikit_1.Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
35
35
|
}))));
|
|
36
36
|
};
|
|
37
37
|
exports.default = Share;
|
|
@@ -8,7 +8,7 @@ const locationContext_1 = require("../../context/locationContext");
|
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const models_1 = require("../../models");
|
|
10
10
|
function BackLink(props) {
|
|
11
|
-
const { history } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
11
|
+
const { history, Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
12
12
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
13
13
|
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.ShareButton, url);
|
|
14
14
|
const backActionHandler = (0, react_1.useCallback)(async () => {
|
|
@@ -26,7 +26,7 @@ function BackLink(props) {
|
|
|
26
26
|
history.push({ pathname: url });
|
|
27
27
|
}
|
|
28
28
|
}, [handleAnalytics, history, onClick, url]);
|
|
29
|
-
return (react_1.default.createElement(uikit_1.Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
29
|
+
return (react_1.default.createElement(uikit_1.Button, { component: Link, className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
30
30
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowSidebar, size: 24 }),
|
|
31
31
|
react_1.default.createElement("span", null, title)));
|
|
32
32
|
}
|
|
@@ -7,6 +7,7 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const utils_2 = require("./utils");
|
|
9
9
|
const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
10
|
+
const locationContext_1 = require("../../context/locationContext/locationContext");
|
|
10
11
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
11
12
|
const hooks_1 = require("../../hooks");
|
|
12
13
|
const icons_1 = require("../../icons");
|
|
@@ -14,6 +15,7 @@ const b = (0, utils_1.block)('button-block');
|
|
|
14
15
|
const Button = (props) => {
|
|
15
16
|
const handleMetrika = (0, useMetrika_1.useMetrika)();
|
|
16
17
|
const { lang, tld } = (0, react_1.useContext)(localeContext_1.LocaleContext);
|
|
18
|
+
const { Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
17
19
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = tslib_1.__rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
18
20
|
const defaultImgPosition = 'left';
|
|
19
21
|
const handleAnalytics = (0, hooks_1.useAnalytics)(models_1.DefaultEventNames.Button, url);
|
|
@@ -42,7 +44,7 @@ const Button = (props) => {
|
|
|
42
44
|
image = undefined;
|
|
43
45
|
}
|
|
44
46
|
const buttonTheme = theme === 'scale' ? 'accent' : theme;
|
|
45
|
-
return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined }, buttonProps),
|
|
47
|
+
return (react_1.default.createElement(uikit_1.Button, Object.assign({ className: buttonClass, view: (0, utils_2.toCommonView)(buttonTheme), size: (0, utils_2.toCommonSize)(size), href: url ? (0, utils_1.setUrlTld)(url, tld) : undefined, component: Link }, buttonProps),
|
|
46
48
|
icon && buttonImg.position === 'left' ? icon : null,
|
|
47
49
|
react_1.default.createElement("span", { className: b('content') },
|
|
48
50
|
image && buttonImg.position === 'left' ? image : null,
|
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
7
|
const locationContext_1 = require("../../context/locationContext");
|
|
8
|
+
const LinkBase_1 = require("../Link/LinkBase/LinkBase");
|
|
8
9
|
const b = (0, utils_1.block)('file-link');
|
|
9
10
|
const FIGMA_URL = 'https://www.figma.com';
|
|
10
11
|
var FileExtension;
|
|
@@ -31,6 +32,6 @@ const FileLink = (props) => {
|
|
|
31
32
|
return (react_1.default.createElement("div", { className: b({ ext: fileExt, type, size: textSize, theme }, className) },
|
|
32
33
|
Object.values(FileExtension).includes(fileExt) && (react_1.default.createElement("div", { className: b('file-label') }, fileExt)),
|
|
33
34
|
react_1.default.createElement("div", { className: b('link') },
|
|
34
|
-
react_1.default.createElement(
|
|
35
|
+
react_1.default.createElement(LinkBase_1.LinkBase, Object.assign({ href: href }, (0, utils_1.getLinkProps)(href, hostname), { onClick: onClick }), text))));
|
|
35
36
|
};
|
|
36
37
|
exports.default = FileLink;
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
7
|
+
const LinkBase_1 = require("../Link/LinkBase/LinkBase");
|
|
7
8
|
const b = (0, utils_1.block)('header-breadcrumbs');
|
|
8
9
|
function HeaderBreadcrumbs(props) {
|
|
9
10
|
const { items, metrikaGoals, pixelEvents, theme = 'light', className } = props;
|
|
@@ -12,6 +13,6 @@ function HeaderBreadcrumbs(props) {
|
|
|
12
13
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
13
14
|
};
|
|
14
15
|
return (react_1.default.createElement("div", { className: b({ theme }, className) }, items.map((item) => (react_1.default.createElement("div", { className: b('item'), key: item.url },
|
|
15
|
-
react_1.default.createElement(
|
|
16
|
+
react_1.default.createElement(LinkBase_1.LinkBase, { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
|
|
16
17
|
}
|
|
17
18
|
exports.default = HeaderBreadcrumbs;
|
|
@@ -12,6 +12,7 @@ const localeContext_1 = require("../../context/localeContext/localeContext");
|
|
|
12
12
|
const locationContext_1 = require("../../context/locationContext/locationContext");
|
|
13
13
|
const useMetrika_1 = require("../../hooks/useMetrika");
|
|
14
14
|
const hooks_1 = require("../../hooks");
|
|
15
|
+
const LinkBase_1 = require("./LinkBase/LinkBase");
|
|
15
16
|
const b = (0, utils_1.block)('link-block');
|
|
16
17
|
const WORD_JOINER_SYM = '\u200b';
|
|
17
18
|
function getArrowSize(size) {
|
|
@@ -48,7 +49,7 @@ const LinkBlock = (props) => {
|
|
|
48
49
|
case 'normal': {
|
|
49
50
|
const linkProps = (0, utils_1.getLinkProps)(url, hostname, target);
|
|
50
51
|
const content = children || text;
|
|
51
|
-
return (react_1.default.createElement(
|
|
52
|
+
return (react_1.default.createElement(LinkBase_1.LinkBase, Object.assign({ className: b('link', { theme: colorTheme, 'has-arrow': arrow }), href: href, onClick: onClick }, linkProps), arrow ? (react_1.default.createElement(react_1.Fragment, null,
|
|
52
53
|
react_1.default.createElement("span", { className: b('content') }, content),
|
|
53
54
|
WORD_JOINER_SYM,
|
|
54
55
|
react_1.default.createElement(uikit_1.Icon, { className: b('arrow'), data: icons_1.Chevron, size: getArrowSize(textSize) }))) : (content)));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkBase = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const locationContext_1 = require("../../../context/locationContext");
|
|
8
|
+
const LinkBase = (props) => {
|
|
9
|
+
const { href, children } = props, linkProps = tslib_1.__rest(props, ["href", "children"]);
|
|
10
|
+
const { Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
11
|
+
if (Link && href) {
|
|
12
|
+
const extractedProps = (0, lodash_1.omit)(linkProps, ['rel', 'ref']);
|
|
13
|
+
return (react_1.default.createElement(Link, { href: href },
|
|
14
|
+
react_1.default.createElement("a", Object.assign({}, extractedProps), children)));
|
|
15
|
+
}
|
|
16
|
+
return (react_1.default.createElement("a", Object.assign({ href: href }, linkProps), children));
|
|
17
|
+
};
|
|
18
|
+
exports.LinkBase = LinkBase;
|
|
@@ -8,6 +8,7 @@ const Anchor_1 = tslib_1.__importDefault(require("../Anchor/Anchor"));
|
|
|
8
8
|
const __1 = require("../");
|
|
9
9
|
const locationContext_1 = require("../../context/locationContext");
|
|
10
10
|
const mobileContext_1 = require("../../context/mobileContext");
|
|
11
|
+
const LinkBase_1 = require("../Link/LinkBase/LinkBase");
|
|
11
12
|
const b = (0, utils_1.block)('title-block');
|
|
12
13
|
function getArrowSize(size, isMobile) {
|
|
13
14
|
switch (size) {
|
|
@@ -40,7 +41,7 @@ const Title = (props) => {
|
|
|
40
41
|
content = textMarkup;
|
|
41
42
|
}
|
|
42
43
|
else if (url) {
|
|
43
|
-
content = (react_1.default.createElement(
|
|
44
|
+
content = (react_1.default.createElement(LinkBase_1.LinkBase, Object.assign({ className: b('link'), href: url }, (0, utils_1.getLinkProps)(url, hostname), { onClick: onClick }), insideClickableContent));
|
|
44
45
|
}
|
|
45
46
|
else if (onClick) {
|
|
46
47
|
content = (react_1.default.createElement("span", { className: b('link'), onClick: onClick }, insideClickableContent));
|
|
@@ -111,6 +111,8 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
111
111
|
controls?: MediaVideoControlsType;
|
|
112
112
|
metrika?: MetrikaVideo;
|
|
113
113
|
}
|
|
114
|
+
export interface LinkBaseProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
|
115
|
+
}
|
|
114
116
|
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
117
|
url: string;
|
|
116
118
|
text?: string;
|
package/build/cjs/navigation/components/NavigationItem/components/GithubButton/GithubButton.js
CHANGED
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const utils_1 = require("../../../../../utils");
|
|
7
7
|
const models_1 = require("../../../../../models");
|
|
8
|
+
const LinkBase_1 = require("../../../../../components/Link/LinkBase/LinkBase");
|
|
8
9
|
const b = (0, utils_1.block)('github-button');
|
|
9
10
|
const DEFAULT_LABEL = 'Stars on GitHub';
|
|
10
11
|
/* More information about github-buttons in https://buttons.github.io/ */
|
|
@@ -42,6 +43,6 @@ const GithubButton = ({ text, url, className, label, size, icon, }) => {
|
|
|
42
43
|
}, []);
|
|
43
44
|
return (react_1.default.createElement("div", { className: b(null, className) },
|
|
44
45
|
react_1.default.createElement("span", { ref: containerRef },
|
|
45
|
-
react_1.default.createElement(
|
|
46
|
+
react_1.default.createElement(LinkBase_1.LinkBase, Object.assign({ href: url, ref: linkRef, "data-show-count": "true", "aria-label": label || DEFAULT_LABEL }, (icon && { 'data-icon': models_1.NavigationGithubButtonIcon[icon] }), (size && { 'data-size': size })), text))));
|
|
46
47
|
};
|
|
47
48
|
exports.GithubButton = GithubButton;
|
|
@@ -5,10 +5,11 @@ const react_1 = tslib_1.__importDefault(require("react"));
|
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
6
|
const components_1 = require("../../../components");
|
|
7
7
|
const utils_2 = require("../../../components/Media/Image/utils");
|
|
8
|
+
const LinkBase_1 = require("../../../components/Link/LinkBase/LinkBase");
|
|
8
9
|
const b = (0, utils_1.block)('social-icon');
|
|
9
10
|
const SocialIcon = ({ icon, url, className }) => {
|
|
10
11
|
const iconData = (0, utils_2.getMediaImage)(icon);
|
|
11
|
-
return (react_1.default.createElement(
|
|
12
|
+
return (react_1.default.createElement(LinkBase_1.LinkBase, { href: url, target: "_blank", rel: "noopener noreferrer", className: b(null, className) },
|
|
12
13
|
react_1.default.createElement(components_1.Image, Object.assign({ className: b('icon') }, iconData))));
|
|
13
14
|
};
|
|
14
15
|
exports.default = SocialIcon;
|
|
@@ -7,11 +7,13 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const models_1 = require("../../models");
|
|
8
8
|
const components_1 = require("../../components");
|
|
9
9
|
const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
|
|
10
|
+
const locationContext_1 = require("../../context/locationContext/locationContext");
|
|
10
11
|
const utils_2 = require("../../components/Media/Image/utils");
|
|
11
12
|
const hooks_1 = require("../../hooks");
|
|
12
13
|
const b = (0, utils_1.block)('quote');
|
|
13
14
|
const Quote = (props) => {
|
|
14
15
|
const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, } = props;
|
|
16
|
+
const { Link } = (0, react_1.useContext)(locationContext_1.LocationContext);
|
|
15
17
|
const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
|
|
16
18
|
const imageThemed = (0, utils_1.getThemedValue)(image, theme);
|
|
17
19
|
const imageData = (0, utils_2.getMediaImage)(imageThemed);
|
|
@@ -19,7 +21,7 @@ const Quote = (props) => {
|
|
|
19
21
|
const handleButtonClick = (0, react_1.useCallback)(() => handleAnalytics(), [handleAnalytics]);
|
|
20
22
|
const renderFooter = Boolean(author || url) && (react_1.default.createElement("div", { className: b('author-wrapper') },
|
|
21
23
|
author && (react_1.default.createElement(components_1.Author, { className: b('author', { theme: textTheme }), author: author, type: models_1.AuthorType.Line })),
|
|
22
|
-
url && buttonText && (react_1.default.createElement(uikit_1.Button, { view: "outlined", size: "xl", href: url, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|
|
24
|
+
url && buttonText && (react_1.default.createElement(uikit_1.Button, { view: "outlined", size: "xl", href: url, component: Link, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|
|
23
25
|
return (react_1.default.createElement("div", { className: b({ theme: textTheme, border }), style: color ? { backgroundColor: color } : {} },
|
|
24
26
|
react_1.default.createElement("div", { key: text, className: b('content-wrapper') },
|
|
25
27
|
react_1.default.createElement("div", null,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { Fragment, useContext } from 'react';
|
|
2
2
|
import { block, getLinkProps } from '../../utils';
|
|
3
3
|
import { BlockHeader, Image } from '../../components';
|
|
4
4
|
import { LocationContext } from '../../context/locationContext';
|
|
5
5
|
import './Icons.css';
|
|
6
6
|
const b = block('icons-block');
|
|
7
|
+
const IconChildren = ({ src, text }) => (React.createElement(Fragment, null,
|
|
8
|
+
React.createElement(Image, { className: b('image'), src: src }),
|
|
9
|
+
React.createElement("p", { className: b('text') }, text)));
|
|
7
10
|
const Icons = ({ title, size = 's', items }) => {
|
|
8
|
-
const { hostname } = useContext(LocationContext);
|
|
11
|
+
const { hostname, Link } = useContext(LocationContext);
|
|
9
12
|
return (React.createElement("div", { className: b({ size }) },
|
|
10
13
|
title && React.createElement(BlockHeader, { className: b('header'), title: title, colSizes: { all: 12 } }),
|
|
11
|
-
items.map((item) =>
|
|
12
|
-
React.createElement(
|
|
13
|
-
|
|
14
|
+
items.map((item) => {
|
|
15
|
+
return React.createElement(Link || 'a', Object.assign({ className: b('item'), key: item.url, href: item.url }, (Link ? {} : getLinkProps(item.url, hostname))), React.createElement(IconChildren, { text: item.text, src: item.src }));
|
|
16
|
+
})));
|
|
14
17
|
};
|
|
15
18
|
export default Icons;
|
|
@@ -20,7 +20,7 @@ const icons = {
|
|
|
20
20
|
};
|
|
21
21
|
const b = block('share-block');
|
|
22
22
|
const Share = ({ items, title }) => {
|
|
23
|
-
const { pathname, hostname } = useContext(LocationContext);
|
|
23
|
+
const { pathname, hostname, Link } = useContext(LocationContext);
|
|
24
24
|
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton);
|
|
25
25
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
26
26
|
return (React.createElement("div", { className: b() },
|
|
@@ -29,7 +29,7 @@ const Share = ({ items, title }) => {
|
|
|
29
29
|
const url = getAbsolutePath(hostname, pathname);
|
|
30
30
|
const socialUrl = getShareLink(url, type);
|
|
31
31
|
const icon = icons[type];
|
|
32
|
-
return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
32
|
+
return (React.createElement(Button, { key: type, view: "flat", size: "l", target: "_blank", href: socialUrl, component: Link, className: b('item', { type: type.toLowerCase() }), onClick: handleButtonClick }, icon && React.createElement(Icon, { data: icon, size: 24, className: b('icon', { type }) })));
|
|
33
33
|
}))));
|
|
34
34
|
};
|
|
35
35
|
export default Share;
|
|
@@ -5,7 +5,7 @@ import { LocationContext } from '../../context/locationContext';
|
|
|
5
5
|
import { useAnalytics } from '../../hooks';
|
|
6
6
|
import { DefaultEventNames } from '../../models';
|
|
7
7
|
export default function BackLink(props) {
|
|
8
|
-
const { history } = useContext(LocationContext);
|
|
8
|
+
const { history, Link } = useContext(LocationContext);
|
|
9
9
|
const { url, title, theme = 'default', size = 'l', className, shouldHandleBackAction = false, onClick, } = props;
|
|
10
10
|
const handleAnalytics = useAnalytics(DefaultEventNames.ShareButton, url);
|
|
11
11
|
const backActionHandler = useCallback(async () => {
|
|
@@ -23,7 +23,7 @@ export default function BackLink(props) {
|
|
|
23
23
|
history.push({ pathname: url });
|
|
24
24
|
}
|
|
25
25
|
}, [handleAnalytics, history, onClick, url]);
|
|
26
|
-
return (React.createElement(Button, { className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
26
|
+
return (React.createElement(Button, { component: Link, className: className, view: theme === 'special' ? 'flat-contrast' : 'flat-secondary', size: size, href: shouldHandleBackAction ? undefined : url, onClick: shouldHandleBackAction ? backActionHandler : undefined },
|
|
27
27
|
React.createElement(Icon, { data: ArrowSidebar, size: 24 }),
|
|
28
28
|
React.createElement("span", null, title)));
|
|
29
29
|
}
|
|
@@ -5,6 +5,7 @@ import { block, setUrlTld } from '../../utils';
|
|
|
5
5
|
import { DefaultEventNames } from '../../models';
|
|
6
6
|
import { toCommonSize, toCommonView } from './utils';
|
|
7
7
|
import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
8
|
+
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
8
9
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
9
10
|
import { useAnalytics } from '../../hooks';
|
|
10
11
|
import { Github } from '../../icons';
|
|
@@ -13,6 +14,7 @@ const b = block('button-block');
|
|
|
13
14
|
const Button = (props) => {
|
|
14
15
|
const handleMetrika = useMetrika();
|
|
15
16
|
const { lang, tld } = useContext(LocaleContext);
|
|
17
|
+
const { Link } = useContext(LocationContext);
|
|
16
18
|
const { className, metrikaGoals, pixelEvents, analyticsEvents, size = 'l', theme = 'normal', url, img, onClick: onClickOrigin, text } = props, rest = __rest(props, ["className", "metrikaGoals", "pixelEvents", "analyticsEvents", "size", "theme", "url", "img", "onClick", "text"]);
|
|
17
19
|
const defaultImgPosition = 'left';
|
|
18
20
|
const handleAnalytics = useAnalytics(DefaultEventNames.Button, url);
|
|
@@ -41,7 +43,7 @@ const Button = (props) => {
|
|
|
41
43
|
image = undefined;
|
|
42
44
|
}
|
|
43
45
|
const buttonTheme = theme === 'scale' ? 'accent' : theme;
|
|
44
|
-
return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined }, buttonProps),
|
|
46
|
+
return (React.createElement(CommonButton, Object.assign({ className: buttonClass, view: toCommonView(buttonTheme), size: toCommonSize(size), href: url ? setUrlTld(url, tld) : undefined, component: Link }, buttonProps),
|
|
45
47
|
icon && buttonImg.position === 'left' ? icon : null,
|
|
46
48
|
React.createElement("span", { className: b('content') },
|
|
47
49
|
image && buttonImg.position === 'left' ? image : null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { block, getLinkProps } from '../../utils';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { LocationContext } from '../../context/locationContext';
|
|
4
|
+
import { LinkBase } from '../Link/LinkBase/LinkBase';
|
|
4
5
|
import './FileLink.css';
|
|
5
6
|
const b = block('file-link');
|
|
6
7
|
const FIGMA_URL = 'https://www.figma.com';
|
|
@@ -27,6 +28,6 @@ const FileLink = (props) => {
|
|
|
27
28
|
return (React.createElement("div", { className: b({ ext: fileExt, type, size: textSize, theme }, className) },
|
|
28
29
|
Object.values(FileExtension).includes(fileExt) && (React.createElement("div", { className: b('file-label') }, fileExt)),
|
|
29
30
|
React.createElement("div", { className: b('link') },
|
|
30
|
-
React.createElement(
|
|
31
|
+
React.createElement(LinkBase, Object.assign({ href: href }, getLinkProps(href, hostname), { onClick: onClick }), text))));
|
|
31
32
|
};
|
|
32
33
|
export default FileLink;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { block } from '../../utils';
|
|
3
3
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
4
|
+
import { LinkBase } from '../Link/LinkBase/LinkBase';
|
|
4
5
|
import './HeaderBreadcrumbs.css';
|
|
5
6
|
const b = block('header-breadcrumbs');
|
|
6
7
|
export default function HeaderBreadcrumbs(props) {
|
|
@@ -10,5 +11,5 @@ export default function HeaderBreadcrumbs(props) {
|
|
|
10
11
|
handleMetrika({ metrikaGoals, pixelEvents });
|
|
11
12
|
};
|
|
12
13
|
return (React.createElement("div", { className: b({ theme }, className) }, items.map((item) => (React.createElement("div", { className: b('item'), key: item.url },
|
|
13
|
-
React.createElement(
|
|
14
|
+
React.createElement(LinkBase, { href: item.url, className: b('text'), onClick: onClick }, item.text))))));
|
|
14
15
|
}
|
|
@@ -9,6 +9,7 @@ import { LocaleContext } from '../../context/localeContext/localeContext';
|
|
|
9
9
|
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
10
10
|
import { useMetrika } from '../../hooks/useMetrika';
|
|
11
11
|
import { useAnalytics } from '../../hooks';
|
|
12
|
+
import { LinkBase } from './LinkBase/LinkBase';
|
|
12
13
|
import './Link.css';
|
|
13
14
|
const b = block('link-block');
|
|
14
15
|
const WORD_JOINER_SYM = '\u200b';
|
|
@@ -46,7 +47,7 @@ const LinkBlock = (props) => {
|
|
|
46
47
|
case 'normal': {
|
|
47
48
|
const linkProps = getLinkProps(url, hostname, target);
|
|
48
49
|
const content = children || text;
|
|
49
|
-
return (React.createElement(
|
|
50
|
+
return (React.createElement(LinkBase, Object.assign({ className: b('link', { theme: colorTheme, 'has-arrow': arrow }), href: href, onClick: onClick }, linkProps), arrow ? (React.createElement(Fragment, null,
|
|
50
51
|
React.createElement("span", { className: b('content') }, content),
|
|
51
52
|
WORD_JOINER_SYM,
|
|
52
53
|
React.createElement(Icon, { className: b('arrow'), data: Chevron, size: getArrowSize(textSize) }))) : (content)));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { omit } from 'lodash';
|
|
4
|
+
import { LocationContext } from '../../../context/locationContext';
|
|
5
|
+
export const LinkBase = (props) => {
|
|
6
|
+
const { href, children } = props, linkProps = __rest(props, ["href", "children"]);
|
|
7
|
+
const { Link } = useContext(LocationContext);
|
|
8
|
+
if (Link && href) {
|
|
9
|
+
const extractedProps = omit(linkProps, ['rel', 'ref']);
|
|
10
|
+
return (React.createElement(Link, { href: href },
|
|
11
|
+
React.createElement("a", Object.assign({}, extractedProps), children)));
|
|
12
|
+
}
|
|
13
|
+
return (React.createElement("a", Object.assign({ href: href }, linkProps), children));
|
|
14
|
+
};
|
|
@@ -4,6 +4,7 @@ import Anchor from '../Anchor/Anchor';
|
|
|
4
4
|
import { ToggleArrow, HTML } from '../';
|
|
5
5
|
import { LocationContext } from '../../context/locationContext';
|
|
6
6
|
import { MobileContext } from '../../context/mobileContext';
|
|
7
|
+
import { LinkBase } from '../Link/LinkBase/LinkBase';
|
|
7
8
|
import './Title.css';
|
|
8
9
|
const b = block('title-block');
|
|
9
10
|
export function getArrowSize(size, isMobile) {
|
|
@@ -36,7 +37,7 @@ const Title = (props) => {
|
|
|
36
37
|
content = textMarkup;
|
|
37
38
|
}
|
|
38
39
|
else if (url) {
|
|
39
|
-
content = (React.createElement(
|
|
40
|
+
content = (React.createElement(LinkBase, Object.assign({ className: b('link'), href: url }, getLinkProps(url, hostname), { onClick: onClick }), insideClickableContent));
|
|
40
41
|
}
|
|
41
42
|
else if (onClick) {
|
|
42
43
|
content = (React.createElement("span", { className: b('link'), onClick: onClick }, insideClickableContent));
|
|
@@ -111,6 +111,8 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
111
111
|
controls?: MediaVideoControlsType;
|
|
112
112
|
metrika?: MetrikaVideo;
|
|
113
113
|
}
|
|
114
|
+
export interface LinkBaseProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
|
115
|
+
}
|
|
114
116
|
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
117
|
url: string;
|
|
116
118
|
text?: string;
|
package/build/esm/navigation/components/NavigationItem/components/GithubButton/GithubButton.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import { block } from '../../../../../utils';
|
|
3
3
|
import { NavigationGithubButtonIcon } from '../../../../../models';
|
|
4
|
+
import { LinkBase } from '../../../../../components/Link/LinkBase/LinkBase';
|
|
4
5
|
import './GithubButton.css';
|
|
5
6
|
const b = block('github-button');
|
|
6
7
|
const DEFAULT_LABEL = 'Stars on GitHub';
|
|
@@ -39,5 +40,5 @@ export const GithubButton = ({ text, url, className, label, size, icon, }) => {
|
|
|
39
40
|
}, []);
|
|
40
41
|
return (React.createElement("div", { className: b(null, className) },
|
|
41
42
|
React.createElement("span", { ref: containerRef },
|
|
42
|
-
React.createElement(
|
|
43
|
+
React.createElement(LinkBase, Object.assign({ href: url, ref: linkRef, "data-show-count": "true", "aria-label": label || DEFAULT_LABEL }, (icon && { 'data-icon': NavigationGithubButtonIcon[icon] }), (size && { 'data-size': size })), text))));
|
|
43
44
|
};
|
|
@@ -2,11 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { block } from '../../../utils';
|
|
3
3
|
import { Image } from '../../../components';
|
|
4
4
|
import { getMediaImage } from '../../../components/Media/Image/utils';
|
|
5
|
+
import { LinkBase } from '../../../components/Link/LinkBase/LinkBase';
|
|
5
6
|
import './SocialIcon.css';
|
|
6
7
|
const b = block('social-icon');
|
|
7
8
|
const SocialIcon = ({ icon, url, className }) => {
|
|
8
9
|
const iconData = getMediaImage(icon);
|
|
9
|
-
return (React.createElement(
|
|
10
|
+
return (React.createElement(LinkBase, { href: url, target: "_blank", rel: "noopener noreferrer", className: b(null, className) },
|
|
10
11
|
React.createElement(Image, Object.assign({ className: b('icon') }, iconData))));
|
|
11
12
|
};
|
|
12
13
|
export default SocialIcon;
|
|
@@ -4,12 +4,14 @@ import { block, getThemedValue } from '../../utils';
|
|
|
4
4
|
import { AuthorType, DefaultEventNames } from '../../models';
|
|
5
5
|
import { Author, Image, HTML } from '../../components';
|
|
6
6
|
import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
|
|
7
|
+
import { LocationContext } from '../../context/locationContext/locationContext';
|
|
7
8
|
import { getMediaImage } from '../../components/Media/Image/utils';
|
|
8
9
|
import { useAnalytics } from '../../hooks';
|
|
9
10
|
import './Quote.css';
|
|
10
11
|
const b = block('quote');
|
|
11
12
|
const Quote = (props) => {
|
|
12
13
|
const { theme: textTheme = 'light', color, image, border = 'shadow', text, logo, author, url, buttonText, } = props;
|
|
14
|
+
const { Link } = useContext(LocationContext);
|
|
13
15
|
const { themeValue: theme } = useContext(ThemeValueContext);
|
|
14
16
|
const imageThemed = getThemedValue(image, theme);
|
|
15
17
|
const imageData = getMediaImage(imageThemed);
|
|
@@ -17,7 +19,7 @@ const Quote = (props) => {
|
|
|
17
19
|
const handleButtonClick = useCallback(() => handleAnalytics(), [handleAnalytics]);
|
|
18
20
|
const renderFooter = Boolean(author || url) && (React.createElement("div", { className: b('author-wrapper') },
|
|
19
21
|
author && (React.createElement(Author, { className: b('author', { theme: textTheme }), author: author, type: AuthorType.Line })),
|
|
20
|
-
url && buttonText && (React.createElement(Button, { view: "outlined", size: "xl", href: url, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|
|
22
|
+
url && buttonText && (React.createElement(Button, { view: "outlined", size: "xl", href: url, component: Link, className: b('link-button', { theme: textTheme }), onClick: handleButtonClick }, buttonText))));
|
|
21
23
|
return (React.createElement("div", { className: b({ theme: textTheme, border }), style: color ? { backgroundColor: color } : {} },
|
|
22
24
|
React.createElement("div", { key: text, className: b('content-wrapper') },
|
|
23
25
|
React.createElement("div", null,
|
package/package.json
CHANGED
|
@@ -111,6 +111,8 @@ export interface MediaVideoProps extends AnalyticsEventsBase {
|
|
|
111
111
|
controls?: MediaVideoControlsType;
|
|
112
112
|
metrika?: MetrikaVideo;
|
|
113
113
|
}
|
|
114
|
+
export interface LinkBaseProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
|
115
|
+
}
|
|
114
116
|
export interface LinkProps extends AnalyticsEventsBase, Stylable {
|
|
115
117
|
url: string;
|
|
116
118
|
text?: string;
|