@gravity-ui/blog-constructor 5.16.1-alpha.1 → 6.0.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/README.md +5 -5
- package/build/cjs/blocks/Banner/Banner.js +7 -9
- package/build/cjs/blocks/CTA/CTA.js +7 -9
- package/build/cjs/blocks/Feed/Feed.js +6 -14
- package/build/cjs/blocks/Header/Header.js +10 -14
- package/build/cjs/blocks/Media/Media.js +1 -0
- package/build/cjs/blocks/Meta/Meta.js +11 -15
- package/build/cjs/blocks/Suggest/Suggest.js +8 -11
- package/build/cjs/components/FeedHeader/components/Controls/Controls.css +19 -5
- package/build/cjs/components/FeedHeader/components/Controls/Controls.js +22 -27
- package/build/cjs/components/FeedHeader/components/Controls/customRenders.js +1 -1
- package/build/cjs/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.css +4 -1
- package/build/cjs/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.js +2 -2
- package/build/cjs/components/Paginator/Paginator.js +16 -19
- package/build/cjs/components/Paginator/components/NavigationButton.js +1 -1
- package/build/cjs/components/PostCard/PostCard.d.ts +3 -6
- package/build/cjs/components/PostCard/PostCard.js +2 -2
- package/build/cjs/components/PostInfo/PostInfo.css +8 -0
- package/build/cjs/components/PostInfo/PostInfo.d.ts +4 -10
- package/build/cjs/components/PostInfo/PostInfo.js +4 -4
- package/build/cjs/components/PostInfo/SuggestPostInfo.js +4 -1
- package/build/cjs/components/PostInfo/components/ReadingTime.js +1 -1
- package/build/cjs/components/PostInfo/components/Save.d.ts +4 -6
- package/build/cjs/components/PostInfo/components/Save.js +4 -7
- package/build/cjs/components/PostInfo/components/Sharing.d.ts +3 -5
- package/build/cjs/components/PostInfo/components/Sharing.js +4 -10
- package/build/cjs/components/Posts/Posts.js +3 -3
- package/build/cjs/components/PostsEmpty/PostsEmpty.js +2 -2
- package/build/cjs/components/PostsError/PostsError.js +3 -3
- package/build/cjs/components/PromptSignIn/PromptSignIn.js +2 -2
- package/build/cjs/components/Search/Search.css +3 -0
- package/build/cjs/components/Search/Search.js +2 -2
- package/build/cjs/constants.d.ts +2 -1
- package/build/cjs/constants.js +20 -19
- package/build/cjs/constructor/BlogConstructorProvider.js +1 -0
- package/build/cjs/containers/BlogPostPage/BlogPostPage.css +1 -1
- package/build/cjs/contexts/LocaleContext.js +2 -2
- package/build/cjs/counters/metrika.js +0 -3
- package/build/cjs/counters/utils.d.ts +1 -1
- package/build/cjs/counters/utils.js +7 -7
- package/build/cjs/i18n/index.d.ts +1 -3
- package/build/cjs/i18n/index.js +8 -10
- package/build/cjs/index.d.ts +0 -1
- package/build/cjs/index.js +1 -3
- package/build/cjs/models/common.d.ts +1 -1
- package/build/cjs/models/locale.d.ts +1 -4
- package/build/cjs/models/locale.js +1 -6
- package/build/cjs/utils/common.d.ts +15 -3
- package/build/cjs/utils/common.js +20 -19
- package/build/esm/blocks/Banner/Banner.js +8 -10
- package/build/esm/blocks/CTA/CTA.js +8 -10
- package/build/esm/blocks/Feed/Feed.js +9 -17
- package/build/esm/blocks/Header/Header.js +12 -16
- package/build/esm/blocks/Media/Media.js +1 -0
- package/build/esm/blocks/Meta/Meta.js +13 -17
- package/build/esm/blocks/Suggest/Suggest.js +9 -12
- package/build/esm/components/FeedHeader/components/Controls/Controls.css +19 -5
- package/build/esm/components/FeedHeader/components/Controls/Controls.js +25 -30
- package/build/esm/components/FeedHeader/components/Controls/customRenders.js +2 -2
- package/build/esm/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.css +4 -1
- package/build/esm/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.js +2 -2
- package/build/esm/components/Paginator/Paginator.js +18 -21
- package/build/esm/components/Paginator/components/NavigationButton.js +2 -2
- package/build/esm/components/PostCard/PostCard.d.ts +3 -6
- package/build/esm/components/PostCard/PostCard.js +2 -2
- package/build/esm/components/PostInfo/PostInfo.css +8 -0
- package/build/esm/components/PostInfo/PostInfo.d.ts +4 -10
- package/build/esm/components/PostInfo/PostInfo.js +4 -4
- package/build/esm/components/PostInfo/SuggestPostInfo.js +4 -1
- package/build/esm/components/PostInfo/components/ReadingTime.js +2 -2
- package/build/esm/components/PostInfo/components/Save.d.ts +4 -6
- package/build/esm/components/PostInfo/components/Save.js +4 -7
- package/build/esm/components/PostInfo/components/Sharing.d.ts +3 -5
- package/build/esm/components/PostInfo/components/Sharing.js +5 -11
- package/build/esm/components/Posts/Posts.js +4 -4
- package/build/esm/components/PostsEmpty/PostsEmpty.js +3 -3
- package/build/esm/components/PostsError/PostsError.js +4 -4
- package/build/esm/components/PromptSignIn/PromptSignIn.js +3 -3
- package/build/esm/components/Search/Search.css +3 -0
- package/build/esm/components/Search/Search.js +3 -3
- package/build/esm/constants.d.ts +2 -1
- package/build/esm/constants.js +19 -18
- package/build/esm/constructor/BlogConstructorProvider.js +2 -1
- package/build/esm/containers/BlogPostPage/BlogPostPage.css +1 -1
- package/build/esm/contexts/LocaleContext.js +1 -1
- package/build/esm/counters/metrika.js +0 -3
- package/build/esm/counters/utils.d.ts +1 -1
- package/build/esm/counters/utils.js +6 -6
- package/build/esm/i18n/index.d.ts +1 -3
- package/build/esm/i18n/index.js +7 -9
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.js +0 -1
- package/build/esm/models/common.d.ts +1 -1
- package/build/esm/models/locale.d.ts +1 -4
- package/build/esm/models/locale.js +0 -5
- package/build/esm/utils/common.d.ts +15 -3
- package/build/esm/utils/common.js +18 -17
- package/package.json +15 -14
- package/server/data/contentFilter.d.ts +1 -1
- package/server/data/contentFilter.js +2 -1
- package/server/data/transformPageContent.d.ts +2 -2
- package/server/data/transformPost.d.ts +7 -2
- package/server/data/transformPost.js +1 -1
- package/server/index.d.ts +1 -1
- package/server/models/common.d.ts +1 -1
- package/server/models/locale.d.ts +1 -4
- package/server/models/locale.js +1 -6
- package/styles/storybook/common.scss +8 -0
- package/styles/storybook/index.scss +1 -1
- package/styles/styles.css +115 -0
- package/styles/styles.scss +1 -0
- package/build/cjs/configure.d.ts +0 -5
- package/build/cjs/configure.js +0 -8
- package/build/esm/configure.d.ts +0 -5
- package/build/esm/configure.js +0 -4
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { useAnalytics } from '@gravity-ui/page-constructor';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
|
7
|
-
*/
|
|
8
|
-
import metrika from '../../counters/metrika';
|
|
9
|
-
import { MetrikaCounter } from '../../counters/utils';
|
|
4
|
+
import { DefaultGoalIds } from '../../constants';
|
|
5
|
+
import { AnalyticsCounter } from '../../counters/utils';
|
|
10
6
|
import { DefaultEventNames } from '../../models/common';
|
|
11
7
|
import { block } from '../../utils/cn';
|
|
12
8
|
import { NavigationButton } from './components/NavigationButton';
|
|
13
9
|
import { PaginatorItem } from './components/PaginatorItem';
|
|
14
10
|
import { ArrowType } from './types';
|
|
15
11
|
import { getPageConfigs, getPagesCount } from './utils';
|
|
12
|
+
import { prepareAnalyticsEvent } from '../../utils/common';
|
|
16
13
|
import _ from 'lodash';
|
|
17
14
|
import './Paginator.css';
|
|
18
15
|
const b = block('paginator');
|
|
@@ -37,19 +34,19 @@ export const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className,
|
|
|
37
34
|
const handleArrowClick = (type) => {
|
|
38
35
|
let newPage = page;
|
|
39
36
|
if (type === 'prev' && page > 1) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
handleAnalyticsHome();
|
|
37
|
+
const event = prepareAnalyticsEvent({
|
|
38
|
+
name: DefaultGoalIds.home,
|
|
39
|
+
counter: AnalyticsCounter.CrossSite,
|
|
40
|
+
});
|
|
41
|
+
handleAnalyticsHome(event);
|
|
45
42
|
newPage = 1;
|
|
46
43
|
}
|
|
47
44
|
else if (type === 'next' && page < pagesCount) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
const event = prepareAnalyticsEvent({
|
|
46
|
+
name: DefaultGoalIds.next,
|
|
47
|
+
counter: AnalyticsCounter.CrossSite,
|
|
48
|
+
});
|
|
49
|
+
handleAnalyticsNext(event);
|
|
53
50
|
newPage = page + 1;
|
|
54
51
|
}
|
|
55
52
|
if (newPage !== page) {
|
|
@@ -58,11 +55,11 @@ export const Paginator = ({ itemsPerPage, totalItems, maxPages, page, className,
|
|
|
58
55
|
};
|
|
59
56
|
const handlePageClick = (index) => {
|
|
60
57
|
if (index !== page && typeof index === 'number') {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
handleAnalyticsPage(
|
|
58
|
+
const event = prepareAnalyticsEvent({
|
|
59
|
+
name: DefaultGoalIds.page,
|
|
60
|
+
counter: AnalyticsCounter.CrossSite,
|
|
61
|
+
});
|
|
62
|
+
handleAnalyticsPage(event, { page: String(index) });
|
|
66
63
|
handlePageChange(index);
|
|
67
64
|
}
|
|
68
65
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Keyset,
|
|
2
|
+
import { Keyset, i18n } from '../../../i18n';
|
|
3
3
|
import { block } from '../../../utils/cn';
|
|
4
4
|
import { ArrowType } from '../types';
|
|
5
5
|
import '../Paginator.css';
|
|
6
6
|
const b = block('paginator');
|
|
7
|
-
export const NavigationButton = ({ arrowType, disabled }) => disabled ? null : (React.createElement("div", { className: b('icon') }, arrowType === ArrowType.Prev ?
|
|
7
|
+
export const NavigationButton = ({ arrowType, disabled }) => disabled ? null : (React.createElement("div", { className: b('icon') }, arrowType === ArrowType.Prev ? i18n(Keyset.ButtonBegin) : i18n(Keyset.ButtonFarther)));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
|
|
3
3
|
import { PostCardSize, PostCardTitleHeadingLevel, PostData } from '../../models/common';
|
|
4
4
|
import './PostCard.css';
|
|
5
5
|
type PostCardProps = {
|
|
@@ -8,10 +8,7 @@ type PostCardProps = {
|
|
|
8
8
|
showTag?: boolean;
|
|
9
9
|
size?: PostCardSize;
|
|
10
10
|
titleHeadingLevel?: PostCardTitleHeadingLevel;
|
|
11
|
-
|
|
12
|
-
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
|
13
|
-
*/
|
|
14
|
-
metrikaGoals?: MetrikaGoal;
|
|
11
|
+
analyticsEvents?: AnalyticsEventsProp;
|
|
15
12
|
};
|
|
16
|
-
export declare const PostCard: ({ post,
|
|
13
|
+
export declare const PostCard: ({ post, fullWidth, size, showTag, titleHeadingLevel, analyticsEvents, }: PostCardProps) => React.JSX.Element;
|
|
17
14
|
export {};
|
|
@@ -8,7 +8,7 @@ import { SuggestPostInfo } from '../PostInfo/SuggestPostInfo';
|
|
|
8
8
|
import { useAriaAttributes } from '../../hooks/useAriaAttributes';
|
|
9
9
|
import './PostCard.css';
|
|
10
10
|
const b = block('post-card');
|
|
11
|
-
export const PostCard = ({ post,
|
|
11
|
+
export const PostCard = ({ post, fullWidth = false, size = PostCardSize.SMALL, showTag = false, titleHeadingLevel = PostCardTitleHeadingLevel.H3, analyticsEvents, }) => {
|
|
12
12
|
var _a;
|
|
13
13
|
const { title: postTitle, htmlTitle, textTitle, blogPostId, id, date, readingTime, hasUserLike, likes, image, description, tags, url, } = post;
|
|
14
14
|
const title = postTitle || textTitle || htmlTitle;
|
|
@@ -34,7 +34,7 @@ export const PostCard = ({ post, metrikaGoals, fullWidth = false, size = PostCar
|
|
|
34
34
|
readingTime && readingTimeId,
|
|
35
35
|
],
|
|
36
36
|
});
|
|
37
|
-
return (React.createElement(CardBase, { url: url,
|
|
37
|
+
return (React.createElement(CardBase, { url: url, analyticsEvents: analyticsEvents, className: b('card', { fullWidth }), extraProps: ariaAttributes },
|
|
38
38
|
React.createElement(CardBase.Header, { image: image, className: b('header', { fullWidth }) },
|
|
39
39
|
React.createElement("div", { className: b('image-container'), "data-qa": "blog-suggest-header" })),
|
|
40
40
|
React.createElement(CardBase.Content, null,
|
|
@@ -17,6 +17,14 @@ unpredictable css rules order in build */
|
|
|
17
17
|
font-size: var(--g-text-body-3-font-size);
|
|
18
18
|
line-height: var(--g-text-body-3-line-height);
|
|
19
19
|
}
|
|
20
|
+
.bc-post-info__item_save {
|
|
21
|
+
background: none;
|
|
22
|
+
color: inherit;
|
|
23
|
+
border: none;
|
|
24
|
+
padding: 0;
|
|
25
|
+
font: inherit;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
20
28
|
.bc-post-info__item:last-child {
|
|
21
29
|
font-size: var(--g-text-body-2-font-size);
|
|
22
30
|
line-height: var(--g-text-body-2-line-height);
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
|
|
2
3
|
import { PostData, QAProps } from '../../models/common';
|
|
3
4
|
import './PostInfo.css';
|
|
4
|
-
export type BlogMetrikaGoals = {
|
|
5
|
-
sharing?: string;
|
|
6
|
-
save?: string;
|
|
7
|
-
};
|
|
8
5
|
type PostInfoProps = QAProps & {
|
|
9
6
|
postId: PostData['id'];
|
|
10
7
|
readingTime: PostData['readingTime'];
|
|
11
8
|
date: PostData['date'];
|
|
12
9
|
theme?: 'light' | 'dark';
|
|
13
|
-
|
|
14
|
-
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
|
15
|
-
*/
|
|
16
|
-
metrikaGoals?: BlogMetrikaGoals;
|
|
10
|
+
analyticsEventsContainer?: Record<string, AnalyticsEventsProp>;
|
|
17
11
|
};
|
|
18
12
|
/**
|
|
19
13
|
* Blog post info panel component
|
|
@@ -22,10 +16,10 @@ type PostInfoProps = QAProps & {
|
|
|
22
16
|
* @param readingTime - post reading time
|
|
23
17
|
* @param date - post create date
|
|
24
18
|
* @param theme - theme name
|
|
25
|
-
* @param metrikaGoals - metrika goals name
|
|
26
19
|
* @param qa - test-attr
|
|
20
|
+
* @param analyticsEventsContainer - a map of records with a single or collection of objects detailing analytics events
|
|
27
21
|
*
|
|
28
22
|
* @returns jsx
|
|
29
23
|
*/
|
|
30
|
-
export declare const PostInfo: ({ date, readingTime, postId, theme,
|
|
24
|
+
export declare const PostInfo: ({ date, readingTime, postId, theme, qa, analyticsEventsContainer, }: PostInfoProps) => React.JSX.Element;
|
|
31
25
|
export {};
|
|
@@ -15,17 +15,17 @@ const b = block('post-info');
|
|
|
15
15
|
* @param readingTime - post reading time
|
|
16
16
|
* @param date - post create date
|
|
17
17
|
* @param theme - theme name
|
|
18
|
-
* @param metrikaGoals - metrika goals name
|
|
19
18
|
* @param qa - test-attr
|
|
19
|
+
* @param analyticsEventsContainer - a map of records with a single or collection of objects detailing analytics events
|
|
20
20
|
*
|
|
21
21
|
* @returns jsx
|
|
22
22
|
*/
|
|
23
|
-
export const PostInfo = ({ date, readingTime, postId, theme = 'light',
|
|
23
|
+
export const PostInfo = ({ date, readingTime, postId, theme = 'light', qa, analyticsEventsContainer, }) => {
|
|
24
24
|
const { likes } = useContext(PostPageContext);
|
|
25
25
|
const qaAttributes = getQaAttributes(qa, 'date', 'reading-time', 'save');
|
|
26
26
|
return (React.createElement("div", { className: b('container', { theme }) },
|
|
27
27
|
date && React.createElement(Date, { date: date, qa: qaAttributes.date }),
|
|
28
28
|
readingTime && React.createElement(ReadingTime, { readingTime: readingTime, qa: qaAttributes.readingTime }),
|
|
29
|
-
React.createElement(Sharing, {
|
|
30
|
-
likes && (React.createElement(Save, { postId: postId, title: likes.likesCount, hasUserLike: likes.hasUserLike, handleUserLike: likes.handleUserLike,
|
|
29
|
+
React.createElement(Sharing, { theme: theme, analyticsEvents: analyticsEventsContainer === null || analyticsEventsContainer === void 0 ? void 0 : analyticsEventsContainer.sharing }),
|
|
30
|
+
likes && (React.createElement(Save, { postId: postId, title: likes.likesCount, hasUserLike: likes.hasUserLike, handleUserLike: likes.handleUserLike, analyticsEvents: analyticsEventsContainer === null || analyticsEventsContainer === void 0 ? void 0 : analyticsEventsContainer.save, theme: theme, qa: qaAttributes.save }))));
|
|
31
31
|
};
|
|
@@ -5,8 +5,11 @@ import { block } from '../../utils/cn';
|
|
|
5
5
|
import { Date } from './components/Date';
|
|
6
6
|
import { ReadingTime } from './components/ReadingTime';
|
|
7
7
|
import { Save } from './components/Save';
|
|
8
|
+
import { prepareAnalyticsEvent } from '../../utils/common';
|
|
9
|
+
import { DefaultGoalIds } from '../../constants';
|
|
8
10
|
import './PostInfo.css';
|
|
9
11
|
const b = block('post-info');
|
|
12
|
+
const saveEvents = prepareAnalyticsEvent({ name: DefaultGoalIds.saveSuggest });
|
|
10
13
|
/**
|
|
11
14
|
* Suggest blog card info component
|
|
12
15
|
*
|
|
@@ -34,5 +37,5 @@ export const SuggestPostInfo = ({ postId, date, readingTime, likes, size = PostC
|
|
|
34
37
|
React.createElement("div", { className: b('suggest-container') },
|
|
35
38
|
date && React.createElement(Date, { date: date, size: size, id: dateId }),
|
|
36
39
|
readingTime && (React.createElement(ReadingTime, { readingTime: readingTime, size: size, id: readingTimeId }))),
|
|
37
|
-
likes && postId && (React.createElement(Save, { postId: postId, title: likesCount, hasUserLike: hasUserLike, handleUserLike: handleLike, size: size, qa: qa }))));
|
|
40
|
+
likes && postId && (React.createElement(Save, { postId: postId, title: likesCount, analyticsEvents: saveEvents, hasUserLike: hasUserLike, handleUserLike: handleLike, size: size, qa: qa }))));
|
|
38
41
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
|
3
|
-
import { Keyset,
|
|
3
|
+
import { Keyset, i18n } from '../../../i18n';
|
|
4
4
|
import { Time } from '../../../icons/Time';
|
|
5
5
|
import { block } from '../../../utils/cn';
|
|
6
6
|
import '../PostInfo.css';
|
|
@@ -9,4 +9,4 @@ const ICON_SIZE = 16;
|
|
|
9
9
|
export const ReadingTime = ({ readingTime, size = 's', id, qa }) => (React.createElement("div", { className: b('item', { size }), id: id, "data-qa": qa },
|
|
10
10
|
React.createElement("span", { className: b('icon') },
|
|
11
11
|
React.createElement(Icon, { data: Time, size: ICON_SIZE, className: b('icon-color') })),
|
|
12
|
-
|
|
12
|
+
i18n(Keyset.ContextReadingTime, { count: readingTime })));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
|
|
2
3
|
import { QAProps } from '../../../models/common';
|
|
3
4
|
import '../PostInfo.css';
|
|
4
5
|
type SaveProps = QAProps & {
|
|
@@ -7,11 +8,8 @@ type SaveProps = QAProps & {
|
|
|
7
8
|
hasUserLike: boolean;
|
|
8
9
|
handleUserLike: () => void;
|
|
9
10
|
theme?: 'light' | 'dark';
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
|
12
|
-
*/
|
|
13
|
-
metrikaGoal?: string;
|
|
14
11
|
size?: 's' | 'm';
|
|
12
|
+
analyticsEvents?: AnalyticsEventsProp;
|
|
15
13
|
};
|
|
16
14
|
/**
|
|
17
15
|
* Components for 'save' blog UI-component
|
|
@@ -19,11 +17,11 @@ type SaveProps = QAProps & {
|
|
|
19
17
|
* @param title - post title
|
|
20
18
|
* @param postId - post id
|
|
21
19
|
* @param hasUserLike - flag what blog has like from current user
|
|
22
|
-
* @param metrikaGoal - metrika goal name
|
|
23
20
|
* @param qa - test-attr
|
|
24
21
|
* @param size - text size
|
|
22
|
+
* @param analyticsEvents - a single or collection of objects detailing analytics events
|
|
25
23
|
*
|
|
26
24
|
* @returns jsx
|
|
27
25
|
*/
|
|
28
|
-
export declare const Save: ({ title, postId, hasUserLike, handleUserLike,
|
|
26
|
+
export declare const Save: ({ title, postId, hasUserLike, handleUserLike, size, theme, qa, analyticsEvents, }: SaveProps) => React.JSX.Element;
|
|
29
27
|
export {};
|
|
@@ -2,8 +2,6 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { useAnalytics } from '@gravity-ui/page-constructor';
|
|
3
3
|
import { Icon } from '@gravity-ui/uikit';
|
|
4
4
|
import { LikesContext } from '../../../contexts/LikesContext';
|
|
5
|
-
import metrika from '../../../counters/metrika';
|
|
6
|
-
import { MetrikaCounter } from '../../../counters/utils';
|
|
7
5
|
import { Save as SaveIcon } from '../../../icons/Save';
|
|
8
6
|
import { SaveFilled } from '../../../icons/SaveFilled';
|
|
9
7
|
import { DefaultEventNames } from '../../../models/common';
|
|
@@ -18,17 +16,17 @@ const b = block('post-info');
|
|
|
18
16
|
* @param title - post title
|
|
19
17
|
* @param postId - post id
|
|
20
18
|
* @param hasUserLike - flag what blog has like from current user
|
|
21
|
-
* @param metrikaGoal - metrika goal name
|
|
22
19
|
* @param qa - test-attr
|
|
23
20
|
* @param size - text size
|
|
21
|
+
* @param analyticsEvents - a single or collection of objects detailing analytics events
|
|
24
22
|
*
|
|
25
23
|
* @returns jsx
|
|
26
24
|
*/
|
|
27
|
-
export const Save = ({ title, postId, hasUserLike, handleUserLike,
|
|
25
|
+
export const Save = ({ title, postId, hasUserLike, handleUserLike, size, theme, qa, analyticsEvents, }) => {
|
|
28
26
|
const { toggleLike, isSignedInUser, requireSignIn } = useContext(LikesContext);
|
|
29
27
|
const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
|
|
30
28
|
const isLikeable = Boolean(toggleLike);
|
|
31
|
-
return (React.createElement("
|
|
29
|
+
return (React.createElement("button", { className: b('item', { size, save: true }), onClick: (event) => {
|
|
32
30
|
// both preventDefault and stopImmediatePropagation required to work properly
|
|
33
31
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
|
34
32
|
event.preventDefault();
|
|
@@ -43,8 +41,7 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
|
|
|
43
41
|
}
|
|
44
42
|
postLikeStatus(postId, Boolean(hasUserLike));
|
|
45
43
|
handleUserLike();
|
|
46
|
-
|
|
47
|
-
handleAnalytics();
|
|
44
|
+
handleAnalytics(analyticsEvents);
|
|
48
45
|
}, "data-qa": qa },
|
|
49
46
|
React.createElement("div", { className: b('content', { cursor: isLikeable, theme }) },
|
|
50
47
|
React.createElement("span", { className: b('icon') },
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { AnalyticsEventsProp } from '@gravity-ui/page-constructor';
|
|
2
3
|
import '../PostInfo.css';
|
|
3
4
|
type SharingProps = {
|
|
4
5
|
theme?: 'light' | 'dark';
|
|
5
|
-
|
|
6
|
-
* @deprecated Metrika will be deleted after launch of analyticsEvents
|
|
7
|
-
*/
|
|
8
|
-
metrikaGoal?: string;
|
|
6
|
+
analyticsEvents?: AnalyticsEventsProp;
|
|
9
7
|
};
|
|
10
|
-
export declare const Sharing: ({ theme,
|
|
8
|
+
export declare const Sharing: ({ theme, analyticsEvents }: SharingProps) => React.JSX.Element;
|
|
11
9
|
export {};
|
|
@@ -4,28 +4,22 @@ import { useAnalytics } from '@gravity-ui/page-constructor';
|
|
|
4
4
|
import { MobileContext } from '../../../contexts/MobileContext';
|
|
5
5
|
import { PostPageContext } from '../../../contexts/PostPageContext';
|
|
6
6
|
import { RouterContext } from '../../../contexts/RouterContext';
|
|
7
|
-
import
|
|
8
|
-
import { MetrikaCounter } from '../../../counters/utils';
|
|
9
|
-
import { Keyset, i18 } from '../../../i18n';
|
|
7
|
+
import { Keyset, i18n } from '../../../i18n';
|
|
10
8
|
import { ShareArrowUp } from '../../../icons/ShareArrowUp';
|
|
11
9
|
import { DefaultEventNames } from '../../../models/common';
|
|
12
10
|
import { block } from '../../../utils/cn';
|
|
13
11
|
import { getAbsolutePath } from '../../../utils/common';
|
|
14
12
|
import '../PostInfo.css';
|
|
15
13
|
const b = block('post-info');
|
|
16
|
-
export const Sharing = ({ theme,
|
|
14
|
+
export const Sharing = ({ theme, analyticsEvents }) => {
|
|
17
15
|
const router = useContext(RouterContext);
|
|
18
16
|
const isMobile = useContext(MobileContext);
|
|
19
17
|
const { shareOptions } = useContext(PostPageContext);
|
|
20
18
|
const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
|
|
21
|
-
const handleMetrika = useCallback(() => {
|
|
22
|
-
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
|
23
|
-
}, [metrikaGoal]);
|
|
24
19
|
const handleAnalytics = useCallback(() => {
|
|
25
|
-
handleAnalyticsGlobal();
|
|
26
|
-
|
|
27
|
-
}, [handleAnalyticsGlobal, handleMetrika]);
|
|
20
|
+
handleAnalyticsGlobal(analyticsEvents);
|
|
21
|
+
}, [analyticsEvents, handleAnalyticsGlobal]);
|
|
28
22
|
return (React.createElement("div", { className: b('item') },
|
|
29
23
|
React.createElement("div", { className: b('icon') },
|
|
30
|
-
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: ShareLayoutDirection.Column, buttonTitle:
|
|
24
|
+
React.createElement(SharePopover, { url: getAbsolutePath(router), className: b('share'), iconClass: b('share-icon'), switcherClassName: b('switcher', { theme }), tooltipClassName: b('popup'), useWebShareApi: isMobile, direction: ShareLayoutDirection.Column, buttonTitle: i18n(Keyset.ActionShare), customIcon: ShareArrowUp, placement: "bottom", openByHover: false, shareOptions: shareOptions, onClick: handleAnalytics }))));
|
|
31
25
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardLayoutBlock } from '@gravity-ui/page-constructor';
|
|
3
3
|
import { Button } from '@gravity-ui/uikit';
|
|
4
|
-
import { Keyset,
|
|
4
|
+
import { Keyset, i18n } from '../../i18n';
|
|
5
5
|
import { PostCardSize, PostCardTitleHeadingLevel } from '../../models/common';
|
|
6
6
|
import { block } from '../../utils/cn';
|
|
7
7
|
import { Paginator } from '../Paginator/Paginator';
|
|
@@ -22,9 +22,9 @@ export const Posts = ({ containerId, pinnedPostOnPage, currentPage, postsOnPage,
|
|
|
22
22
|
? PostCardTitleHeadingLevel.H3
|
|
23
23
|
: PostCardTitleHeadingLevel.H2 }))))) : (React.createElement(PostsEmpty, null))),
|
|
24
24
|
React.createElement("div", { className: b('pagination') },
|
|
25
|
-
Boolean(isShowMoreVisible && (postsOnPage === null || postsOnPage === void 0 ? void 0 : postsOnPage.length)) && (React.createElement(Button, { view: "outlined", size: "xl", className: b('more-button'), onClick: handleShowMore },
|
|
25
|
+
Boolean(isShowMoreVisible && (postsOnPage === null || postsOnPage === void 0 ? void 0 : postsOnPage.length)) && (React.createElement(Button, { view: "outlined", size: "xl", className: b('more-button'), onClick: handleShowMore }, i18n(Keyset.ActionLoadMore))),
|
|
26
26
|
errorShowMore && (React.createElement("div", { className: b('error-show-more') },
|
|
27
|
-
React.createElement("div", null,
|
|
28
|
-
React.createElement("div", null,
|
|
27
|
+
React.createElement("div", null, i18n(Keyset.ErrorTitle)),
|
|
28
|
+
React.createElement("div", null, i18n(Keyset.PostLoadError)))),
|
|
29
29
|
Boolean(currentPage && postCountOnPage) && (React.createElement("div", { className: b('paginator') },
|
|
30
30
|
React.createElement(Paginator, { onPageChange: handlePageChange, page: currentPage, totalItems: postCountOnPage, itemsPerPage: perPageInQuery, maxPages: Infinity, pageCountForShowSupportButtons: pageCountForShowSupportButtons, queryParams: queryParams }))))));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Keyset,
|
|
2
|
+
import { Keyset, i18n } from '../../i18n';
|
|
3
3
|
import { block } from '../../utils/cn';
|
|
4
4
|
import './PostsEmpty.css';
|
|
5
5
|
const b = block('posts-empty');
|
|
6
6
|
export const PostsEmpty = () => (React.createElement("div", { className: b('container') },
|
|
7
|
-
React.createElement("div", { className: b('title') },
|
|
8
|
-
React.createElement("div", { className: b('subtitle') },
|
|
7
|
+
React.createElement("div", { className: b('title') }, i18n(Keyset.TitleEmptyContainer)),
|
|
8
|
+
React.createElement("div", { className: b('subtitle') }, i18n(Keyset.ContextEmptyContainer))));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
|
3
|
-
import { Keyset,
|
|
3
|
+
import { Keyset, i18n } from '../../i18n';
|
|
4
4
|
import { block } from '../../utils/cn';
|
|
5
5
|
import './PostError.css';
|
|
6
6
|
const b = block('posts-error');
|
|
7
7
|
export const PostsError = ({ onButtonClick }) => {
|
|
8
8
|
const handleClick = () => (onButtonClick ? onButtonClick() : window.location.reload());
|
|
9
9
|
return (React.createElement("div", { className: b('container') },
|
|
10
|
-
React.createElement("div", { className: b('title') },
|
|
11
|
-
React.createElement("div", { className: b('subtitle') },
|
|
10
|
+
React.createElement("div", { className: b('title') }, i18n(Keyset.ErrorTitle)),
|
|
11
|
+
React.createElement("div", { className: b('subtitle') }, i18n(Keyset.PostLoadError)),
|
|
12
12
|
React.createElement("div", { className: b('button') },
|
|
13
|
-
React.createElement(Button, { size: "xl", view: "outlined", onClick: handleClick },
|
|
13
|
+
React.createElement(Button, { size: "xl", view: "outlined", onClick: handleClick }, i18n(Keyset.ActionTryAgain)))));
|
|
14
14
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Keyset,
|
|
3
|
+
import { Keyset, i18n } from '../../i18n';
|
|
4
4
|
import { Prompt } from '../Prompt/Prompt';
|
|
5
5
|
/**
|
|
6
6
|
* Authentication Popup that appears when user action requires login
|
|
7
7
|
* @returns {JSX|null}
|
|
8
8
|
*/
|
|
9
9
|
export const PromptSignIn = (_a) => {
|
|
10
|
-
var { text =
|
|
10
|
+
var { text = i18n(Keyset.PromptSignInOnLike), onClickSignIn = () => alert(i18n(Keyset.SignIn)), actions = [
|
|
11
11
|
{
|
|
12
|
-
children:
|
|
12
|
+
children: i18n(Keyset.SignIn),
|
|
13
13
|
onClick: onClickSignIn,
|
|
14
14
|
size: 'l',
|
|
15
15
|
},
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { Icon, TextInput } from '@gravity-ui/uikit';
|
|
3
3
|
import lodashDebounce from 'lodash/debounce';
|
|
4
4
|
import { useIsIPhone } from '../../hooks/useIsIPhone';
|
|
5
|
-
import { Keyset,
|
|
5
|
+
import { Keyset, i18n } from '../../i18n';
|
|
6
6
|
import { Close } from '../../icons/Close';
|
|
7
7
|
import { SearchIcon } from '../../icons/SearchIcon';
|
|
8
8
|
import { block } from '../../utils/cn';
|
|
@@ -17,7 +17,7 @@ const AUTOFOCUS_TIMEOUT = 0;
|
|
|
17
17
|
*
|
|
18
18
|
* @returns {JSX|null}
|
|
19
19
|
*/
|
|
20
|
-
export const Search = ({ className, initialValue, onSubmit, debounce = 300, placeholder =
|
|
20
|
+
export const Search = ({ className, initialValue, onSubmit, debounce = 300, placeholder = i18n(Keyset.Search), size = 'm', autoFocus = false, value: externalValue, }) => {
|
|
21
21
|
const handleChange = lodashDebounce(onSubmit, debounce);
|
|
22
22
|
const [value, setValue] = useState(initialValue);
|
|
23
23
|
const inputRef = useRef(null);
|
|
@@ -42,7 +42,7 @@ export const Search = ({ className, initialValue, onSubmit, debounce = 300, plac
|
|
|
42
42
|
onSubmit('');
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
return (React.createElement("
|
|
45
|
+
return (React.createElement("button", { className: b('input-icon'), onClick: handleClick },
|
|
46
46
|
React.createElement(Icon, { size: iconSize, data: iconData })));
|
|
47
47
|
}, [handleChange, onSubmit, value]);
|
|
48
48
|
return (React.createElement("div", { className: b({ size }, className) },
|
package/build/esm/constants.d.ts
CHANGED
|
@@ -9,13 +9,14 @@ export declare const BREAKPOINTS: {
|
|
|
9
9
|
export declare const DEFAULT_THEME = "light";
|
|
10
10
|
export declare const UIKIT_ROOT_CLASS = "g-root";
|
|
11
11
|
export declare const UIKIT_THEME_LIGHT_CLASS: string;
|
|
12
|
-
export declare enum
|
|
12
|
+
export declare enum DefaultGoalIds {
|
|
13
13
|
shareTop = "SITE_BLOG_SHARE-TOP_CLICK",
|
|
14
14
|
shareBottom = "SITE_BLOG_SHARE-BOTTOM_CLICK",
|
|
15
15
|
breadcrumbsTop = "SITE_BLOG_BREADCRUMBS-TOP_CLICK",
|
|
16
16
|
breadcrumbsBottom = "SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK",
|
|
17
17
|
saveTop = "SITE_BLOG_SAVE-TOP_CLICK",
|
|
18
18
|
saveBottom = "SITE_BLOG_SAVE-BOTTOM_CLICK",
|
|
19
|
+
saveSuggest = "SITE_BLOG_SAVE-SUGGEST_CLICK",
|
|
19
20
|
suggest = "SITE_BLOG_INTERESTING-CARD_CLICK",
|
|
20
21
|
bannerCommon = "SITE_BLOG_TEXT-BANNER_CLICK",
|
|
21
22
|
cta = "SITE_BLOG_CTA_CLICK",
|
package/build/esm/constants.js
CHANGED
|
@@ -9,24 +9,25 @@ export const BREAKPOINTS = {
|
|
|
9
9
|
export const DEFAULT_THEME = 'light';
|
|
10
10
|
export const UIKIT_ROOT_CLASS = 'g-root';
|
|
11
11
|
export const UIKIT_THEME_LIGHT_CLASS = `${UIKIT_ROOT_CLASS}_theme_${DEFAULT_THEME}`;
|
|
12
|
-
export var
|
|
13
|
-
(function (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
export var DefaultGoalIds;
|
|
13
|
+
(function (DefaultGoalIds) {
|
|
14
|
+
DefaultGoalIds["shareTop"] = "SITE_BLOG_SHARE-TOP_CLICK";
|
|
15
|
+
DefaultGoalIds["shareBottom"] = "SITE_BLOG_SHARE-BOTTOM_CLICK";
|
|
16
|
+
DefaultGoalIds["breadcrumbsTop"] = "SITE_BLOG_BREADCRUMBS-TOP_CLICK";
|
|
17
|
+
DefaultGoalIds["breadcrumbsBottom"] = "SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK";
|
|
18
|
+
DefaultGoalIds["saveTop"] = "SITE_BLOG_SAVE-TOP_CLICK";
|
|
19
|
+
DefaultGoalIds["saveBottom"] = "SITE_BLOG_SAVE-BOTTOM_CLICK";
|
|
20
|
+
DefaultGoalIds["saveSuggest"] = "SITE_BLOG_SAVE-SUGGEST_CLICK";
|
|
21
|
+
DefaultGoalIds["suggest"] = "SITE_BLOG_INTERESTING-CARD_CLICK";
|
|
22
|
+
DefaultGoalIds["bannerCommon"] = "SITE_BLOG_TEXT-BANNER_CLICK";
|
|
23
|
+
DefaultGoalIds["cta"] = "SITE_BLOG_CTA_CLICK";
|
|
24
|
+
DefaultGoalIds["tag"] = "SITE_BLOG_THEME-SELECTOR_CLCK";
|
|
25
|
+
DefaultGoalIds["service"] = "SITE_BLOG_SERVICE-SELECTOR_CLCK";
|
|
26
|
+
DefaultGoalIds["showMore"] = "SITE_BLOG-PAGINATION_SHOW-MORE_CLCK";
|
|
27
|
+
DefaultGoalIds["next"] = "SITE_BLOG-PAGINATION_NEXT_CLCK";
|
|
28
|
+
DefaultGoalIds["home"] = "SITE_BLOG-PAGINATION_HOME_CLCK";
|
|
29
|
+
DefaultGoalIds["page"] = "SITE_BLOG-PAGINATION_PAGE-NMBR_CLCK";
|
|
30
|
+
})(DefaultGoalIds || (DefaultGoalIds = {}));
|
|
30
31
|
export const DEFAULT_PADDINGS = {
|
|
31
32
|
[PaddingsDirections.bottom]: 'l',
|
|
32
33
|
[PaddingsDirections.top]: 'xs',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
|
-
import { AnalyticsContext } from '@gravity-ui/page-constructor';
|
|
2
|
+
import { AnalyticsContext, ThemeContext, } from '@gravity-ui/page-constructor';
|
|
3
3
|
import { DEFAULT_THEME } from '../constants';
|
|
4
4
|
import { DeviceContext } from '../contexts/DeviceContext';
|
|
5
5
|
import { LocaleContext } from '../contexts/LocaleContext';
|
|
@@ -10,6 +10,7 @@ import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
|
|
|
10
10
|
export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, settings = {}, children, }) => {
|
|
11
11
|
const context = [
|
|
12
12
|
React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
|
|
13
|
+
React.createElement(ThemeContext.Provider, { value: { theme: theme }, key: "pc-theme" }),
|
|
13
14
|
React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
|
|
14
15
|
React.createElement(RouterContext.Provider, { value: router, key: "router-context" }),
|
|
15
16
|
React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})(
|
|
1
|
+
export var AnalyticsCounter;
|
|
2
|
+
(function (AnalyticsCounter) {
|
|
3
|
+
AnalyticsCounter["Main"] = "main";
|
|
4
|
+
AnalyticsCounter["CrossSite"] = "cross-site";
|
|
5
|
+
AnalyticsCounter["Scale"] = "scale";
|
|
6
|
+
})(AnalyticsCounter || (AnalyticsCounter = {}));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { I18N } from '@gravity-ui/i18n';
|
|
2
|
-
export declare const i18n: I18N;
|
|
3
1
|
export declare enum Keyset {
|
|
4
2
|
Title = "title",
|
|
5
3
|
TitleBreadcrumbs = "title_breadcrumbs",
|
|
@@ -21,4 +19,4 @@ export declare enum Keyset {
|
|
|
21
19
|
PromptSignInOnLike = "prompt_sign_in_on_like",
|
|
22
20
|
SignIn = "Sign In"
|
|
23
21
|
}
|
|
24
|
-
export declare const
|
|
22
|
+
export declare const i18n: (key: Keyset, params?: import("@gravity-ui/i18n").Params | undefined) => string;
|