@gravity-ui/page-constructor 1.6.1 → 1.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.7.0](https://github.com/gravity-ui/page-constructor/compare/v1.6.1...v1.7.0) (2022-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * **ExtendedFeatures:** add content ([#51](https://github.com/gravity-ui/page-constructor/issues/51)) ([0990563](https://github.com/gravity-ui/page-constructor/commit/0990563a62c3f8f4d4cfb206cedb7a1205cb1797))
9
+
3
10
  ## [1.6.1](https://github.com/gravity-ui/page-constructor/compare/v1.4.1...v1.6.1) (2022-11-10)
4
11
 
5
12
  ### Bug Fixes
@@ -12,6 +12,8 @@ unpredictable css rules order in build */
12
12
  }
13
13
  .pc-ExtendedFeaturesBlock__item {
14
14
  margin-top: 32px;
15
+ }
16
+ .pc-ExtendedFeaturesBlock__item.col {
15
17
  padding-right: 32px;
16
18
  }
17
19
  .pc-ExtendedFeaturesBlock__item-title {
@@ -74,12 +76,15 @@ unpredictable css rules order in build */
74
76
  height: 32px;
75
77
  background-size: cover;
76
78
  display: block;
77
- margin-bottom: 8px;
79
+ margin-bottom: 12px;
78
80
  }
79
81
  @media (max-width: 577px) {
80
82
  .pc-ExtendedFeaturesBlock__item {
81
83
  margin-top: 32px;
82
84
  }
85
+ .pc-ExtendedFeaturesBlock__item.col {
86
+ padding-right: 8px;
87
+ }
83
88
  }
84
89
  @media (min-width: 769px) {
85
90
  .pc-ExtendedFeaturesBlock.pc-AnimateBlock .pc-ExtendedFeaturesBlock__item, .pc-AnimateBlock .pc-ExtendedFeaturesBlock .pc-ExtendedFeaturesBlock__item {
@@ -2,26 +2,40 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExtendedFeaturesBlock = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const react_1 = (0, tslib_1.__importDefault)(require("react"));
5
+ const react_1 = (0, tslib_1.__importStar)(require("react"));
6
6
  const utils_1 = require("../../utils");
7
7
  const grid_1 = require("../../grid");
8
8
  const components_1 = require("../../components/");
9
+ const sub_blocks_1 = require("../../sub-blocks");
10
+ const Image_1 = (0, tslib_1.__importDefault)(require("../../components/Image/Image"));
11
+ const ThemeValueContext_1 = require("../../context/theme/ThemeValueContext");
12
+ const utils_2 = require("../../components/Media/Image/utils");
9
13
  const b = (0, utils_1.block)('ExtendedFeaturesBlock');
10
14
  const DEFAULT_SIZES = {
11
15
  all: 12,
12
16
  sm: 6,
13
17
  md: 4,
14
18
  };
15
- const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_SIZES, animated, }) => (react_1.default.createElement(components_1.AnimateBlock, { className: b(), animate: animated },
16
- react_1.default.createElement(components_1.BlockHeader, { title: title, description: description, className: b('header') }),
17
- react_1.default.createElement("div", { className: b('items') },
18
- react_1.default.createElement(grid_1.Row, null, items.map(({ title: itemTitle, text, link, label, icon }) => (react_1.default.createElement(grid_1.Col, { className: b('item'), key: text || itemTitle, sizes: colSizes },
19
- icon && react_1.default.createElement("img", { src: icon, className: b('icon') }),
20
- itemTitle && (react_1.default.createElement("h5", { className: b('item-title', { 'has-label': Boolean(label) }) },
21
- react_1.default.createElement(components_1.HTML, null, itemTitle),
22
- label && react_1.default.createElement("div", { className: b('item-label') }, label))),
23
- text && (react_1.default.createElement("div", { className: b('item-text') },
24
- react_1.default.createElement(components_1.HTML, null, text))),
25
- link && react_1.default.createElement(components_1.Link, Object.assign({ className: b('item-link') }, link)))))))));
19
+ const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_SIZES, animated, }) => {
20
+ const { themeValue: theme } = (0, react_1.useContext)(ThemeValueContext_1.ThemeValueContext);
21
+ return (react_1.default.createElement(components_1.AnimateBlock, { className: b(), animate: animated },
22
+ react_1.default.createElement(components_1.BlockHeader, { title: title, description: description, className: b('header') }),
23
+ react_1.default.createElement("div", { className: b('items') },
24
+ react_1.default.createElement(grid_1.Row, null, items.map(({ title: itemTitle, text, link, links, label, icon }) => {
25
+ const itemLinks = links || [];
26
+ const iconThemed = icon && (0, utils_1.getThemedValue)(icon, theme);
27
+ const iconData = iconThemed && (0, utils_2.getMediaImage)(iconThemed);
28
+ if (link) {
29
+ itemLinks.push(link);
30
+ }
31
+ return (react_1.default.createElement(grid_1.Col, { className: b('item'), key: text || itemTitle, sizes: colSizes },
32
+ iconData && react_1.default.createElement(Image_1.default, Object.assign({}, iconData, { className: b('icon') })),
33
+ react_1.default.createElement("div", { className: b('container') },
34
+ itemTitle && (react_1.default.createElement("h5", { className: b('item-title') },
35
+ react_1.default.createElement(components_1.HTML, null, itemTitle),
36
+ label && (react_1.default.createElement("div", { className: b('item-label') }, label)))),
37
+ react_1.default.createElement(sub_blocks_1.Content, { text: text, links: itemLinks, size: "s", colSizes: { all: 12, md: 12 } }))));
38
+ })))));
39
+ };
26
40
  exports.ExtendedFeaturesBlock = ExtendedFeaturesBlock;
