@gravity-ui/blog-constructor 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.3.0](https://github.com/gravity-ui/blog-constructor/compare/v3.2.1...v3.3.0) (2023-05-16)
4
+
5
+
6
+ ### Features
7
+
8
+ * add md breackpoint to cta-block ([#45](https://github.com/gravity-ui/blog-constructor/issues/45)) ([e859b0b](https://github.com/gravity-ui/blog-constructor/commit/e859b0b02e80b20eb0b4496e2c4834fb2de74922))
9
+
10
+ ## [3.2.1](https://github.com/gravity-ui/blog-constructor/compare/v3.2.0...v3.2.1) (2023-05-16)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add settings context to add a tag for pagination ([#47](https://github.com/gravity-ui/blog-constructor/issues/47)) ([0856675](https://github.com/gravity-ui/blog-constructor/commit/0856675316425c9a690664a99d30d2af63e116ca))
16
+
3
17
  ## [3.2.0](https://github.com/gravity-ui/blog-constructor/compare/v3.1.1...v3.2.0) (2023-05-15)
4
18
 
5
19
 
@@ -8,49 +8,27 @@
8
8
  flex-direction: column;
9
9
  flex-grow: 1;
10
10
  padding: 32px;
11
- }
12
- .bc-cta__button {
13
- display: flex;
14
- padding-bottom: 16px;
11
+ width: calc(33.3333333333% - (32px / 2));
15
12
  }
16
13
  .bc-cta__content {
17
14
  display: flex;
18
- flex-direction: column;
15
+ flex-flow: row wrap;
16
+ gap: 16px;
19
17
  }
20
- @media (min-width: 577px) {
18
+ @media (max-width: 769px) {
21
19
  .bc-cta__content {
22
- display: flex;
23
- flex-direction: row;
24
- }
25
- .bc-cta__button {
26
- padding-bottom: 0px;
27
- }
28
- .bc-cta__button_layout {
29
- width: 100%;
30
- max-width: 100%;
31
- margin-right: 0px;
20
+ flex-wrap: wrap;
32
21
  }
33
- .bc-cta__button_layout_2 {
34
- width: calc(50% - (16px / 2));
35
- max-width: 50%;
36
- margin-right: 16px;
22
+ .bc-cta__card {
23
+ width: calc((100% / 2) - 16px);
24
+ flex-grow: 1;
37
25
  }
38
- .bc-cta__button_layout_2:nth-child(2n) {
39
- margin-right: 0px;
40
- }
41
- .bc-cta__button_layout_3 {
42
- width: calc(33.3333333333% - (32px / 3));
43
- margin-right: 16px;
44
- }
45
- .bc-cta__button_layout_3:nth-child(3n) {
46
- margin-right: 0px;
47
- }
48
- .bc-cta__button_layout_4 {
49
- width: calc(25% - (48px / 4));
50
- max-width: 50%;
51
- margin-right: 16px;
26
+ }
27
+ @media (max-width: 577px) {
28
+ .bc-cta__content {
29
+ flex-direction: column;
52
30
  }
53
- .bc-cta__button_layout_4:nth-child(4n) {
54
- margin-right: 0px;
31
+ .bc-cta__card {
32
+ width: 100%;
55
33
  }
56
34
  }
@@ -12,15 +12,7 @@ const paddings_1 = require("../../models/paddings");
12
12
  const cn_1 = require("../../utils/cn");
13
13
  const common_1 = require("../../utils/common");
14
14
  const b = (0, cn_1.block)('cta');
15
- const MAX_COLUMN_COUNT = 4, MIN_COLUMN_COUNT = 2, DEFAULT_COLUMN_COUNT = 3;
16
15
  const CTA = ({ items, paddingTop, paddingBottom }) => {
17
- let count = items ? items.length : DEFAULT_COLUMN_COUNT;
18
- if (count < MIN_COLUMN_COUNT) {
19
- count = MIN_COLUMN_COUNT;
20
- }
21
- else if (count > MAX_COLUMN_COUNT) {
22
- count = MAX_COLUMN_COUNT;
23
- }
24
16
  /**
25
17
  * @deprecated Metrika will be deleted after launch of analyticsEvents
26
18
  */
@@ -31,18 +23,15 @@ const CTA = ({ items, paddingTop, paddingBottom }) => {
31
23
  return (react_1.default.createElement(Wrapper_1.Wrapper, { paddings: {
32
24
  [paddings_1.PaddingsDirections.top]: paddingTop,
33
25
  [paddings_1.PaddingsDirections.bottom]: paddingBottom,
34
- }, className: b('content'), dataQa: "blog-cta-content" }, items.slice(0, count).map((content, index) => {
26
+ }, className: b('content'), dataQa: "blog-cta-content" }, items.map((content, index) => {
35
27
  var _a;
36
28
  const contentData = (0, common_1.updateContentSizes)(content);
37
29
  (_a = contentData.links) === null || _a === void 0 ? void 0 : _a.forEach((link) => {
38
30
  // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
39
31
  link.metrikaGoals = (0, common_1.getBlogElementMetrika)(metrikaGoal, link.metrikaGoals);
40
32
  });
41
- return (react_1.default.createElement("div", { key: index, className: b('button', {
42
- ['layout']: count,
43
- }), "data-qa": "blog-cta-card" },
44
- react_1.default.createElement("div", { className: b('card') },
45
- react_1.default.createElement(page_constructor_1.Content, Object.assign({}, contentData)))));
33
+ return (react_1.default.createElement("div", { key: index, className: b('card'), "data-qa": "blog-cta-card" },
34
+ react_1.default.createElement(page_constructor_1.Content, Object.assign({}, contentData))));
46
35
  })));
47
36
  };
48
37
  exports.CTA = CTA;
@@ -9,7 +9,6 @@ unpredictable css rules order in build */
9
9
  }
10
10
  .bc-paginator__link {
11
11
  text-decoration: none;
12
- pointer-events: none;
13
12
  color: var(--yc-color-text-primary);
14
13
  }
15
14
  .bc-paginator__item {
@@ -27,16 +27,18 @@ exports.PaginatorItem = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const uikit_1 = require("@gravity-ui/uikit");
29
29
  const LocaleContext_1 = require("../../../contexts/LocaleContext");
30
+ const SettingsContext_1 = require("../../../contexts/SettingsContext");
30
31
  const cn_1 = require("../../../utils/cn");
31
32
  const common_1 = require("../../../utils/common");
32
33
  const b = (0, cn_1.block)('paginator');
33
34
  const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, index, }) => {
34
35
  const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
36
+ const { addNavigationLinkForPages } = (0, react_1.useContext)(SettingsContext_1.SettingsContext);
35
37
  const urlPath = (0, common_1.getBlogPath)((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
36
38
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
37
39
  const navTag = index > 1 ? `?page=${index}` : '';
38
40
  const navigationLink = `${urlPath || ''}${navTag}`;
39
- return (react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) },
40
- react_1.default.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, content)));
41
+ const renderButton = (react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content));
42
+ return (react_1.default.createElement(react_1.Fragment, null, addNavigationLinkForPages ? (react_1.default.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, renderButton)) : (react_1.default.createElement(react_1.Fragment, null, renderButton))));
41
43
  };
42
44
  exports.PaginatorItem = PaginatorItem;
@@ -2,6 +2,7 @@ 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 { SettingsContextProps } from '../contexts/SettingsContext';
5
6
  import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
6
7
  import { Locale } from '../models/locale';
7
8
  export interface BlogConstructorProviderProps {
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
11
12
  theme?: ThemeValueType;
12
13
  device?: DeviceContextProps;
13
14
  analytics?: AnalyticsContextProps;
15
+ settings?: SettingsContextProps;
14
16
  children?: React.ReactNode;
15
17
  }
16
18
  export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
@@ -31,14 +31,16 @@ 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 SettingsContext_1 = require("../contexts/SettingsContext");
34
35
  const ThemeValueContext_1 = require("../contexts/theme/ThemeValueContext");
35
- const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
36
+ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = constants_1.DEFAULT_THEME, device = {}, analytics = {}, settings = {}, children, }) => {
36
37
  const context = [
37
38
  react_1.default.createElement(ThemeValueContext_1.ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
38
39
  react_1.default.createElement(LocaleContext_1.LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
39
40
  react_1.default.createElement(RouterContext_1.RouterContext.Provider, { value: router, key: "router-context" }),
40
41
  react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
41
42
  react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
43
+ react_1.default.createElement(SettingsContext_1.SettingsContext.Provider, { value: settings, key: "settings-context" }),
42
44
  react_1.default.createElement(page_constructor_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
43
45
  ].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
44
46
  return react_1.default.createElement(react_1.Fragment, null, context);
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface SettingsContextProps {
3
+ addNavigationLinkForPages?: boolean;
4
+ }
5
+ export declare const SettingsContext: React.Context<SettingsContextProps>;
@@ -0,0 +1,8 @@
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.SettingsContext = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ exports.SettingsContext = react_1.default.createContext({});
@@ -8,49 +8,27 @@
8
8
  flex-direction: column;
9
9
  flex-grow: 1;
10
10
  padding: 32px;
11
- }
12
- .bc-cta__button {
13
- display: flex;
14
- padding-bottom: 16px;
11
+ width: calc(33.3333333333% - (32px / 2));
15
12
  }
16
13
  .bc-cta__content {
17
14
  display: flex;
18
- flex-direction: column;
15
+ flex-flow: row wrap;
16
+ gap: 16px;
19
17
  }
20
- @media (min-width: 577px) {
18
+ @media (max-width: 769px) {
21
19
  .bc-cta__content {
22
- display: flex;
23
- flex-direction: row;
24
- }
25
- .bc-cta__button {
26
- padding-bottom: 0px;
27
- }
28
- .bc-cta__button_layout {
29
- width: 100%;
30
- max-width: 100%;
31
- margin-right: 0px;
20
+ flex-wrap: wrap;
32
21
  }
33
- .bc-cta__button_layout_2 {
34
- width: calc(50% - (16px / 2));
35
- max-width: 50%;
36
- margin-right: 16px;
22
+ .bc-cta__card {
23
+ width: calc((100% / 2) - 16px);
24
+ flex-grow: 1;
37
25
  }
38
- .bc-cta__button_layout_2:nth-child(2n) {
39
- margin-right: 0px;
40
- }
41
- .bc-cta__button_layout_3 {
42
- width: calc(33.3333333333% - (32px / 3));
43
- margin-right: 16px;
44
- }
45
- .bc-cta__button_layout_3:nth-child(3n) {
46
- margin-right: 0px;
47
- }
48
- .bc-cta__button_layout_4 {
49
- width: calc(25% - (48px / 4));
50
- max-width: 50%;
51
- margin-right: 16px;
26
+ }
27
+ @media (max-width: 577px) {
28
+ .bc-cta__content {
29
+ flex-direction: column;
52
30
  }
53
- .bc-cta__button_layout_4:nth-child(4n) {
54
- margin-right: 0px;
31
+ .bc-cta__card {
32
+ width: 100%;
55
33
  }
56
34
  }
@@ -7,15 +7,7 @@ import { block } from '../../utils/cn';
7
7
  import { getBlogElementMetrika, updateContentSizes } from '../../utils/common';
8
8
  import './CTA.css';
9
9
  const b = block('cta');
10
- const MAX_COLUMN_COUNT = 4, MIN_COLUMN_COUNT = 2, DEFAULT_COLUMN_COUNT = 3;
11
10
  export const CTA = ({ items, paddingTop, paddingBottom }) => {
12
- let count = items ? items.length : DEFAULT_COLUMN_COUNT;
13
- if (count < MIN_COLUMN_COUNT) {
14
- count = MIN_COLUMN_COUNT;
15
- }
16
- else if (count > MAX_COLUMN_COUNT) {
17
- count = MAX_COLUMN_COUNT;
18
- }
19
11
  /**
20
12
  * @deprecated Metrika will be deleted after launch of analyticsEvents
21
13
  */
@@ -26,17 +18,14 @@ export const CTA = ({ items, paddingTop, paddingBottom }) => {
26
18
  return (React.createElement(Wrapper, { paddings: {
27
19
  [PaddingsDirections.top]: paddingTop,
28
20
  [PaddingsDirections.bottom]: paddingBottom,
29
- }, className: b('content'), dataQa: "blog-cta-content" }, items.slice(0, count).map((content, index) => {
21
+ }, className: b('content'), dataQa: "blog-cta-content" }, items.map((content, index) => {
30
22
  var _a;
31
23
  const contentData = updateContentSizes(content);
32
24
  (_a = contentData.links) === null || _a === void 0 ? void 0 : _a.forEach((link) => {
33
25
  // eslint-disable-next-line no-not-accumulator-reassign/no-not-accumulator-reassign
34
26
  link.metrikaGoals = getBlogElementMetrika(metrikaGoal, link.metrikaGoals);
35
27
  });
36
- return (React.createElement("div", { key: index, className: b('button', {
37
- ['layout']: count,
38
- }), "data-qa": "blog-cta-card" },
39
- React.createElement("div", { className: b('card') },
40
- React.createElement(Content, Object.assign({}, contentData)))));
28
+ return (React.createElement("div", { key: index, className: b('card'), "data-qa": "blog-cta-card" },
29
+ React.createElement(Content, Object.assign({}, contentData))));
41
30
  })));
42
31
  };
@@ -9,7 +9,6 @@ unpredictable css rules order in build */
9
9
  }
10
10
  .bc-paginator__link {
11
11
  text-decoration: none;
12
- pointer-events: none;
13
12
  color: var(--yc-color-text-primary);
14
13
  }
15
14
  .bc-paginator__item {
@@ -1,16 +1,18 @@
1
- import React, { useContext } from 'react';
1
+ import React, { Fragment, useContext } from 'react';
2
2
  import { Button } from '@gravity-ui/uikit';
3
3
  import { LocaleContext } from '../../../contexts/LocaleContext';
4
+ import { SettingsContext } from '../../../contexts/SettingsContext';
4
5
  import { block } from '../../../utils/cn';
5
6
  import { getBlogPath } from '../../../utils/common';
6
7
  import '../Paginator.css';
7
8
  const b = block('paginator');
8
9
  export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, index, }) => {
9
10
  const { locale } = useContext(LocaleContext);
11
+ const { addNavigationLinkForPages } = useContext(SettingsContext);
10
12
  const urlPath = getBlogPath((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
11
13
  const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
12
14
  const navTag = index > 1 ? `?page=${index}` : '';
13
15
  const navigationLink = `${urlPath || ''}${navTag}`;
14
- return (React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) },
15
- React.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, content)));
16
+ const renderButton = (React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content));
17
+ return (React.createElement(Fragment, null, addNavigationLinkForPages ? (React.createElement("a", { href: navigationLink, className: b('link'), onClick: (event) => event.preventDefault() }, renderButton)) : (React.createElement(Fragment, null, renderButton))));
16
18
  };
@@ -2,6 +2,7 @@ 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 { SettingsContextProps } from '../contexts/SettingsContext';
5
6
  import { ThemeValueType } from '../contexts/theme/ThemeValueContext';
6
7
  import { Locale } from '../models/locale';
7
8
  export interface BlogConstructorProviderProps {
@@ -11,6 +12,7 @@ export interface BlogConstructorProviderProps {
11
12
  theme?: ThemeValueType;
12
13
  device?: DeviceContextProps;
13
14
  analytics?: AnalyticsContextProps;
15
+ settings?: SettingsContextProps;
14
16
  children?: React.ReactNode;
15
17
  }
16
18
  export declare const BlogConstructorProvider: React.FC<BlogConstructorProviderProps>;
@@ -5,14 +5,16 @@ 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 { SettingsContext } from '../contexts/SettingsContext';
8
9
  import { ThemeValueContext } from '../contexts/theme/ThemeValueContext';
9
- export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, children, }) => {
10
+ export const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = DEFAULT_THEME, device = {}, analytics = {}, settings = {}, children, }) => {
10
11
  const context = [
11
12
  React.createElement(ThemeValueContext.Provider, { value: { themeValue: theme }, key: "theme-context" }),
12
13
  React.createElement(LocaleContext.Provider, { value: { locale }, key: "locale-context" }),
13
14
  React.createElement(RouterContext.Provider, { value: router, key: "router-context" }),
14
15
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
15
16
  React.createElement(DeviceContext.Provider, { value: device, key: "device-context" }),
17
+ React.createElement(SettingsContext.Provider, { value: settings, key: "settings-context" }),
16
18
  React.createElement(AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
17
19
  ].reduceRight((prev, provider) => React.cloneElement(provider, {}, prev), children);
18
20
  return React.createElement(Fragment, null, context);
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface SettingsContextProps {
3
+ addNavigationLinkForPages?: boolean;
4
+ }
5
+ export declare const SettingsContext: React.Context<SettingsContextProps>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export const SettingsContext = React.createContext({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/blog-constructor",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Gravity UI Blog Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {