@gravity-ui/blog-constructor 2.1.0-alpha.0 → 2.1.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/components/PostInfo/components/Sharing.js +16 -9
- package/build/cjs/models/common.d.ts +3 -0
- package/build/cjs/models/common.js +6 -2
- package/build/esm/components/PostInfo/components/Sharing.js +17 -10
- package/build/esm/models/common.d.ts +3 -0
- package/build/esm/models/common.js +5 -1
- package/package.json +1 -1
- package/server/models/common.d.ts +3 -0
- package/server/models/common.js +6 -2
@@ -27,28 +27,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Sharing = void 0;
|
30
|
-
const
|
30
|
+
const useAnalytics_1 = require("@gravity-ui/page-constructor/build/esm/hooks/useAnalytics");
|
31
31
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
|
+
const react_1 = __importStar(require("react"));
|
32
33
|
const MobileContext_1 = require("../../../contexts/MobileContext");
|
33
|
-
const RouterContext_1 = require("../../../contexts/RouterContext");
|
34
34
|
const PostPageContext_1 = require("../../../contexts/PostPageContext");
|
35
|
+
const RouterContext_1 = require("../../../contexts/RouterContext");
|
36
|
+
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
37
|
+
const utils_1 = require("../../../counters/utils");
|
35
38
|
const i18n_1 = require("../../../i18n");
|
36
|
-
const
|
39
|
+
const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
|
40
|
+
const common_1 = require("../../../models/common");
|
37
41
|
const cn_1 = require("../../../utils/cn");
|
38
|
-
const
|
42
|
+
const common_2 = require("../../../utils/common");
|
39
43
|
// @ts-ignore
|
40
|
-
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
41
|
-
const ShareArrowUp_1 = require("../../../icons/ShareArrowUp");
|
42
44
|
const b = (0, cn_1.block)('post-info');
|
43
45
|
const Sharing = ({ theme, metrikaGoal }) => {
|
44
46
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
45
47
|
const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
|
46
48
|
const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
|
47
|
-
const
|
49
|
+
const handleAnalyticsGlobal = (0, useAnalytics_1.useAnalytics)(common_1.DefaultEventNames.ShareButton);
|
50
|
+
const handleMetrika = (0, react_1.useCallback)(() => {
|
48
51
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
49
|
-
};
|
52
|
+
}, [metrikaGoal]);
|
53
|
+
const handleAnalytics = (0, react_1.useCallback)(() => {
|
54
|
+
handleAnalyticsGlobal();
|
55
|
+
handleMetrika();
|
56
|
+
}, [handleAnalyticsGlobal, handleMetrika]);
|
50
57
|
return (react_1.default.createElement("div", { className: b('item') },
|
51
58
|
react_1.default.createElement("span", { className: b('icon') },
|
52
|
-
react_1.default.createElement(uikit_1.SharePopover, { url: (0,
|
59
|
+
react_1.default.createElement(uikit_1.SharePopover, { url: (0, common_2.getAbsolutePath)(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: (0, i18n_1.i18)(i18n_1.Keyset.ActionShare), customIcon: ShareArrowUp_1.ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
|
53
60
|
};
|
54
61
|
exports.Sharing = Sharing;
|
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
149
|
export type SetQueryType = (params: Query, options?: {
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
|
+
export declare enum DefaultEventNames {
|
153
|
+
ShareButton = "share-button-click"
|
154
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BlockType = exports.Theme = void 0;
|
3
|
+
exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,4 +19,8 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
+
var DefaultEventNames;
|
24
|
+
(function (DefaultEventNames) {
|
25
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
@@ -1,25 +1,32 @@
|
|
1
|
-
import
|
1
|
+
import { useAnalytics } from '@gravity-ui/page-constructor/build/esm/hooks/useAnalytics';
|
2
2
|
import { SharePopover } from '@gravity-ui/uikit';
|
3
|
+
import React, { useCallback, useContext } from 'react';
|
3
4
|
import { MobileContext } from '../../../contexts/MobileContext';
|
4
|
-
import { RouterContext } from '../../../contexts/RouterContext';
|
5
5
|
import { PostPageContext } from '../../../contexts/PostPageContext';
|
6
|
-
import {
|
7
|
-
import { getAbsolutePath } from '../../../utils/common';
|
8
|
-
import { block } from '../../../utils/cn';
|
9
|
-
import { MetrikaCounter } from '../../../counters/utils';
|
10
|
-
// @ts-ignore
|
6
|
+
import { RouterContext } from '../../../contexts/RouterContext';
|
11
7
|
import metrika from '../../../counters/metrika.js';
|
8
|
+
import { MetrikaCounter } from '../../../counters/utils';
|
9
|
+
import { Keyset, i18 } from '../../../i18n';
|
12
10
|
import { ShareArrowUp } from '../../../icons/ShareArrowUp';
|
11
|
+
import { DefaultEventNames } from '../../../models/common';
|
12
|
+
import { block } from '../../../utils/cn';
|
13
|
+
import { getAbsolutePath } from '../../../utils/common';
|
14
|
+
// @ts-ignore
|
13
15
|
import '../PostInfo.css';
|
14
16
|
const b = block('post-info');
|
15
17
|
export const Sharing = ({ theme, metrikaGoal }) => {
|
16
18
|
const router = useContext(RouterContext);
|
17
19
|
const isMobile = useContext(MobileContext);
|
18
20
|
const { shareOptions } = useContext(PostPageContext);
|
19
|
-
const
|
21
|
+
const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
|
22
|
+
const handleMetrika = useCallback(() => {
|
20
23
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
21
|
-
};
|
24
|
+
}, [metrikaGoal]);
|
25
|
+
const handleAnalytics = useCallback(() => {
|
26
|
+
handleAnalyticsGlobal();
|
27
|
+
handleMetrika();
|
28
|
+
}, [handleAnalyticsGlobal, handleMetrika]);
|
22
29
|
return (React.createElement("div", { className: b('item') },
|
23
30
|
React.createElement("span", { className: b('icon') },
|
24
|
-
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika:
|
31
|
+
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: 'column', buttonTitle: i18(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, handleMetrika: handleAnalytics }))));
|
25
32
|
};
|
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
149
|
export type SetQueryType = (params: Query, options?: {
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
|
+
export declare enum DefaultEventNames {
|
153
|
+
ShareButton = "share-button-click"
|
154
|
+
}
|
@@ -16,4 +16,8 @@ export var BlockType;
|
|
16
16
|
BlockType["Suggest"] = "blog-suggest-block";
|
17
17
|
BlockType["Meta"] = "blog-meta-block";
|
18
18
|
BlockType["Feed"] = "blog-feed-block";
|
19
|
-
})(BlockType || (BlockType = {}));
|
19
|
+
})(BlockType || (BlockType = {}));
|
20
|
+
export var DefaultEventNames;
|
21
|
+
(function (DefaultEventNames) {
|
22
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
23
|
+
})(DefaultEventNames || (DefaultEventNames = {}));
|
package/package.json
CHANGED
@@ -149,3 +149,6 @@ export type HandleChangeQueryParams = (params: Query) => void;
|
|
149
149
|
export type SetQueryType = (params: Query, options?: {
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
|
+
export declare enum DefaultEventNames {
|
153
|
+
ShareButton = "share-button-click"
|
154
|
+
}
|
package/server/models/common.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BlockType = exports.Theme = void 0;
|
3
|
+
exports.DefaultEventNames = exports.BlockType = exports.Theme = void 0;
|
4
4
|
var Theme;
|
5
5
|
(function (Theme) {
|
6
6
|
Theme["Light"] = "light";
|
@@ -19,4 +19,8 @@ var BlockType;
|
|
19
19
|
BlockType["Suggest"] = "blog-suggest-block";
|
20
20
|
BlockType["Meta"] = "blog-meta-block";
|
21
21
|
BlockType["Feed"] = "blog-feed-block";
|
22
|
-
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
22
|
+
})(BlockType = exports.BlockType || (exports.BlockType = {}));
|
23
|
+
var DefaultEventNames;
|
24
|
+
(function (DefaultEventNames) {
|
25
|
+
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|