Skip to content

Commit e5f1a7d

Browse files
authored
feat: add description field to icons block (#696)
* feat: add description field to icons block * feat: added description to typografTransformer * feat: added description to typografTransformer
1 parent 38d5b88 commit e5f1a7d

File tree

5 files changed

+55
-9
lines changed

5 files changed

+55
-9
lines changed

src/blocks/Icons/Icons.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getItemContent = (item: IconsBlockProps['items'][number]) => (
1717
</Fragment>
1818
);
1919

20-
const Icons = ({title, size = 's', items}: IconsBlockProps) => {
20+
const Icons = ({title, description, size = 's', items}: IconsBlockProps) => {
2121
const {hostname} = useContext(LocationContext);
2222
const handleAnalytics = useAnalytics();
2323

@@ -30,7 +30,14 @@ const Icons = ({title, size = 's', items}: IconsBlockProps) => {
3030

3131
return (
3232
<div className={b({size})}>
33-
{title && <Title className={b('header')} title={title} colSizes={{all: 12}} />}
33+
{(title || description) && (
34+
<Title
35+
className={b('header')}
36+
title={title}
37+
subtitle={description}
38+
colSizes={{all: 12}}
39+
/>
40+
)}
3441
{items.map((item) => {
3542
const itemContent = getItemContent(item);
3643
const {url, text} = item;

src/blocks/Icons/__stories__/Icons.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {Fragment} from 'react';
22

33
import {Meta, StoryFn} from '@storybook/react';
44

5+
import {yfmTransform} from '../../../../.storybook/utils';
56
import {PageConstructor} from '../../../containers/PageConstructor/PageConstructor';
67
import {IconsBlockModel, IconsBlockProps} from '../../../models';
78
import Icons from '../Icons';
@@ -17,6 +18,10 @@ const DefaultTemplate: StoryFn<IconsBlockModel> = (args) => (
1718
<PageConstructor content={{blocks: [args]}} />
1819
);
1920

21+
const WithDescriptionTemplate: StoryFn<IconsBlockModel> = (args) => (
22+
<PageConstructor content={{blocks: [args]}} />
23+
);
24+
2025
const SizeTemplate: StoryFn<IconsBlockModel> = (args) => (
2126
<Fragment>
2227
<DefaultTemplate title="Size S" {...args} size="s" />
@@ -27,6 +32,13 @@ const SizeTemplate: StoryFn<IconsBlockModel> = (args) => (
2732

2833
export const Default = DefaultTemplate.bind([]);
2934
export const Size = SizeTemplate.bind([]);
35+
export const WithDescription = WithDescriptionTemplate.bind({});
36+
37+
const transformedText = yfmTransform(data.withDescription.content.description);
3038

3139
Default.args = data.default.content as IconsBlockProps;
3240
Size.args = data.size.content as Omit<IconsBlockProps, 'size'>;
41+
WithDescription.args = {
42+
...data.withDescription.content,
43+
description: transformedText,
44+
} as IconsBlockProps;

src/blocks/Icons/__stories__/data.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,37 @@
6161
}
6262
]
6363
}
64+
},
65+
"withDescription": {
66+
"content": {
67+
"type": "icons-block",
68+
"description": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
69+
"items": [
70+
{
71+
"src": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icons-link_1_64.svg",
72+
"text": "Lorem ipsum dolor sit amet"
73+
},
74+
{
75+
"src": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icons-link_2_64.svg",
76+
"text": "Lorem ipsum dolor sit amet",
77+
"url": "#"
78+
},
79+
{
80+
"src": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icons-link_3_64.svg",
81+
"text": "Lorem ipsum dolor sit amet",
82+
"url": "#"
83+
},
84+
{
85+
"src": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icons-link_4_64.svg",
86+
"text": "Lorem ipsum dolor sit amet",
87+
"url": "#"
88+
},
89+
{
90+
"src": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icons-link_5_64.svg",
91+
"text": "Lorem ipsum dolor sit amet",
92+
"url": "#"
93+
}
94+
]
95+
}
6496
}
6597
}

src/models/constructor-items/blocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ export interface IconsBlockItemProps extends AnalyticsEventsBase {
330330

331331
export interface IconsBlockProps {
332332
title?: string;
333+
description?: string;
333334
size?: 's' | 'm' | 'l';
334335
items: IconsBlockItemProps[];
335336
}

src/text-transform/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,5 @@ export const config: BlocksConfig = {
361361
},
362362
],
363363
[BlockType.CardLayoutBlock]: blockHeaderTransformer,
364-
[BlockType.IconsBlock]: [
365-
{
366-
fields: ['title'],
367-
transformer: typografTransformer,
368-
parser: parseTitle,
369-
},
370-
],
364+
[BlockType.IconsBlock]: blockHeaderTransformer,
371365
};

0 commit comments

Comments
 (0)