@gravity-ui/blog-constructor 3.0.0 → 3.1.0-alpha.1

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 CHANGED
@@ -47,6 +47,8 @@ import {BlogPostPage, BlogConstructorProvider} from '@gravity-ui/blog-constructo
47
47
 
48
48
  ```
49
49
 
50
+ Documentation about [providerProps](./src/constructor/README.md).
51
+
50
52
  Also blog-constructor have server components to help you transform your data if you need
51
53
 
52
54
  ```jsx
@@ -30,7 +30,7 @@ exports.Save = void 0;
30
30
  const react_1 = __importStar(require("react"));
31
31
  const page_constructor_1 = require("@gravity-ui/page-constructor");
32
32
  const uikit_1 = require("@gravity-ui/uikit");
33
- const UserContext_1 = require("../../../contexts/UserContext");
33
+ const LikesContext_1 = require("../../../contexts/LikesContext");
34
34
  const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
35
35
  const utils_1 = require("../../../counters/utils");
36
36
  const Save_1 = require("../../../icons/Save");
@@ -53,14 +53,15 @@ const b = (0, cn_1.block)('post-info');
53
53
  * @returns jsx
54
54
  */
55
55
  const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
56
- const { uid } = (0, react_1.useContext)(UserContext_1.UserContext);
56
+ const { toggleLike } = (0, react_1.useContext)(LikesContext_1.LikesContext);
57
57
  const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveButton);
58
+ const isLikeable = Boolean(toggleLike);
58
59
  return (react_1.default.createElement("div", { className: b('item', { size }), onClick: (event) => {
59
60
  // both preventDefault and stopImmediatePropagation required to work properly
60
61
  // https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
61
62
  event.preventDefault();
62
63
  event.nativeEvent.stopImmediatePropagation();
63
- if (!uid) {
64
+ if (!isLikeable) {
64
65
  return;
65
66
  }
66
67
  (0, common_2.postLikeStatus)(postId, Boolean(hasUserLike));
@@ -68,9 +69,9 @@ const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, t
68
69
  metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
69
70
  handleAnalytics();
70
71
  }, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
71
- react_1.default.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
72
+ react_1.default.createElement("div", { className: b('content', { cursor: isLikeable, theme }) },
72
73
  react_1.default.createElement("span", { className: b('icon') },
73
74
  react_1.default.createElement(uikit_1.Icon, { data: hasUserLike ? SaveFilled_1.SaveFilled : Save_1.Save, size: ICON_SIZE, className: b({ filled: Boolean(hasUserLike) }) })),
74
- react_1.default.createElement("span", { className: b('title', { cursor: Boolean(uid) }) }, title))));
75
+ react_1.default.createElement("span", { className: b('title', { cursor: isLikeable }) }, title))));
75
76
  };
76
77
  exports.Save = Save;
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
3
3
  import { DeviceContextProps } from '../contexts/DeviceContext';
4
4
  import { RouterContextProps } from '../contexts/RouterContext';
5
- import { UserContextProps } from '../contexts/UserContext';
6
5
  import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
7
6
  import { Locale } from '../models/locale';
8
7
  export interface BlogConstructorProviderProps {
@@ -10,7 +9,6 @@ export interface BlogConstructorProviderProps {
10
9
  locale?: Locale;
11
10
  router?: RouterContextProps;
12
11
  theme?: ThemeValueType;
13
- user?: UserContextProps;
14
12
  device?: DeviceContextProps;
15
13
  analytics?: AnalyticsContextProps;
16
14
  children?: React.ReactNode;
@@ -31,15 +31,13 @@ const DeviceContext_1 = require("../contexts/DeviceContext");
31
31
  const LocaleContext_1 = require("../contexts/LocaleContext");
32
32
  const MobileContext_1 = require("../contexts/MobileContext");
33
33
  const RouterContext_1 = require("../contexts/RouterContext");
34
- const UserContext_1 = require("../contexts/UserContext");
35
34
  const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
36
- const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
35
+ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
37
36
  const context = [
38
37
  react_1.default.createElement(ThemeValueContext_1.ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
39
38
  react_1.default.createElement(LocaleContext_1.LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
40
39
  react_1.default.createElement(RouterContext_1.RouterContext.Provider, { value: router, key: "router-context" }),
41
40
  react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
42
- react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
43
41
  react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
44
42
  react_1.default.createElement(page_constructor_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
45
43
  ].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
@@ -1,7 +1,7 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { useAnalytics } from '@gravity-ui/page-constructor';
3
3
  import { Icon } from '@gravity-ui/uikit';
4
- import { UserContext } from '../../../contexts/UserContext';
4
+ import { LikesContext } from '../../../contexts/LikesContext';
5
5
  import metrika from '../../../counters/metrika.js';
6
6
  import { MetrikaCounter } from '../../../counters/utils';
7
7
  import { Save as SaveIcon } from '../../../icons/Save';
@@ -25,14 +25,15 @@ const b = block('post-info');
25
25
  * @returns jsx
26
26
  */
27
27
  export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
28
- const { uid } = useContext(UserContext);
28
+ const { toggleLike } = useContext(LikesContext);
29
29
  const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
30
+ const isLikeable = Boolean(toggleLike);
30
31
  return (React.createElement("div", { className: b('item', { size }), onClick: (event) => {
31
32
  // both preventDefault and stopImmediatePropagation required to work properly
32
33
  // https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
33
34
  event.preventDefault();
34
35
  event.nativeEvent.stopImmediatePropagation();
35
- if (!uid) {
36
+ if (!isLikeable) {
36
37
  return;
37
38
  }
38
39
  postLikeStatus(postId, Boolean(hasUserLike));
@@ -40,8 +41,8 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
40
41
  metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
41
42
  handleAnalytics();
42
43
  }, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
43
- React.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
44
+ React.createElement("div", { className: b('content', { cursor: isLikeable, theme }) },
44
45
  React.createElement("span", { className: b('icon') },
45
46
  React.createElement(Icon, { data: hasUserLike ? SaveFilled : SaveIcon, size: ICON_SIZE, className: b({ filled: Boolean(hasUserLike) }) })),
46
- React.createElement("span", { className: b('title', { cursor: Boolean(uid) }) }, title))));
47
+ React.createElement("span", { className: b('title', { cursor: isLikeable }) }, title))));
47
48
  };
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
3
3
  import { DeviceContextProps } from '../contexts/DeviceContext';
4
4
  import { RouterContextProps } from '../contexts/RouterContext';
5
- import { UserContextProps } from '../contexts/UserContext';
6
5
  import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
7
6
  import { Locale } from '../models/locale';
8
7
  export interface BlogConstructorProviderProps {
@@ -10,7 +9,6 @@ export interface BlogConstructorProviderProps {
10
9
  locale?: Locale;
11
10
  router?: RouterContextProps;
12
11
  theme?: ThemeValueType;
13
- user?: UserContextProps;
14
12
  device?: DeviceContextProps;
15
13
  analytics?: AnalyticsContextProps;
16
14
  children?: React.ReactNode;
@@ -5,15 +5,13 @@ import { DeviceContext } from '../contexts/DeviceContext';
5
5
  import { LocaleContext } from '../contexts/LocaleContext';
6
6
  import { MobileContext } from '../contexts/MobileContext';
7
7
  import { RouterContext } from '../contexts/RouterContext';
8
- import { UserContext } from '../contexts/UserContext';
9
8
  import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
10
- export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, user = {}, device = {}, analytics = {}, children, }) => {
9
+ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
11
10
  const context = [
12
11
  React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
13
12
  React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
14
13
  React.createElement(RouterContext.Provider, { value: router, key: "router-context" }),
15
14
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
16
- React.createElement(UserContext.Provider, { value: user, key: "user-context" }),
17
15
  React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
18
16
  React.createElement(AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
19
17
  ].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "3.0.0",
3
+ "version": "3.1.0-alpha.1",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -141,5 +141,8 @@
141
141
  "*.{json,yaml,yml,md}": [
142
142
  "prettier --write"
143
143
  ]
144
+ },
145
+ "publishConfig": {
146
+ "tag": "alpha"
144
147
  }
145
148
  }
package/CHANGELOG.md DELETED
@@ -1,101 +0,0 @@
1
- # Changelog
2
-
3
- ## [3.0.0](https://github.com/gravity-ui/blog-constructor/compare/v2.3.0...v3.0.0) (2023-04-10)
4
-
5
-
6
- ### ⚠ BREAKING CHANGES
7
-
8
- * add callback prop for blog page ([#25](https://github.com/gravity-ui/blog-constructor/issues/25))
9
-
10
- ### Features
11
-
12
- * add callback prop for blog page ([#25](https://github.com/gravity-ui/blog-constructor/issues/25)) ([7b1ab2c](https://github.com/gravity-ui/blog-constructor/commit/7b1ab2c12aa9ef4f8e5a11853508a9b439a196d7))
13
-
14
- ## [2.3.0](https://github.com/gravity-ui/blog-constructor/compare/v2.2.0...v2.3.0) (2023-04-10)
15
-
16
-
17
- ### Features
18
-
19
- * analytics refactoring ([#13](https://github.com/gravity-ui/blog-constructor/issues/13)) ([a95c55b](https://github.com/gravity-ui/blog-constructor/commit/a95c55bd1ff98f86a110f33ac3275b590ee5db8e))
20
-
21
-
22
- ### Bug Fixes
23
-
24
- * margin-top of header ([#31](https://github.com/gravity-ui/blog-constructor/issues/31)) ([97ed974](https://github.com/gravity-ui/blog-constructor/commit/97ed974ab0ce0546010d60587b21b8c0eee3279c))
25
-
26
- ## [2.2.0](https://github.com/gravity-ui/blog-constructor/compare/v2.1.0...v2.2.0) (2023-04-06)
27
-
28
-
29
- ### Features
30
-
31
- * update linters ([#24](https://github.com/gravity-ui/blog-constructor/issues/24)) ([bc5aa0f](https://github.com/gravity-ui/blog-constructor/commit/bc5aa0f72e64b916acaf692874482ccdae3f94e9))
32
-
33
- ## [2.1.0](https://github.com/gravity-ui/blog-constructor/compare/v2.0.2...v2.1.0) (2023-04-06)
34
-
35
-
36
- ### Features
37
-
38
- * change source field with author description ([#5](https://github.com/gravity-ui/blog-constructor/issues/5)) ([fb7151c](https://github.com/gravity-ui/blog-constructor/commit/fb7151ceac39b2e4407c7110da0314b87c4db72b))
39
-
40
- ## [2.0.2](https://github.com/gravity-ui/blog-constructor/compare/v2.0.1...v2.0.2) (2023-04-05)
41
-
42
-
43
- ### Bug Fixes
44
-
45
- * covering pagination buttons into 'a' tag ([#23](https://github.com/gravity-ui/blog-constructor/issues/23)) ([e603f2e](https://github.com/gravity-ui/blog-constructor/commit/e603f2e2b0f86d492132174a1c8172786e7a09a1))
46
-
47
- ## [2.0.1](https://github.com/gravity-ui/blog-constructor/compare/v2.0.0...v2.0.1) (2023-04-04)
48
-
49
-
50
- ### Bug Fixes
51
-
52
- * throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([ccb0f19](https://github.com/gravity-ui/blog-constructor/commit/ccb0f19a904e54fd43ca66195da9e94925d0a26f))
53
- * throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([0aa5aed](https://github.com/gravity-ui/blog-constructor/commit/0aa5aeda9a0afd99ae8590c6b666c033a12b7fba))
54
-
55
- ## [2.0.0](https://github.com/gravity-ui/blog-constructor/compare/v1.1.2...v2.0.0) (2023-04-03)
56
-
57
-
58
- ### ⚠ BREAKING CHANGES
59
-
60
- * update uikit up to 4 ([#11](https://github.com/gravity-ui/blog-constructor/issues/11))
61
-
62
- ### Features
63
-
64
- * update uikit up to 4 ([#11](https://github.com/gravity-ui/blog-constructor/issues/11)) ([5d6f3d5](https://github.com/gravity-ui/blog-constructor/commit/5d6f3d51daf111a240871dbad721bbdd250d6b46))
65
-
66
- ## [1.1.2](https://github.com/gravity-ui/blog-constructor/compare/v1.1.1...v1.1.2) (2023-03-28)
67
-
68
-
69
- ### Bug Fixes
70
-
71
- * add info about release ([#19](https://github.com/gravity-ui/blog-constructor/issues/19)) ([8a5824f](https://github.com/gravity-ui/blog-constructor/commit/8a5824f24c4ad85f0f122111f8f5c1e7c36becc5))
72
-
73
- ## [1.1.1](https://github.com/gravity-ui/blog-constructor/compare/v1.1.0...v1.1.1) (2023-03-28)
74
-
75
-
76
- ### Bug Fixes
77
-
78
- * add info about ci in readme ([#17](https://github.com/gravity-ui/blog-constructor/issues/17)) ([b6cffaa](https://github.com/gravity-ui/blog-constructor/commit/b6cffaa1c255c53cd00d06d4fbe0330e117f42a0))
79
-
80
- ## 1.1.0 (2023-03-28)
81
-
82
- ### Features
83
-
84
- - add workflows, update @types/react, small refactors, update Select ([#2](https://github.com/gravity-ui/blog-constructor/issues/2)) ([326247a](https://github.com/gravity-ui/blog-constructor/commit/326247abe9411b50c82ed2cfa516ac6cd341bfa7))
85
- - Brush up stories, add content for CTA, Layout, Feed blocks. ([#4](https://github.com/gravity-ui/blog-constructor/issues/4)) ([0b73537](https://github.com/gravity-ui/blog-constructor/commit/0b73537b3bae35eca10610963369f3f5d8f9ecbd))
86
- - export author type ([9e5ee34](https://github.com/gravity-ui/blog-constructor/commit/9e5ee34c6b4d1b3288cda1258160e22073f9ad9d))
87
- - fix button savedOnly color ([#9](https://github.com/gravity-ui/blog-constructor/issues/9)) ([ef3b1ca](https://github.com/gravity-ui/blog-constructor/commit/ef3b1ca9048f1218817ec5c9c6a5b3e05492f062))
88
- - init tests ([#1](https://github.com/gravity-ui/blog-constructor/issues/1)) ([f8df32f](https://github.com/gravity-ui/blog-constructor/commit/f8df32f3eccb97abc7bfef222aca1ea56421619b))
89
- - **navigation:** pass the PageConstructor's navigation prop ([cb875ff](https://github.com/gravity-ui/blog-constructor/commit/cb875ff708832f5dd9e121d67cfccb387ae2499f))
90
- - uninstall doctools/components ([#14](https://github.com/gravity-ui/blog-constructor/issues/14)) ([16dc64c](https://github.com/gravity-ui/blog-constructor/commit/16dc64c3002b614831880dbe5b250c5637031c7d))
91
- - update license ([#3](https://github.com/gravity-ui/blog-constructor/issues/3)) ([aa4ee5b](https://github.com/gravity-ui/blog-constructor/commit/aa4ee5bdd01a7db5f6c6c457836658761eee1099))
92
- - update readme ([#15](https://github.com/gravity-ui/blog-constructor/issues/15)) ([3dbdf78](https://github.com/gravity-ui/blog-constructor/commit/3dbdf78b35f93024bebbcf64a6f06fb01509ae3e))
93
-
94
- ### Bug Fixes
95
-
96
- - **general:** better deps ([8c22384](https://github.com/gravity-ui/blog-constructor/commit/8c223848e47faf8b9beee6700afce317359ee226))
97
- - search input width ([051c145](https://github.com/gravity-ui/blog-constructor/commit/051c14502110306964c4ec9a2bea47cea9364db5))
98
-
99
- ## 1.0.0
100
-
101
- Create public access for blog-constructor library for creating blog format web pages.
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- export interface UserAccount {
3
- uid: string;
4
- login: string;
5
- avatarId: string;
6
- displayName?: string;
7
- lang?: string;
8
- hasStaffLogin?: boolean;
9
- }
10
- export interface User extends UserAccount {
11
- accounts: UserAccount[];
12
- passportHost: string;
13
- avatarHost: string;
14
- status: string;
15
- yandexuid: string;
16
- }
17
- export type UserContextProps = Partial<User>;
18
- export declare const UserContext: React.Context<Partial<User>>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UserContext = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- exports.UserContext = react_1.default.createContext({});
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- export interface UserAccount {
3
- uid: string;
4
- login: string;
5
- avatarId: string;
6
- displayName?: string;
7
- lang?: string;
8
- hasStaffLogin?: boolean;
9
- }
10
- export interface User extends UserAccount {
11
- accounts: UserAccount[];
12
- passportHost: string;
13
- avatarHost: string;
14
- status: string;
15
- yandexuid: string;
16
- }
17
- export type UserContextProps = Partial<User>;
18
- export declare const UserContext: React.Context<Partial<User>>;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export const UserContext = React.createContext({});