@@ -164,12 +159,12 @@ export const Controls = ({
options={tagsItems}
defaultValue={[tagInitial] as string[]}
onUpdate={handleTagSelect}
- placeholder={i18(Keyset.AllTags)}
+ placeholder={i18n(Keyset.AllTags)}
popupClassName={b('popup', {isMobile})}
renderControl={renderSwitcher({
initial: [tagInitial],
list: tagsItems,
- defaultLabel: i18(Keyset.AllTags),
+ defaultLabel: i18n(Keyset.AllTags),
})}
disablePortal
virtualizationThreshold={VIRTUALIZATION_THRESHOLD}
@@ -190,11 +185,11 @@ export const Controls = ({
defaultValue={servicesItems}
popupClassName={b('popup', {isMobile})}
onUpdate={handleServicesSelect}
- placeholder={i18(Keyset.AllServices)}
+ placeholder={i18n(Keyset.AllServices)}
renderControl={renderSwitcher({
initial: servicesItems,
list: services,
- defaultLabel: i18(Keyset.AllServices),
+ defaultLabel: i18n(Keyset.AllServices),
})}
virtualizationThreshold={VIRTUALIZATION_THRESHOLD}
renderOption={renderOption}
@@ -211,7 +206,7 @@ export const Controls = ({
onClick={handleSavedOnly}
>
- {i18(Keyset.ActionSavedOnly)}
+ {i18n(Keyset.ActionSavedOnly)}
) : null}
diff --git a/src/components/FeedHeader/components/Controls/customRenders.tsx b/src/components/FeedHeader/components/Controls/customRenders.tsx
index 47fb8865..31cd914a 100644
--- a/src/components/FeedHeader/components/Controls/customRenders.tsx
+++ b/src/components/FeedHeader/components/Controls/customRenders.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import {SelectOption, SelectProps, TextInput} from '@gravity-ui/uikit';
-import {Keyset, i18} from '../../../../i18n';
+import {Keyset, i18n} from '../../../../i18n';
import {block} from '../../../../utils/cn';
import {
CustomSelectOption,
@@ -45,7 +45,7 @@ export const renderFilter: SelectProps['renderFilter'] = ({value, onChange, onKe
controlProps={{size: 1}}
value={value}
view="clear"
- placeholder={i18(Keyset.Search)}
+ placeholder={i18n(Keyset.Search)}
onUpdate={onChange}
onKeyDown={onKeyDown}
className={b('popup-filter')}
diff --git a/src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss b/src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss
index 93f0e767..55829050 100644
--- a/src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss
+++ b/src/components/FeedHeader/components/CustomSwitcher/CustomSwitcher.scss
@@ -27,7 +27,7 @@ $clearIconSize: 11px;
margin: 0;
// TODO delete this section after Select can customize the popup list
- & + .yc-popup.yc-popup_open {
+ & + .g-popup.g-popup_open {
//stylelint-disable-next-line declaration-no-important
position: absolute !important;
//stylelint-disable-next-line declaration-no-important
diff --git a/src/components/Paginator/Paginator.tsx b/src/components/Paginator/Paginator.tsx
index ff336a71..4ddfe0f4 100644
--- a/src/components/Paginator/Paginator.tsx
+++ b/src/components/Paginator/Paginator.tsx
@@ -2,12 +2,8 @@ import React, {useEffect, useMemo, useState} from 'react';
import {useAnalytics} from '@gravity-ui/page-constructor';
-import {BlogMetrikaGoalIds} from '../../constants';
-/**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
-import metrika from '../../counters/metrika';
-import {MetrikaCounter} from '../../counters/utils';
+import {DefaultGoalIds} from '../../constants';
+import {AnalyticsCounter} from '../../counters/utils';
import {DefaultEventNames} from '../../models/common';
import {block} from '../../utils/cn';
@@ -15,6 +11,7 @@ import {NavigationButton} from './components/NavigationButton';
import {PaginatorItem} from './components/PaginatorItem';
import {ArrowType, PaginatorItemProps, PaginatorProps} from './types';
import {getPageConfigs, getPagesCount} from './utils';
+import {prepareAnalyticsEvent} from '../../utils/common';
import _ from 'lodash';
@@ -66,18 +63,18 @@ export const Paginator = ({
let newPage = page;
if (type === 'prev' && page > 1) {
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.home);
- handleAnalyticsHome();
+ const event = prepareAnalyticsEvent({
+ name: DefaultGoalIds.home,
+ counter: AnalyticsCounter.CrossSite,
+ });
+ handleAnalyticsHome(event);
newPage = 1;
} else if (type === 'next' && page < pagesCount) {
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- handleAnalyticsNext();
- metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.next);
+ const event = prepareAnalyticsEvent({
+ name: DefaultGoalIds.next,
+ counter: AnalyticsCounter.CrossSite,
+ });
+ handleAnalyticsNext(event);
newPage = page + 1;
}
@@ -88,11 +85,11 @@ export const Paginator = ({
const handlePageClick = (index: number | ArrowType) => {
if (index !== page && typeof index === 'number') {
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrika.reachGoal(MetrikaCounter.CrossSite, BlogMetrikaGoalIds.page, {page: index});
- handleAnalyticsPage(null, {page: String(index)});
+ const event = prepareAnalyticsEvent({
+ name: DefaultGoalIds.page,
+ counter: AnalyticsCounter.CrossSite,
+ });
+ handleAnalyticsPage(event, {page: String(index)});
handlePageChange(index);
}
};
diff --git a/src/components/Paginator/components/NavigationButton.tsx b/src/components/Paginator/components/NavigationButton.tsx
index 3a2e36d5..92e681c1 100644
--- a/src/components/Paginator/components/NavigationButton.tsx
+++ b/src/components/Paginator/components/NavigationButton.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import {Keyset, i18} from '../../../i18n';
+import {Keyset, i18n} from '../../../i18n';
import {block} from '../../../utils/cn';
import {ArrowType} from '../types';
@@ -16,6 +16,6 @@ export type NavigationButtonProps = {
export const NavigationButton = ({arrowType, disabled}: NavigationButtonProps) =>
disabled ? null : (
- {arrowType === ArrowType.Prev ? i18(Keyset.ButtonBegin) : i18(Keyset.ButtonFarther)}
+ {arrowType === ArrowType.Prev ? i18n(Keyset.ButtonBegin) : i18n(Keyset.ButtonFarther)}
);
diff --git a/src/components/PostCard/PostCard.tsx b/src/components/PostCard/PostCard.tsx
index 513fcf78..c59420c5 100644
--- a/src/components/PostCard/PostCard.tsx
+++ b/src/components/PostCard/PostCard.tsx
@@ -1,5 +1,5 @@
import React, {useContext, useMemo} from 'react';
-import {CardBase, HTML, MetrikaGoal, YFMWrapper} from '@gravity-ui/page-constructor';
+import {AnalyticsEventsProp, CardBase, HTML, YFMWrapper} from '@gravity-ui/page-constructor';
import {useUniqId} from '@gravity-ui/uikit';
import {LikesContext} from '../../contexts/LikesContext';
@@ -16,21 +16,18 @@ type PostCardProps = {
showTag?: boolean;
size?: PostCardSize;
titleHeadingLevel?: PostCardTitleHeadingLevel;
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrikaGoals?: MetrikaGoal;
+ analyticsEvents?: AnalyticsEventsProp;
};
const b = block('post-card');
export const PostCard = ({
post,
- metrikaGoals,
fullWidth = false,
size = PostCardSize.SMALL,
showTag = false,
titleHeadingLevel = PostCardTitleHeadingLevel.H3,
+ analyticsEvents,
}: PostCardProps) => {
const {
title: postTitle,
@@ -81,7 +78,7 @@ export const PostCard = ({
return (
diff --git a/src/components/PostInfo/PostInfo.tsx b/src/components/PostInfo/PostInfo.tsx
index 0f706da7..313c7da4 100644
--- a/src/components/PostInfo/PostInfo.tsx
+++ b/src/components/PostInfo/PostInfo.tsx
@@ -1,5 +1,6 @@
import React, {useContext} from 'react';
+import {AnalyticsEventsProp} from '@gravity-ui/page-constructor';
import {PostPageContext} from '../../contexts/PostPageContext';
import {PostData, QAProps} from '../../models/common';
import {block} from '../../utils/cn';
@@ -14,20 +15,12 @@ import './PostInfo.scss';
const b = block('post-info');
-export type BlogMetrikaGoals = {
- sharing?: string;
- save?: string;
-};
-
type PostInfoProps = QAProps & {
postId: PostData['id'];
readingTime: PostData['readingTime'];
date: PostData['date'];
theme?: 'light' | 'dark';
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrikaGoals?: BlogMetrikaGoals;
+ analyticsEventsContainer?: Record;
};
/**
@@ -37,8 +30,8 @@ type PostInfoProps = QAProps & {
* @param readingTime - post reading time
* @param date - post create date
* @param theme - theme name
- * @param metrikaGoals - metrika goals name
* @param qa - test-attr
+ * @param analyticsEventsContainer - a map of records with a single or collection of objects detailing analytics events
*
* @returns jsx
*/
@@ -47,8 +40,8 @@ export const PostInfo = ({
readingTime,
postId,
theme = 'light',
- metrikaGoals,
qa,
+ analyticsEventsContainer,
}: PostInfoProps) => {
const {likes} = useContext(PostPageContext);
const qaAttributes = getQaAttributes(qa, 'date', 'reading-time', 'save');
@@ -57,14 +50,14 @@ export const PostInfo = ({
{date &&
}
{readingTime &&
}
-
+
{likes && (
diff --git a/src/components/PostInfo/SuggestPostInfo.tsx b/src/components/PostInfo/SuggestPostInfo.tsx
index 2eb97356..c9b1d85c 100644
--- a/src/components/PostInfo/SuggestPostInfo.tsx
+++ b/src/components/PostInfo/SuggestPostInfo.tsx
@@ -7,10 +7,15 @@ import {block} from '../../utils/cn';
import {Date} from './components/Date';
import {ReadingTime} from './components/ReadingTime';
import {Save} from './components/Save';
+import {prepareAnalyticsEvent} from '../../utils/common';
+import {DefaultGoalIds} from '../../constants';
+
import './PostInfo.scss';
const b = block('post-info');
+const saveEvents = prepareAnalyticsEvent({name: DefaultGoalIds.saveSuggest});
+
export interface SuggestPostInfoProps
extends Pick
,
QAProps {
@@ -70,6 +75,7 @@ export const SuggestPostInfo = ({
- {i18(Keyset.ContextReadingTime, {count: readingTime})}
+ {i18n(Keyset.ContextReadingTime, {count: readingTime})}
);
diff --git a/src/components/PostInfo/components/Save.tsx b/src/components/PostInfo/components/Save.tsx
index 3ee625f7..955e0b66 100644
--- a/src/components/PostInfo/components/Save.tsx
+++ b/src/components/PostInfo/components/Save.tsx
@@ -1,11 +1,9 @@
import React, {useContext} from 'react';
-import {useAnalytics} from '@gravity-ui/page-constructor';
+import {AnalyticsEventsProp, useAnalytics} from '@gravity-ui/page-constructor';
import {Icon} from '@gravity-ui/uikit';
import {LikesContext} from '../../../contexts/LikesContext';
-import metrika from '../../../counters/metrika';
-import {MetrikaCounter} from '../../../counters/utils';
import {Save as SaveIcon} from '../../../icons/Save';
import {SaveFilled} from '../../../icons/SaveFilled';
import {DefaultEventNames, QAProps} from '../../../models/common';
@@ -24,11 +22,8 @@ type SaveProps = QAProps & {
hasUserLike: boolean;
handleUserLike: () => void;
theme?: 'light' | 'dark';
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrikaGoal?: string;
size?: 's' | 'm';
+ analyticsEvents?: AnalyticsEventsProp;
};
/**
@@ -37,9 +32,9 @@ type SaveProps = QAProps & {
* @param title - post title
* @param postId - post id
* @param hasUserLike - flag what blog has like from current user
- * @param metrikaGoal - metrika goal name
* @param qa - test-attr
* @param size - text size
+ * @param analyticsEvents - a single or collection of objects detailing analytics events
*
* @returns jsx
*/
@@ -48,10 +43,10 @@ export const Save = ({
postId,
hasUserLike,
handleUserLike,
- metrikaGoal,
size,
theme,
qa,
+ analyticsEvents,
}: SaveProps) => {
const {toggleLike, isSignedInUser, requireSignIn} = useContext(LikesContext);
const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
@@ -78,8 +73,7 @@ export const Save = ({
postLikeStatus(postId, Boolean(hasUserLike));
handleUserLike();
- metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
- handleAnalytics();
+ handleAnalytics(analyticsEvents);
}}
data-qa={qa}
>
diff --git a/src/components/PostInfo/components/Sharing.tsx b/src/components/PostInfo/components/Sharing.tsx
index f1b90317..fa4c6fe0 100644
--- a/src/components/PostInfo/components/Sharing.tsx
+++ b/src/components/PostInfo/components/Sharing.tsx
@@ -1,14 +1,12 @@
import React, {useCallback, useContext} from 'react';
import {ShareLayoutDirection, SharePopover} from '@gravity-ui/components';
-import {useAnalytics} from '@gravity-ui/page-constructor';
+import {AnalyticsEventsProp, useAnalytics} from '@gravity-ui/page-constructor';
import {MobileContext} from '../../../contexts/MobileContext';
import {PostPageContext} from '../../../contexts/PostPageContext';
import {RouterContext} from '../../../contexts/RouterContext';
-import metrika from '../../../counters/metrika';
-import {MetrikaCounter} from '../../../counters/utils';
-import {Keyset, i18} from '../../../i18n';
+import {Keyset, i18n} from '../../../i18n';
import {ShareArrowUp} from '../../../icons/ShareArrowUp';
import {DefaultEventNames} from '../../../models/common';
import {block} from '../../../utils/cn';
@@ -20,27 +18,18 @@ const b = block('post-info');
type SharingProps = {
theme?: 'light' | 'dark';
- /**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
- metrikaGoal?: string;
+ analyticsEvents?: AnalyticsEventsProp;
};
-export const Sharing = ({theme, metrikaGoal}: SharingProps) => {
+export const Sharing = ({theme, analyticsEvents}: SharingProps) => {
const router = useContext(RouterContext);
const isMobile = useContext(MobileContext);
const {shareOptions} = useContext(PostPageContext);
const handleAnalyticsGlobal = useAnalytics(DefaultEventNames.ShareButton);
- const handleMetrika = useCallback(() => {
- metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
- }, [metrikaGoal]);
-
const handleAnalytics = useCallback(() => {
- handleAnalyticsGlobal();
-
- handleMetrika();
- }, [handleAnalyticsGlobal, handleMetrika]);
+ handleAnalyticsGlobal(analyticsEvents);
+ }, [analyticsEvents, handleAnalyticsGlobal]);
return (
@@ -53,7 +42,7 @@ export const Sharing = ({theme, metrikaGoal}: SharingProps) => {
tooltipClassName={b('popup')}
useWebShareApi={isMobile}
direction={ShareLayoutDirection.Column}
- buttonTitle={i18(Keyset.ActionShare)}
+ buttonTitle={i18n(Keyset.ActionShare)}
customIcon={ShareArrowUp}
placement="bottom"
openByHover={false}
diff --git a/src/components/Posts/Posts.tsx b/src/components/Posts/Posts.tsx
index b6cdaf98..d45bee00 100644
--- a/src/components/Posts/Posts.tsx
+++ b/src/components/Posts/Posts.tsx
@@ -3,7 +3,7 @@ import React, {MouseEvent} from 'react';
import {CardLayoutBlock} from '@gravity-ui/page-constructor';
import {Button} from '@gravity-ui/uikit';
-import {Keyset, i18} from '../../i18n';
+import {Keyset, i18n} from '../../i18n';
import {PostCardSize, PostCardTitleHeadingLevel, PostData, Query} from '../../models/common';
import {block} from '../../utils/cn';
import {Paginator} from '../Paginator/Paginator';
@@ -96,13 +96,13 @@ export const Posts = ({
className={b('more-button')}
onClick={handleShowMore}
>
- {i18(Keyset.ActionLoadMore)}
+ {i18n(Keyset.ActionLoadMore)}
)}
{errorShowMore && (
-
{i18(Keyset.ErrorTitle)}
-
{i18(Keyset.PostLoadError)}
+
{i18n(Keyset.ErrorTitle)}
+
{i18n(Keyset.PostLoadError)}
)}
{Boolean(currentPage && postCountOnPage) && (
diff --git a/src/components/PostsEmpty/PostsEmpty.tsx b/src/components/PostsEmpty/PostsEmpty.tsx
index dfa13d8c..9345f492 100644
--- a/src/components/PostsEmpty/PostsEmpty.tsx
+++ b/src/components/PostsEmpty/PostsEmpty.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import {Keyset, i18} from '../../i18n';
+import {Keyset, i18n} from '../../i18n';
import {block} from '../../utils/cn';
import './PostsEmpty.scss';
@@ -9,7 +9,7 @@ const b = block('posts-empty');
export const PostsEmpty = () => (
-
{i18(Keyset.TitleEmptyContainer)}
-
{i18(Keyset.ContextEmptyContainer)}
+
{i18n(Keyset.TitleEmptyContainer)}
+
{i18n(Keyset.ContextEmptyContainer)}
);
diff --git a/src/components/PostsError/PostsError.tsx b/src/components/PostsError/PostsError.tsx
index ce8f8305..f3155de9 100644
--- a/src/components/PostsError/PostsError.tsx
+++ b/src/components/PostsError/PostsError.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import {Button} from '@gravity-ui/uikit';
-import {Keyset, i18} from '../../i18n';
+import {Keyset, i18n} from '../../i18n';
import {block} from '../../utils/cn';
import './PostError.scss';
@@ -18,11 +18,11 @@ export const PostsError = ({onButtonClick}: PostsErrorContainerProps) => {
return (
-
{i18(Keyset.ErrorTitle)}
-
{i18(Keyset.PostLoadError)}
+
{i18n(Keyset.ErrorTitle)}
+
{i18n(Keyset.PostLoadError)}
diff --git a/src/components/PromptSignIn/PromptSignIn.tsx b/src/components/PromptSignIn/PromptSignIn.tsx
index 220c90c6..eb1bff47 100644
--- a/src/components/PromptSignIn/PromptSignIn.tsx
+++ b/src/components/PromptSignIn/PromptSignIn.tsx
@@ -1,6 +1,6 @@
import React, {SyntheticEvent} from 'react';
-import {Keyset, i18} from '../../i18n';
+import {Keyset, i18n} from '../../i18n';
import {Prompt, PromptProps} from '../Prompt/Prompt';
export interface PromptSignInProps extends Partial
{
@@ -12,11 +12,11 @@ export interface PromptSignInProps extends Partial {
* @returns {JSX|null}
*/
export const PromptSignIn = ({
- text = i18(Keyset.PromptSignInOnLike),
- onClickSignIn = () => alert(i18(Keyset.SignIn)),
+ text = i18n(Keyset.PromptSignInOnLike),
+ onClickSignIn = () => alert(i18n(Keyset.SignIn)),
actions = [
{
- children: i18(Keyset.SignIn),
+ children: i18n(Keyset.SignIn),
onClick: onClickSignIn,
size: 'l',
},
diff --git a/src/components/Search/Search.tsx b/src/components/Search/Search.tsx
index 6f1c3b34..e01f9bc2 100644
--- a/src/components/Search/Search.tsx
+++ b/src/components/Search/Search.tsx
@@ -4,7 +4,7 @@ import {Icon, TextInput} from '@gravity-ui/uikit';
import lodashDebounce from 'lodash/debounce';
import {useIsIPhone} from '../../hooks/useIsIPhone';
-import {Keyset, i18} from '../../i18n';
+import {Keyset, i18n} from '../../i18n';
import {Close} from '../../icons/Close';
import {SearchIcon} from '../../icons/SearchIcon';
import {ClassNameProps} from '../../models/common';
@@ -42,7 +42,7 @@ export const Search = ({
initialValue,
onSubmit,
debounce = 300,
- placeholder = i18(Keyset.Search),
+ placeholder = i18n(Keyset.Search),
size = 'm',
autoFocus = false,
value: externalValue,
diff --git a/src/configure.ts b/src/configure.ts
deleted file mode 100644
index 5e84d52e..00000000
--- a/src/configure.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import {i18n} from './i18n';
-import {Lang} from './models/locale';
-
-export interface ProjectConfigParams {
- lang: Lang;
-}
-
-export const configure = ({lang}: ProjectConfigParams) => {
- i18n.setLang(lang);
-};
diff --git a/src/constants.ts b/src/constants.ts
index 3cc377c6..af459835 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -13,13 +13,14 @@ export const DEFAULT_THEME = 'light';
export const UIKIT_ROOT_CLASS = 'g-root';
export const UIKIT_THEME_LIGHT_CLASS = `${UIKIT_ROOT_CLASS}_theme_${DEFAULT_THEME}`;
-export enum BlogMetrikaGoalIds {
+export enum DefaultGoalIds {
shareTop = 'SITE_BLOG_SHARE-TOP_CLICK',
shareBottom = 'SITE_BLOG_SHARE-BOTTOM_CLICK',
breadcrumbsTop = 'SITE_BLOG_BREADCRUMBS-TOP_CLICK',
breadcrumbsBottom = 'SITE_BLOG_BREADCRUMBS-BOTTOM_CLICK',
saveTop = 'SITE_BLOG_SAVE-TOP_CLICK',
saveBottom = 'SITE_BLOG_SAVE-BOTTOM_CLICK',
+ saveSuggest = 'SITE_BLOG_SAVE-SUGGEST_CLICK',
suggest = 'SITE_BLOG_INTERESTING-CARD_CLICK',
bannerCommon = 'SITE_BLOG_TEXT-BANNER_CLICK',
cta = 'SITE_BLOG_CTA_CLICK',
diff --git a/src/constructor/BlogConstructorProvider.tsx b/src/constructor/BlogConstructorProvider.tsx
index 33724ecd..6298836b 100644
--- a/src/constructor/BlogConstructorProvider.tsx
+++ b/src/constructor/BlogConstructorProvider.tsx
@@ -1,6 +1,11 @@
import React, {Fragment, PropsWithChildren} from 'react';
-import {AnalyticsContext, AnalyticsContextProps} from '@gravity-ui/page-constructor';
+import {
+ AnalyticsContext,
+ AnalyticsContextProps,
+ Theme,
+ ThemeContext,
+} from '@gravity-ui/page-constructor';
import {DEFAULT_THEME} from '../constants';
import {DeviceContext, DeviceContextProps} from '../contexts/DeviceContext';
@@ -34,6 +39,7 @@ export const BlogConstructorProvider = ({
}: PropsWithChildren) => {
const context = [
,
+ ,
,
,
,
diff --git a/src/containers/BlogPage/__stories__/BlogPage.stories.tsx b/src/containers/BlogPage/__stories__/BlogPage.stories.tsx
index cfed4d66..95fe7a09 100644
--- a/src/containers/BlogPage/__stories__/BlogPage.stories.tsx
+++ b/src/containers/BlogPage/__stories__/BlogPage.stories.tsx
@@ -11,7 +11,7 @@ import navigation from '../../../../.mocks/navigation.json';
import posts from '../../../../.mocks/posts.json';
import services from '../../../../.mocks/services.json';
import tags from '../../../../.mocks/tags.json';
-import {Lang} from '../../../models/locale';
+import {Lang} from '@gravity-ui/uikit';
import {routerData} from '../../../demo/mocks';
const mockMetaComponent = Blog page;
diff --git a/src/contexts/LocaleContext.ts b/src/contexts/LocaleContext.ts
index 783c72d8..3838b114 100644
--- a/src/contexts/LocaleContext.ts
+++ b/src/contexts/LocaleContext.ts
@@ -1,6 +1,7 @@
import React from 'react';
-import {Lang, Locale} from '../models/locale';
+import {Locale} from '../models/locale';
+import {Lang} from '@gravity-ui/uikit';
export type LocaleContextProps = {
locale: Locale;
diff --git a/src/counters/metrika.ts b/src/counters/metrika.ts
index 8d3ea720..bf8251b6 100644
--- a/src/counters/metrika.ts
+++ b/src/counters/metrika.ts
@@ -1,6 +1,3 @@
-/**
- * @deprecated Metrika will be deleted after launch of analyticsEvents
- */
const Goal = {
SUPPORT_OPEN_FORM: 'SUPPORTOPENFORM',
SUPPORT_STEP_1_SUBMIT: 'SUPPORTSTEP1SUBMIT',
diff --git a/src/counters/utils.ts b/src/counters/utils.ts
index c39884b9..2a7c217c 100644
--- a/src/counters/utils.ts
+++ b/src/counters/utils.ts
@@ -1,4 +1,4 @@
-export enum MetrikaCounter {
+export enum AnalyticsCounter {
Main = 'main',
CrossSite = 'cross-site',
Scale = 'scale',
diff --git a/src/data/contentFilter.ts b/src/data/contentFilter.ts
index 5b53fd8a..789767a1 100644
--- a/src/data/contentFilter.ts
+++ b/src/data/contentFilter.ts
@@ -1,7 +1,8 @@
-import evalExp from '@doc-tools/transform/lib/liquid/evaluation';
+// eslint-disable-next-line import/no-extraneous-dependencies
+import evalExp from '@diplodoc/transform/lib/liquid/evaluation';
import {PageContent} from '@gravity-ui/page-constructor';
-import {Lang} from '../models/locale';
+import {Lang} from '@gravity-ui/uikit';
type FilteringOptions = {
lang: Lang;
diff --git a/src/data/transformPageContent.ts b/src/data/transformPageContent.ts
index 0997415b..b817ffc4 100644
--- a/src/data/transformPageContent.ts
+++ b/src/data/transformPageContent.ts
@@ -1,9 +1,10 @@
-import {MarkdownItPluginCb} from '@doc-tools/transform/lib/plugins/typings';
+// eslint-disable-next-line import/no-extraneous-dependencies
+import {MarkdownItPluginCb} from '@diplodoc/transform/lib/plugins/typings';
import {ConstructorBlock, PageContent} from '@gravity-ui/page-constructor';
import {contentTransformer} from '@gravity-ui/page-constructor/server';
import yaml from 'js-yaml';
-import {Lang} from '../models/locale';
+import {Lang} from '@gravity-ui/uikit';
import {getExtendTypographyConfig} from './config';
import {filterContent} from './contentFilter';
diff --git a/src/data/transformPost.ts b/src/data/transformPost.ts
index 51ac451e..278d1f47 100644
--- a/src/data/transformPost.ts
+++ b/src/data/transformPost.ts
@@ -1,7 +1,13 @@
import {typografToHTML, typografToText, yfmTransformer} from '@gravity-ui/page-constructor/server';
import {PostData, TransformPostOptions} from '../models/common';
-import {Lang} from '../models/locale';
+import {Lang} from '@gravity-ui/uikit';
+
+export type TransformPostType = {
+ postData: PostData;
+ lang: Lang;
+ options: TransformPostOptions;
+};
/**
* Func for transform post data
@@ -12,11 +18,7 @@ import {Lang} from '../models/locale';
* @param plugins - YFM plugins list
* @returns -prepared post
*/
-export const transformPost = (
- postData: PostData,
- lang: Lang,
- {plugins}: TransformPostOptions = {},
-) => {
+export const transformPost = ({postData, lang, options: {plugins} = {}}: TransformPostType) => {
if (!postData) {
// eslint-disable-next-line no-console
console.error('Post not found');
diff --git a/src/i18n/index.ts b/src/i18n/index.ts
index b66e21d6..56bf2081 100644
--- a/src/i18n/index.ts
+++ b/src/i18n/index.ts
@@ -1,10 +1,6 @@
-import {I18N} from '@gravity-ui/i18n';
+import {addComponentKeysets} from '@gravity-ui/uikit/i18n';
-import {Lang} from '../models/locale';
-
-const KEYSET_NAME = 'blog';
-
-export const i18n = new I18N();
+const NAMESPACE = 'blog';
export enum Keyset {
Title = 'title',
@@ -28,7 +24,7 @@ export enum Keyset {
SignIn = 'Sign In',
}
-i18n.registerKeyset(Lang.En, KEYSET_NAME, {
+const en = {
[Keyset.Title]: 'Blog',
[Keyset.TitleBreadcrumbs]: 'Blog',
[Keyset.TitleSuggest]: 'See also',
@@ -52,9 +48,9 @@ i18n.registerKeyset(Lang.En, KEYSET_NAME, {
'{{count}} mins to read',
],
[Keyset.SignIn]: 'Sign In',
-});
+};
-i18n.registerKeyset(Lang.Ru, KEYSET_NAME, {
+const ru = {
[Keyset.Title]: 'Блог',
[Keyset.TitleBreadcrumbs]: 'Блог',
[Keyset.TitleSuggest]: 'Читать также',
@@ -79,6 +75,6 @@ i18n.registerKeyset(Lang.Ru, KEYSET_NAME, {
'{{count}} минут чтения',
],
[Keyset.SignIn]: 'Войти',
-});
+};
-export const i18 = i18n.keyset(KEYSET_NAME);
+export const i18n = addComponentKeysets({en, ru}, NAMESPACE);
diff --git a/src/index.ts b/src/index.ts
index 4a0f64d1..71790246 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,3 @@
-export {configure} from './configure';
-
export {BlogConstructorProvider} from './constructor/BlogConstructorProvider';
export {BlogPostPage} from './containers/BlogPostPage/BlogPostPage';
diff --git a/src/models/common.ts b/src/models/common.ts
index d81e2952..8eef4dda 100644
--- a/src/models/common.ts
+++ b/src/models/common.ts
@@ -1,6 +1,7 @@
import {ReactNode} from 'react';
-import {MarkdownItPluginCb} from '@doc-tools/transform/lib/plugins/typings';
+// eslint-disable-next-line import/no-extraneous-dependencies
+import {MarkdownItPluginCb} from '@diplodoc/transform/lib/plugins/typings';
import {HeaderBlockProps as PageConstructorHeaderBlockProps} from '@gravity-ui/page-constructor';
import {IBrowser, IDevice} from 'ua-parser-js';
diff --git a/src/models/locale.ts b/src/models/locale.ts
index 127d10ae..1dec55d4 100644
--- a/src/models/locale.ts
+++ b/src/models/locale.ts
@@ -1,7 +1,4 @@
-export enum Lang {
- Ru = 'ru',
- En = 'en',
-}
+import {Lang} from '@gravity-ui/uikit';
export enum Currency {
RUB = 'RUB',
diff --git a/src/server.ts b/src/server.ts
index 12a18cb2..8e6734b0 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -1,4 +1,4 @@
export {transformPageContent} from './data/transformPageContent';
export {createReadableContent} from './data/createReadableContent';
export {sanitizeMeta} from './data/sanitizeMeta';
-export {transformPost} from './data/transformPost';
+export {transformPost, TransformPostType} from './data/transformPost';
diff --git a/src/utils/common.ts b/src/utils/common.ts
index 51e18a8a..8c2695f8 100644
--- a/src/utils/common.ts
+++ b/src/utils/common.ts
@@ -1,11 +1,10 @@
import {format, parse} from 'url';
import {
+ AnalyticsEvent,
+ AnalyticsEventsProp,
ContentBlockProps,
HeaderBreadCrumbsProps,
- MetrikaGoal,
- NewMetrikaGoal,
- isNewMetrikaFormat,
} from '@gravity-ui/page-constructor';
import camelCase from 'lodash/camelCase';
import debounce from 'lodash/debounce';
@@ -20,8 +19,9 @@ import {
DEFAULT_ROWS_PER_PAGE,
} from '../blocks/constants';
import {RouterContextProps} from '../contexts/RouterContext';
-import {Keyset, i18} from '../i18n';
+import {Keyset, i18n} from '../i18n';
import {GetPostsRequest, Query, Tag} from '../models/common';
+import {AnalyticsCounter} from '../counters/utils';
const QA_ATTRIBUTES_KEYS = ['container', 'content', 'wrapper', 'image', 'button'];
@@ -116,7 +116,7 @@ export const getBlogPath = (pathPrefix: string) => {
export const getBreadcrumbs = ({tags, blogPath}: GetBreadcrumbsProps) => {
const breadcrumbs: HeaderBreadCrumbsProps = {
- items: [{text: i18(Keyset.TitleBreadcrumbs), url: blogPath}],
+ items: [{text: i18n(Keyset.TitleBreadcrumbs), url: blogPath}],
theme: 'light',
};
@@ -130,26 +130,26 @@ export const getBreadcrumbs = ({tags, blogPath}: GetBreadcrumbsProps) => {
return breadcrumbs;
};
-export const isMetrikaExist = (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => {
- return Boolean(existGoals.find((existGoal) => goal.name === existGoal.name));
+const getArrayOfEvents = (events?: AnalyticsEventsProp) => {
+ if (!events) {
+ return [];
+ }
+
+ if (Array.isArray(events)) {
+ return events;
+ }
+
+ return [events];
};
-export const getBlogElementMetrika = (
- blogCustomGoal: NewMetrikaGoal,
- existingGoals?: MetrikaGoal,
+export const getMergedAnalyticsEvents = (
+ analyticEvents: AnalyticsEventsProp,
+ existringEvents?: AnalyticsEventsProp,
) => {
- if (existingGoals) {
- if (isNewMetrikaFormat(existingGoals) && !isMetrikaExist(blogCustomGoal, existingGoals)) {
- const goals = [...existingGoals];
- goals.push(blogCustomGoal);
-
- return goals;
- }
+ const eventsAsArray = getArrayOfEvents(analyticEvents);
+ const existingAsArray = getArrayOfEvents(existringEvents);
- return existingGoals;
- } else {
- return [blogCustomGoal];
- }
+ return eventsAsArray.concat(existingAsArray);
};
export const getFeedQueryParams = (queryString: Query, pageNumber?: number): GetPostsRequest => {
@@ -188,3 +188,21 @@ export const getQaAttributes = (qa?: string, ...customKeys: (string | Array;
+};
+
+export const prepareAnalyticsEvent = ({
+ name,
+ counter = AnalyticsCounter.Main,
+ options = {},
+}: PrepareAnalyticsEventArgs): AnalyticsEvent => ({
+ ...options,
+ name,
+ counters: {
+ include: [counter],
+ },
+});
diff --git a/styles/storybook/common.scss b/styles/storybook/common.scss
index 57edbcc6..e6cfc258 100644
--- a/styles/storybook/common.scss
+++ b/styles/storybook/common.scss
@@ -1,3 +1,5 @@
+@import '../mixins.scss';
+
.demo-container {
min-height: calc(100vh - 1px);
padding: 50px;
@@ -33,3 +35,9 @@
--pc-first-block-indent: 64px;
margin-bottom: 120px;
}
+
+.pc-layout {
+ @include add-specificity(&) {
+ min-height: auto;
+ }
+}
diff --git a/styles/storybook/index.scss b/styles/storybook/index.scss
index 74627340..95ecb4b4 100644
--- a/styles/storybook/index.scss
+++ b/styles/storybook/index.scss
@@ -3,7 +3,7 @@
@import './common';
@import './palette';
@import './typography';
-@import '~@doc-tools/transform/dist/css/yfm.css';
+@import '~@diplodoc/transform/dist/css/yfm.css';
/**
* storybook-host container style overrides
* @see {@link https://github.com/philcockfield/storybook-host/issues/43}
diff --git a/styles/styles.scss b/styles/styles.scss
index a9602299..250ae8a5 100644
--- a/styles/styles.scss
+++ b/styles/styles.scss
@@ -1,2 +1,3 @@
@import '~@gravity-ui/uikit/styles/styles.css';
+@import './yfm.scss';
@import './fonts.scss';
diff --git a/test-utils/setup-tests.ts b/test-utils/setup-tests.ts
index 14ae4b40..e8fe85f7 100644
--- a/test-utils/setup-tests.ts
+++ b/test-utils/setup-tests.ts
@@ -1,8 +1,7 @@
+import {Lang, configure as uiKitConfigure} from '@gravity-ui/uikit';
import {configure} from '@testing-library/dom';
-import {Lang, configure as libConfigure} from '../src';
-
-libConfigure({
+uiKitConfigure({
lang: Lang.En,
});