Skip to content

Commit 2640b74

Browse files
author
Juli Ovechkina
authored
Merge pull request #61 from gravity-ui/yuberdysheva/extendend-features-fix
fix(ExtendedFeatures): add props
2 parents b52d707 + b98eccc commit 2640b74

File tree

4 files changed

+67
-72
lines changed

4 files changed

+67
-72
lines changed

src/blocks/ExtendedFeatures/ExtendedFeatures.tsx

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,51 @@ export const ExtendedFeaturesBlock = ({
3333
<BlockHeader title={title} description={description} className={b('header')} />
3434
<div className={b('items')}>
3535
<Row>
36-
{items.map(({title: itemTitle, text, link, links, label, icon}) => {
37-
const itemLinks = links || [];
36+
{items.map(
37+
({
38+
title: itemTitle,
39+
text,
40+
link,
41+
links,
42+
label,
43+
icon,
44+
buttons,
45+
additionalInfo,
46+
}) => {
47+
const itemLinks = links || [];
3848

39-
const iconThemed = icon && getThemedValue(icon, theme);
40-
const iconData = iconThemed && getMediaImage(iconThemed);
49+
const iconThemed = icon && getThemedValue(icon, theme);
50+
const iconData = iconThemed && getMediaImage(iconThemed);
4151

42-
if (link) {
43-
itemLinks.push(link);
44-
}
52+
if (link) {
53+
itemLinks.push(link);
54+
}
4555

46-
return (
47-
<Col className={b('item')} key={text || itemTitle} sizes={colSizes}>
48-
{iconData && <Image {...iconData} className={b('icon')} />}
49-
<div className={b('container')}>
50-
{itemTitle && (
51-
<h5 className={b('item-title')}>
52-
<HTML>{itemTitle}</HTML>
53-
{label && (
54-
<div className={b('item-label')}>{label}</div>
55-
)}
56-
</h5>
57-
)}
58-
<Content
59-
text={text}
60-
links={itemLinks}
61-
size="s"
62-
colSizes={{all: 12, md: 12}}
63-
/>
64-
</div>
65-
</Col>
66-
);
67-
})}
56+
return (
57+
<Col className={b('item')} key={text || itemTitle} sizes={colSizes}>
58+
{iconData && <Image {...iconData} className={b('icon')} />}
59+
<div className={b('container')}>
60+
{itemTitle && (
61+
<h5 className={b('item-title')}>
62+
<HTML>{itemTitle}</HTML>
63+
{label && (
64+
<div className={b('item-label')}>{label}</div>
65+
)}
66+
</h5>
67+
)}
68+
<Content
69+
text={text}
70+
links={itemLinks}
71+
size="s"
72+
colSizes={{all: 12, md: 12}}
73+
buttons={buttons}
74+
additionalInfo={additionalInfo}
75+
/>
76+
</div>
77+
</Col>
78+
);
79+
},
80+
)}
6881
</Row>
6982
</div>
7083
</AnimateBlock>

src/blocks/ExtendedFeatures/__stories__/ExtendedFeatures.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const extendedFeaturesItems = (items: ExtendedFeaturesItem[]) => {
3232
return items.map((item) => ({
3333
...item,
3434
text: item.text && yfmTransform(item.text),
35+
additionalInfo: item.additionalInfo && yfmTransform(item.additionalInfo),
3536
}));
3637
};
3738

src/blocks/ExtendedFeatures/__stories__/data.json

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@
1414
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_light.svg",
1515
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_dark.svg"
1616
},
17-
"links": [
18-
{
19-
"text": "Go",
20-
"url": "#",
21-
"arrow": true,
22-
"theme": "normal"
23-
}
24-
]
17+
"additionalInfo": "Duis aute irure dolor in [reprehenderit](https://example.com) n voluptate velit esse cillum dolore eu fugiat nulla pariatur."
2518
},
2619
{
2720
"title": "Sed do eiusmod tempor",
@@ -30,12 +23,16 @@
3023
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_light.svg",
3124
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_dark.svg"
3225
},
33-
"links": [
26+
"buttons": [
3427
{
35-
"text": "Go",
36-
"url": "#",
37-
"arrow": true,
38-
"theme": "normal"
28+
"text": "Button",
29+
"theme": "action",
30+
"url": "https://example.com"
31+
},
32+
{
33+
"text": "Button",
34+
"theme": "outlined",
35+
"url": "https://example.com"
3936
}
4037
]
4138
},
@@ -67,26 +64,13 @@
6764
},
6865
"items": [
6966
{
70-
"title": "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
67+
"title": "Sed do eiusmod tempor",
7168
"text": "Ut enim ad minim veniam [quis nostrud](https://example.com) ullamco laboris nisi ut aliquip ex ea commodo consequat.",
7269
"icon": {
7370
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_light.svg",
7471
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_dark.svg"
7572
},
76-
"link": {
77-
"text": "Go",
78-
"url": "#",
79-
"arrow": true,
80-
"theme": "normal"
81-
},
82-
"links": [
83-
{
84-
"text": "Go",
85-
"url": "#",
86-
"arrow": true,
87-
"theme": "normal"
88-
}
89-
],
73+
"additionalInfo": "Duis aute irure dolor in [reprehenderit](https://example.com) n voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
9074
"label": "New"
9175
},
9276
{
@@ -96,18 +80,16 @@
9680
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_light.svg",
9781
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_dark.svg"
9882
},
99-
"link": {
100-
"text": "Go",
101-
"url": "#",
102-
"arrow": true,
103-
"theme": "normal"
104-
},
105-
"links": [
83+
"buttons": [
10684
{
107-
"text": "Go",
108-
"url": "#",
109-
"arrow": true,
110-
"theme": "normal"
85+
"text": "Button",
86+
"theme": "action",
87+
"url": "https://example.com"
88+
},
89+
{
90+
"text": "Button",
91+
"theme": "outlined",
92+
"url": "https://example.com"
11193
}
11294
],
11395
"label": "Preview"

src/models/constructor-items/blocks.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,13 @@ export interface SimpleBlockProps extends Animatable, Childable {
164164
description: string;
165165
}
166166

167-
export interface ExtendedFeaturesItem {
168-
title?: string;
169-
text?: string;
167+
export interface ExtendedFeaturesItem
168+
extends Omit<ContentBlockProps, 'theme' | 'centered' | 'colSizes' | 'size' | 'title'> {
169+
title: string;
170170
label?: string;
171171
icon?: ThemedImage;
172172
/** @deprecated **/
173173
link?: LinkProps;
174-
links?: LinkProps[];
175174
}
176175

177176
export interface ExtendedFeaturesProps extends Animatable {

0 commit comments

Comments
 (0)