Skip to content

Commit f3952b3

Browse files
niktverdNikolay Tverdokhlebov
andauthored
feat(schemas): add content field to blocks' schemas (#60)
Co-authored-by: Nikolay Tverdokhlebov <[email protected]>
1 parent 8d0091e commit f3952b3

File tree

26 files changed

+121
-40
lines changed

26 files changed

+121
-40
lines changed

src/blocks/Banner/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ export const BannerCardProps = {
1414
...AnimatableProps,
1515
title: {
1616
type: 'string',
17+
contentType: 'text',
1718
},
1819
subtitle: {
1920
type: 'string',
21+
contentType: 'yfm',
2022
},
2123
image: withTheme({
2224
type: 'string',

src/blocks/CardLayout/schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ export const CardLayoutProps = {
1313
...BlockBaseProps,
1414
...AnimatableProps,
1515
title: {
16-
oneOf: [{type: 'string'}, TitleProps],
16+
oneOf: [{type: 'string', contentType: 'text'}, TitleProps],
1717
},
1818
description: {
1919
type: 'string',
20+
contentType: 'yfm',
2021
},
2122
colSizes: containerSizesObject,
2223
children: ChildrenCardsProps,

src/blocks/Companies/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const CompaniesBlock = {
99
...AnimatableProps,
1010
title: {
1111
type: 'string',
12+
contentType: 'text',
1213
},
1314
images: withTheme({
1415
type: 'object',
@@ -25,6 +26,7 @@ export const CompaniesBlock = {
2526
},
2627
alt: {
2728
type: 'string',
29+
contentType: 'text',
2830
},
2931
},
3032
}),

src/blocks/ExtendedFeatures/schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ export const ExtendedFeaturesItem = {
1313
properties: {
1414
title: {
1515
type: 'string',
16+
contentType: 'text',
1617
},
1718
text: {
1819
type: 'string',
20+
contentType: 'yfm',
1921
},
2022
label: {
2123
type: 'string',
@@ -36,10 +38,11 @@ export const ExtendedFeaturesBlock = {
3638
...BlockBaseProps,
3739
...AnimatableProps,
3840
title: {
39-
oneOf: [{type: 'string'}, TitleProps],
41+
oneOf: [{type: 'string', contentType: 'text'}, TitleProps],
4042
},
4143
description: {
4244
type: 'string',
45+
contentType: 'yfm',
4346
},
4447
items: filteredArray(ExtendedFeaturesItem),
4548
colSizes: containerSizesObject,

src/blocks/Header/schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ export const HeaderBackgroundProps = {
2222
export const HeaderProperties = {
2323
title: {
2424
type: 'string',
25+
contentType: 'text',
2526
},
2627
overtitle: {
2728
type: 'string',
29+
contentType: 'text',
2830
},
2931
description: {
3032
type: 'string',
33+
contentType: 'yfm',
3134
},
3235
width: {
3336
type: 'string',
@@ -49,6 +52,7 @@ export const HeaderProperties = {
4952
},
5053
title: {
5154
type: 'string',
55+
contentType: 'text',
5256
},
5357
},
5458
},
@@ -82,6 +86,7 @@ export const HeaderProperties = {
8286
},
8387
text: {
8488
type: 'string',
89+
contentType: 'text',
8590
},
8691
},
8792
},

src/blocks/Icons/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const IconsProps = {
88
...AnimatableProps,
99
title: {
1010
type: 'string',
11+
contentType: 'text',
1112
},
1213
size: {
1314
type: 'string',
@@ -25,6 +26,7 @@ export const IconsProps = {
2526
},
2627
text: {
2728
type: 'string',
29+
contentType: 'text',
2830
},
2931
src: {
3032
type: 'string',

src/blocks/Info/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ export const InfoBlock = {
2222
...BaseProps,
2323
title: {
2424
type: 'string',
25+
contentType: 'text',
2526
},
2627
backgroundColor: withTheme({
2728
type: 'string',
2829
}),
2930
sectionsTitle: {
3031
type: 'string',
32+
contentType: 'text',
3133
},
3234
buttons: filteredArray(ButtonBlock),
3335
theme: ThemeProps,

src/blocks/Media/schema.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
import {omit} from 'lodash';
2+
13
import {
24
BlockBaseProps,
35
ButtonBlock,
46
MediaProps,
5-
TitleProps,
67
AnimatableProps,
7-
contentSizes,
8-
LinkProps,
98
mediaDirection,
109
} from '../../schema/validators/common';
11-
import {filteredArray} from '../../schema/validators/utils';
10+
import {ContentBase} from '../../../src/sub-blocks/Content/schema';
1211

1312
export const Media = {
1413
type: 'object',
@@ -17,25 +16,19 @@ export const Media = {
1716
properties: MediaProps,
1817
};
1918

19+
const MediaBlockContentProps = omit(ContentBase, ['text', 'theme']);
20+
2021
export const MediaBlock = {
2122
'media-block': {
2223
additionalProperties: false,
2324
required: ['title', 'media'],
2425
properties: {
2526
...BlockBaseProps,
2627
...AnimatableProps,
27-
title: {
28-
oneOf: [{type: 'string'}, TitleProps],
29-
},
30-
additionalInfo: {
31-
type: 'string',
32-
},
28+
...MediaBlockContentProps,
3329
description: {
3430
type: 'string',
35-
},
36-
size: {
37-
type: 'string',
38-
enum: contentSizes,
31+
contentType: 'yfm',
3932
},
4033
direction: {
4134
type: 'string',
@@ -54,8 +47,6 @@ export const MediaBlock = {
5447
disableShadow: {
5548
type: 'boolean',
5649
},
57-
links: filteredArray(LinkProps),
58-
buttons: filteredArray(ButtonBlock),
5950
media: Media,
6051
button: ButtonBlock,
6152
},

src/blocks/Preview/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const PreviewContentItem = {
1515
properties: {
1616
title: {
1717
type: 'string',
18+
contentType: 'text',
1819
},
1920
description: {
2021
type: 'string',
22+
contentType: 'yfm',
2123
},
2224
},
2325
};
@@ -45,9 +47,11 @@ export const PreviewBlock = {
4547
...AnimatableProps,
4648
title: {
4749
type: 'string',
50+
contentType: 'text',
4851
},
4952
description: {
5053
type: 'string',
54+
contentType: 'yfm',
5155
},
5256
direction: {
5357
type: 'string',

src/blocks/PromoFeaturesBlock/schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export const PromoFeaturesItem = {
88
properties: {
99
title: {
1010
type: 'string',
11+
contentType: 'text',
1112
},
1213
text: {
1314
type: 'string',
15+
contentType: 'yfm',
1416
},
1517
theme: {
1618
enum: ['accent', 'accent-light', 'primary'],
@@ -27,10 +29,11 @@ export const PromoFeaturesBlock = {
2729
...BlockBaseProps,
2830
...AnimatableProps,
2931
title: {
30-
oneOf: [{type: 'string'}, TitleProps],
32+
oneOf: [{type: 'string', contentType: 'text'}, TitleProps],
3133
},
3234
description: {
3335
type: 'string',
36+
contentType: 'text',
3437
},
3538
theme: {
3639
enum: ['grey', 'default'],

0 commit comments

Comments
 (0)