Skip to content

Commit cbda11f

Browse files
authored
feat: remove custorm withChildren (#955)
1 parent a77534a commit cbda11f

File tree

29 files changed

+63
-84
lines changed

29 files changed

+63
-84
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The page constructor is imported as a React component. To make sure it runs prop
2525
```jsx
2626
import {PageConstructor, PageConstructorProvider} from '@gravity-ui/page-constructor';
2727

28-
const Page: WithChildren<PageProps> = ({content}) => (
28+
const Page: React.PropsWithChildren<PageProps> = ({content}) => (
2929
<PageConstructorProvider>
3030
<PageConstructor content={content} />
3131
</PageConstructorProvider>

src/blocks/CardLayout/CardLayout.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import isEmpty from 'lodash/isEmpty';
55
import {AnimateBlock, BackgroundImage, Title} from '../../components';
66
import {useTheme} from '../../context/theme';
77
import {Col, GridColumnSizesType, Row} from '../../grid';
8-
import {
9-
CardLayoutBlockProps as CardLayoutBlockParams,
10-
ClassNameProps,
11-
WithChildren,
12-
} from '../../models';
8+
import {CardLayoutBlockProps as CardLayoutBlockParams, ClassNameProps} from '../../models';
139
import {block, getThemedValue} from '../../utils';
1410

1511
import './CardLayout.scss';
@@ -19,7 +15,9 @@ const DEFAULT_SIZES: GridColumnSizesType = {
1915
sm: 6,
2016
md: 4,
2117
};
22-
export type CardLayoutBlockProps = WithChildren<Omit<CardLayoutBlockParams, 'children'>> &
18+
export type CardLayoutBlockProps = React.PropsWithChildren<
19+
Omit<CardLayoutBlockParams, 'children'>
20+
> &
2321
ClassNameProps;
2422

2523
const b = block('card-layout-block');

src/blocks/Header/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import YFMWrapper from '../../components/YFMWrapper/YFMWrapper';
99
import {MobileContext} from '../../context/mobileContext';
1010
import {useTheme} from '../../context/theme';
1111
import {Col, Grid, Row} from '../../grid';
12-
import {ClassNameProps, HeaderBlockBackground, HeaderBlockProps, WithChildren} from '../../models';
12+
import {ClassNameProps, HeaderBlockBackground, HeaderBlockProps} from '../../models';
1313
import {block, getThemedValue} from '../../utils';
1414

1515
import {getImageSize, getTitleSizes, titleWithImageSizes} from './utils';
@@ -62,7 +62,7 @@ const FullWidthBackground = ({background}: FullWidthBackgroundProps) => (
6262
/>
6363
);
6464

65-
export const HeaderBlock = (props: WithChildren<HeaderBlockFullProps>) => {
65+
export const HeaderBlock = (props: React.PropsWithChildren<HeaderBlockFullProps>) => {
6666
const {
6767
title,
6868
overtitle,

src/blocks/Slider/Slider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
SliderProps as SliderParams,
2929
SliderType,
3030
Timeout,
31-
WithChildren,
3231
} from '../../models';
3332
import {block} from '../../utils';
3433

@@ -63,7 +62,7 @@ export interface SliderProps
6362
arrowSize?: number;
6463
}
6564

66-
export const SliderBlock = (props: WithChildren<SliderProps>) => {
65+
export const SliderBlock = (props: React.PropsWithChildren<SliderProps>) => {
6766
const {
6867
animated,
6968
title,

src/components/AnimateBlock/AnimateBlock.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, {CSSProperties, useContext, useState} from 'react';
33
import {Waypoint} from 'react-waypoint';
44

55
import {AnimateContext, AnimateContextProps} from '../../context/animateContext/AnimateContext';
6-
import {QAProps, WithChildren} from '../../models';
6+
import {QAProps} from '../../models';
77
import {block} from '../../utils';
88

99
const b = block('AnimateBlock');
@@ -16,7 +16,7 @@ export interface AnimateBlockProps extends AnimateContextProps, QAProps {
1616
onScroll?: () => void;
1717
}
1818

19-
const AnimateBlock = (props: WithChildren<AnimateBlockProps>) => {
19+
const AnimateBlock = (props: React.PropsWithChildren<AnimateBlockProps>) => {
2020
const {animated} = useContext(AnimateContext);
2121
const {children, className, offset = 100, onScroll, style, animate = animated, qa} = props;
2222
const [playAnimation, setPlayAnimation] = useState<boolean>(false);

src/components/AnimateBlock/__tests__/AnimateBlock.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import {render, screen} from '@testing-library/react';
44
import userEvent from '@testing-library/user-event';
55

66
import {testCustomClassName, testCustomStyle} from '../../../../test-utils/shared/common';
7-
import {WithChildren} from '../../../models';
87
import AnimateBlock, {AnimateBlockProps} from '../AnimateBlock';
98

109
const qa = 'animate-block';
1110

12-
type ComponentProps = WithChildren<AnimateBlockProps>;
11+
type ComponentProps = React.PropsWithChildren<AnimateBlockProps>;
1312

1413
describe('AnimateBlock', () => {
1514
test('render AnimateBlock by default', async () => {

src/components/Author/Author.tsx

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

3-
import {AuthorProps, AuthorType, ImageProps, WithChildren} from '../../models';
3+
import {AuthorProps, AuthorType, ImageProps} from '../../models';
44
import {block} from '../../utils';
55
import {getMediaImage} from '../Media/Image/utils';
66
import {Image} from '../index';
@@ -9,7 +9,7 @@ import './Author.scss';
99

1010
const b = block('author');
1111

12-
const Author = (props: WithChildren<AuthorProps>) => {
12+
const Author = (props: React.PropsWithChildren<AuthorProps>) => {
1313
const {
1414
author,
1515
className,

src/components/BackgroundImage/BackgroundImage.tsx

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

3-
import {BackgroundImageProps, WithChildren} from '../../models';
3+
import {BackgroundImageProps} from '../../models';
44
import {block, getQaAttrubutes} from '../../utils';
55
import Image from '../Image/Image';
66

@@ -10,7 +10,7 @@ export const qaIdByDefault = 'background-image';
1010

1111
const b = block('storage-background-image');
1212

13-
const BackgroundImage = (props: WithChildren<BackgroundImageProps>) => {
13+
const BackgroundImage = (props: React.PropsWithChildren<BackgroundImageProps>) => {
1414
const {children, src, desktop, className, imageClassName, style, hide, qa} = props;
1515
const qaAttributes = getQaAttrubutes(qa || qaIdByDefault);
1616

src/components/BalancedMasonry/BalancedMasonry.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import first from 'lodash/first';
55
import minBy from 'lodash/minBy';
66

77
import {SSRContext} from '../../context/ssrContext';
8-
import {QAProps, WithChildren} from '../../models';
8+
import {QAProps} from '../../models';
99
import {block, getQaAttrubutes} from '../../utils';
1010

1111
import './BalancedMasonry.scss';
@@ -21,7 +21,7 @@ export interface BalancedMasonryProps extends QAProps {
2121
};
2222
}
2323

24-
const BalancedMasonry = (props: WithChildren<BalancedMasonryProps>) => {
24+
const BalancedMasonry = (props: React.PropsWithChildren<BalancedMasonryProps>) => {
2525
const {className, columnClassName, children = [], breakpointCols, qa} = props;
2626
const qaAttributes = getQaAttrubutes(qa, 'column');
2727
const {isServer} = useContext(SSRContext);

src/components/BlockBase/__tests__/BlockBase.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {render, screen} from '@testing-library/react';
55
import {testCustomClassName} from '../../../../test-utils/shared/common';
66
import {qaIdByDefault} from '../../../components/Anchor/Anchor';
77
import {GridColumnSize, IndentValue} from '../../../grid';
8-
import {ClassNameProps, WithChildren} from '../../../models';
8+
import {ClassNameProps} from '../../../models';
99
import BlockBase, {BlockBaseFullProps} from '../BlockBase';
1010

1111
const qa = 'block-base-component';
1212

1313
const indentValues: IndentValue[] = ['0', 'xs', 's', 'm', 'l', 'xl'];
1414

15-
type ComponentProps = WithChildren<BlockBaseFullProps & ClassNameProps>;
15+
type ComponentProps = React.PropsWithChildren<BlockBaseFullProps & ClassNameProps>;
1616

1717
describe('BlockBase', () => {
1818
test('render component by default', async () => {

0 commit comments

Comments
 (0)