@gravity-ui/blog-constructor 3.1.0-alpha.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
@@ -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 { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
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 (!hasLikes) {
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: hasLikes, 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: hasLikes }) }, title))));
75
+ react_1.default.createElement("span", { className: b('title', { cursor: isLikeable }) }, title))));
75
76
  };
76
77
  exports.Save = 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 { hasLikes } = useContext(LikesContext);
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 (!hasLikes) {
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: hasLikes, 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: hasLikes }) }, title))));
47
+ React.createElement("span", { className: b('title', { cursor: isLikeable }) }, title))));
47
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.1.0-alpha.1",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {