Skip to content

Commit 70551ae

Browse files
authored
feat: add title to feed block (#284)
1 parent 1435776 commit 70551ae

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

.mocks/blogPage.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
"type": "blog-feed-block",
1616
"resetPaddings": true,
1717
"image": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img_8-12_light.png",
18-
"title": {
19-
"text": "Blog",
20-
"textSize": "l"
21-
}
18+
"title": "Blog"
2219
}
2320
]
2421
},

.mocks/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const getDefaultStoryArgs = () => {
4242
paddingTop: 'l',
4343
text: 'Lorem ipsum dolor',
4444
image: 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img_8-12_light.png',
45+
title: 'Blog',
4546
};
4647
};
4748

src/blocks/Feed/Feed.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const CONTAINER_ID = 'blog-cards';
2121
const PAGE_QUERY = 'page';
2222
const FIRST_PAGE = 1;
2323

24-
export const Feed = ({image}: FeedProps) => {
24+
export const Feed = ({image, title}: FeedProps) => {
2525
const {
2626
posts,
2727
totalCount,
@@ -239,6 +239,7 @@ export const Feed = ({image}: FeedProps) => {
239239
url: image,
240240
disableCompress: true,
241241
}}
242+
title={title}
242243
/>
243244
{errorLoad ? (
244245
<PostsError onButtonClick={handleOnErrorReload} />

src/blocks/Feed/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ The data in this component is taken from contexts.
33
| Property | Type | Required | Description |
44
| :------- | :------- | :------- | :-------------------- |
55
| image | `string` | `true` | Image for feed header |
6+
| title | `string` | `false` | Title for feed header |

src/blocks/Feed/schema.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
import {validators} from '@gravity-ui/page-constructor';
22

33
const {
4-
common: {TitleProps, BlockBaseProps},
4+
common: {BlockBaseProps},
55
} = validators;
66

77
import {BlockType} from '../../models/common';
88

99
export const Feed = {
1010
[BlockType.Feed]: {
1111
additionalProperties: false,
12-
required: [],
12+
required: 'image',
1313
properties: {
1414
...BlockBaseProps,
15-
title: TitleProps,
16-
image: {
17-
type: 'string',
18-
},
19-
description: {
15+
title: {
2016
type: 'string',
21-
contentType: 'text',
2217
},
23-
size: {
18+
image: {
2419
type: 'string',
25-
enum: ['s', 'm'],
2620
},
2721
},
2822
},

src/components/FeedHeader/FeedHeader.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const FeedHeader = ({
3131
verticalOffset = 'l',
3232
className,
3333
queryParams,
34+
title,
3435
}: FeedHeaderContainerProps) => {
3536
const backgroundThemed = background && getThemedValue(background, theme as Theme);
3637

@@ -57,6 +58,7 @@ export const FeedHeader = ({
5758
/>
5859
) : null}
5960
<Controls
61+
title={title}
6062
tags={tags}
6163
services={services}
6264
handleLoadData={handleLoadData}

src/components/FeedHeader/components/Controls/Controls.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type ControlsProps = {
3131
tags?: SelectItem[];
3232
services?: SelectItem[];
3333
queryParams: Query;
34+
title?: string;
3435
};
3536

3637
const ICON_SIZE = 16;
@@ -42,6 +43,7 @@ export const Controls = ({
4243
tags = [],
4344
services = [],
4445
queryParams,
46+
title = i18n(Keyset.Title),
4547
}: ControlsProps) => {
4648
const {hasLikes} = React.useContext(LikesContext);
4749
const handleAnalyticsTag = useAnalytics(DefaultEventNames.Tag);
@@ -142,7 +144,7 @@ export const Controls = ({
142144
return (
143145
<MobileProvider mobile={false}>
144146
<div className={b('header')}>
145-
<h1 className={b('header-item', {title: true})}>{i18n(Keyset.Title)}</h1>
147+
<h1 className={b('header-item', {title: true})}>{title}</h1>
146148
<div className={b('header-item', {filters: true})}>
147149
<div className={b('filter-item')}>
148150
<Search

src/models/blocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export type YFMProps = {
8484

8585
export type FeedProps = {
8686
image: string;
87+
title?: string;
8788
};
8889

8990
export type FormProps = {

0 commit comments

Comments
 (0)