Skip to content

Commit f305732

Browse files
VitaliiDC8Juli Ovechkina
andauthored
feat: added description field to companies block (#692)
* feat: added description field to companies block * feat: use Titel Block instead of h2 and YFMWrapper * Update src/blocks/Companies/__stories__/Companies.mdx Co-authored-by: Juli Ovechkina <[email protected]> * feat: added story with description * feat: added blockHeaderTransform * feat: added description to data.json --------- Co-authored-by: Juli Ovechkina <[email protected]>
1 parent cee8700 commit f305732

File tree

7 files changed

+40
-7
lines changed

7 files changed

+40
-7
lines changed

src/blocks/Companies/Companies.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ $block: '.#{$ns}companies-block';
88

99
text-align: center;
1010

11-
&__title {
12-
@include heading2();
13-
}
14-
1511
&__images {
1612
margin-top: $indentM;
1713
}

src/blocks/Companies/Companies.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import {Image} from '../../components';
3+
import {Image, Title} from '../../components';
44
import AnimateBlock from '../../components/AnimateBlock/AnimateBlock';
55
import {useTheme} from '../../context/theme';
66
import {CompaniesBlockProps} from '../../models';
@@ -10,14 +10,14 @@ import './Companies.scss';
1010

1111
const b = block('companies-block');
1212

13-
export const CompaniesBlock = ({title, images, animated}: CompaniesBlockProps) => {
13+
export const CompaniesBlock = ({title, description, images, animated}: CompaniesBlockProps) => {
1414
const theme = useTheme();
1515
const themedImages = getThemedValue(images, theme) || {};
1616

1717
return (
1818
<AnimateBlock className={b()} offset={150} animate={animated}>
1919
<div className={b('content')}>
20-
<h2 className={b('title')}>{title}</h2>
20+
<Title title={title} subtitle={description} colSizes={{all: 12, sm: 12}}></Title>
2121
<div className={b('images')}>
2222
<Image {...themedImages} className={b('image')} />
2323
</div>

src/blocks/Companies/__stories__/Companies.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import * as CompaniesStories from './Companies.stories.tsx';
1111

1212
`title: string` — Title
1313

14+
`description?: string` — text (with YFM support)
15+
1416
`images: ImageDeviceProps` — Images for different screen sizes (see in common types)
1517
</StoryTemplate>
1618

src/blocks/Companies/__stories__/Companies.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React 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 {CompaniesBlockModel, CompaniesBlockProps} from '../../../models';
78
import Companies from '../Companies';
@@ -17,6 +18,17 @@ const DefaultTemplate: StoryFn<CompaniesBlockModel> = (args) => (
1718
<PageConstructor content={{blocks: [args]}} />
1819
);
1920

21+
const WithDescriptionTemplate: StoryFn<CompaniesBlockModel> = (args) => (
22+
<PageConstructor content={{blocks: [args]}} />
23+
);
24+
2025
export const Default = DefaultTemplate.bind({});
26+
export const WithDescription = WithDescriptionTemplate.bind({});
27+
28+
const transformedText = yfmTransform(data.withDescription.content.description);
2129

2230
Default.args = data.default.content as CompaniesBlockProps;
31+
WithDescription.args = {
32+
...data.withDescription.content,
33+
description: transformedText,
34+
} as CompaniesBlockProps;

src/blocks/Companies/__stories__/data.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,26 @@
1818
}
1919
}
2020
}
21+
},
22+
"withDescription": {
23+
"content": {
24+
"type": "companies-block",
25+
"title": "Page constructor",
26+
"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.",
27+
"images": {
28+
"light": {
29+
"desktop": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_desktop_light.svg",
30+
"tablet": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_tablet_light.svg",
31+
"mobile": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_mobile_light.svg",
32+
"alt": "Page constructor"
33+
},
34+
"dark": {
35+
"desktop": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_desktop_dark.svg",
36+
"tablet": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_tablet_dark.svg",
37+
"mobile": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/logo-svg_12-12_mobile_dark.svg",
38+
"alt": "Page constructor"
39+
}
40+
}
41+
}
2142
}
2243
}

src/models/constructor-items/blocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export interface BannerBlockProps extends BannerCardProps, Animatable {}
212212

213213
export interface CompaniesBlockProps extends Animatable {
214214
title: string;
215+
description?: string;
215216
images: ThemeSupporting<ImageDeviceProps>;
216217
}
217218

src/text-transform/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export const config: BlocksConfig = {
214214
},
215215
],
216216
[BlockType.SliderBlock]: blockHeaderTransformer,
217+
[BlockType.CompaniesBlock]: blockHeaderTransformer,
217218
[BlockType.QuestionsBlock]: [
218219
{
219220
fields: ['title'],

0 commit comments

Comments
 (0)