27
41
  exports.default = exports.ExtendedFeaturesBlock;
@@ -118,8 +118,10 @@ export interface ExtendedFeaturesItem {
118
118
  title?: string;
119
119
  text?: string;
120
120
  label?: string;
121
- icon?: string;
121
+ icon?: ThemedImage;
122
+ /** @deprecated **/
122
123
  link?: LinkProps;
124
+ links?: LinkProps[];
123
125
  }
124
126
  export interface ExtendedFeaturesProps extends Animatable {
125
127
  items: ExtendedFeaturesItem[];
@@ -155,7 +155,12 @@ const config = {
155
155
  {
156
156
  fields: ['items'],
157
157
  transformer: typografTransformer,
158
- parser: parseFeatures,
158
+ parser: (0, exports.createItemsParser)(['title']),
159
+ },
160
+ {
161
+ fields: ['items'],
162
+ transformer: yfmTransformer,
163
+ parser: (0, exports.createItemsParser)(['text', 'additionalInfo']),
159
164
  },
160
165
  ],
161
166
  [models_1.BlockType.PromoFeaturesBlock]: {
@@ -12,6 +12,8 @@ unpredictable css rules order in build */
12
12
  }
13
13
  .pc-ExtendedFeaturesBlock__item {
14
14
  margin-top: 32px;
15
+ }
16
+ .pc-ExtendedFeaturesBlock__item.col {
15
17
  padding-right: 32px;
16
18
  }
17
19
  .pc-ExtendedFeaturesBlock__item-title {
@@ -74,12 +76,15 @@ unpredictable css rules order in build */
74
76
  height: 32px;
75
77
  background-size: cover;
76
78
  display: block;
77
- margin-bottom: 8px;
79
+ margin-bottom: 12px;
78
80
  }
79
81
  @media (max-width: 577px) {
80
82
  .pc-ExtendedFeaturesBlock__item {
81
83
  margin-top: 32px;
82
84
  }
85
+ .pc-ExtendedFeaturesBlock__item.col {
86
+ padding-right: 8px;
87
+ }
83
88
  }
84
89
  @media (min-width: 769px) {
85
90
  .pc-ExtendedFeaturesBlock.pc-AnimateBlock .pc-ExtendedFeaturesBlock__item, .pc-AnimateBlock .pc-ExtendedFeaturesBlock .pc-ExtendedFeaturesBlock__item {
@@ -1,7 +1,11 @@
1
- import React from 'react';
2
- import { block } from '../../utils';
1
+ import React, { useContext } from 'react';
2
+ import { block, getThemedValue } from '../../utils';
3
3
  import { Row, Col } from '../../grid';
4
- import { Link, HTML, AnimateBlock, BlockHeader } from '../../components/';
4
+ import { AnimateBlock, BlockHeader, HTML } from '../../components/';
5
+ import { Content } from '../../sub-blocks';
6
+ import Image from '../../components/Image/Image';
7
+ import { ThemeValueContext } from '../../context/theme/ThemeValueContext';
8
+ import { getMediaImage } from '../../components/Media/Image/utils';
5
9
  import './ExtendedFeatures.css';
6
10
  const b = block('ExtendedFeaturesBlock');
7
11
  const DEFAULT_SIZES = {
@@ -9,15 +13,25 @@ const DEFAULT_SIZES = {
9
13
  sm: 6,
10
14
  md: 4,
11
15
  };
12
- export const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_SIZES, animated, }) => (React.createElement(AnimateBlock, { className: b(), animate: animated },
13
- React.createElement(BlockHeader, { title: title, description: description, className: b('header') }),
14
- React.createElement("div", { className: b('items') },
15
- React.createElement(Row, null, items.map(({ title: itemTitle, text, link, label, icon }) => (React.createElement(Col, { className: b('item'), key: text || itemTitle, sizes: colSizes },
16
- icon && React.createElement("img", { src: icon, className: b('icon') }),
17
- itemTitle && (React.createElement("h5", { className: b('item-title', { 'has-label': Boolean(label) }) },
18
- React.createElement(HTML, null, itemTitle),
19
- label && React.createElement("div", { className: b('item-label') }, label))),
20
- text && (React.createElement("div", { className: b('item-text') },
21
- React.createElement(HTML, null, text))),
22
- link && React.createElement(Link, Object.assign({ className: b('item-link') }, link)))))))));
16
+ export const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_SIZES, animated, }) => {
17
+ const { themeValue: theme } = useContext(ThemeValueContext);
18
+ return (React.createElement(AnimateBlock, { className: b(), animate: animated },
19
+ React.createElement(BlockHeader, { title: title, description: description, className: b('header') }),
20
+ React.createElement("div", { className: b('items') },
21
+ React.createElement(Row, null, items.map(({ title: itemTitle, text, link, links, label, icon }) => {
22
+ const itemLinks = links || [];
23
+ const iconThemed = icon && getThemedValue(icon, theme);
24
+ const iconData = iconThemed && getMediaImage(iconThemed);
25
+ if (link) {
26
+ itemLinks.push(link);
27
+ }
28
+ return (React.createElement(Col, { className: b('item'), key: text || itemTitle, sizes: colSizes },
29
+ iconData && React.createElement(Image, Object.assign({}, iconData, { className: b('icon') })),
30
+ React.createElement("div", { className: b('container') },
31
+ itemTitle && (React.createElement("h5", { className: b('item-title') },
32
+ React.createElement(HTML, null, itemTitle),
33
+ label && (React.createElement("div", { className: b('item-label') }, label)))),
34
+ React.createElement(Content, { text: text, links: itemLinks, size: "s", colSizes: { all: 12, md: 12 } }))));
35
+ })))));
36
+ };
23
37
  export default ExtendedFeaturesBlock;
@@ -118,8 +118,10 @@ export interface ExtendedFeaturesItem {
118
118
  title?: string;
119
119
  text?: string;
120
120
  label?: string;
121
- icon?: string;
121
+ icon?: ThemedImage;
122
+ /** @deprecated **/
122
123
  link?: LinkProps;
124
+ links?: LinkProps[];
123
125
  }
124
126
  export interface ExtendedFeaturesProps extends Animatable {
125
127
  items: ExtendedFeaturesItem[];
@@ -149,7 +149,12 @@ const config = {
149
149
  {
150
150
  fields: ['items'],
151
151
  transformer: typografTransformer,
152
- parser: parseFeatures,
152
+ parser: createItemsParser(['title']),
153
+ },
154
+ {
155
+ fields: ['items'],
156
+ transformer: yfmTransformer,
157
+ parser: createItemsParser(['text', 'additionalInfo']),
153
158
  },
154
159
  ],
155
160
  [BlockType.PromoFeaturesBlock]: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -118,8 +118,10 @@ export interface ExtendedFeaturesItem {
118
118
  title?: string;
119
119
  text?: string;
120
120
  label?: string;
121
- icon?: string;
121
+ icon?: ThemedImage;
122
+ /** @deprecated **/
122
123
  link?: LinkProps;
124
+ links?: LinkProps[];
123
125
  }
124
126
  export interface ExtendedFeaturesProps extends Animatable {
125
127
  items: ExtendedFeaturesItem[];
@@ -168,7 +168,12 @@ const config = {
168
168
  {
169
169
  fields: ['items'],
170
170
  transformer: typografTransformer,
171
- parser: parseFeatures,
171
+ parser: (0, exports.createItemsParser)(['title']),
172
+ },
173
+ {
174
+ fields: ['items'],
175
+ transformer: yfmTransformer,
176
+ parser: (0, exports.createItemsParser)(['text', 'additionalInfo']),
172
177
  },
173
178
  ],
174
179
  [models_1.BlockType.PromoFeaturesBlock]: {