Skip to content

Commit 97e7fbc

Browse files
authored
chore: fix story (#1227)
1 parent ae1d12a commit 97e7fbc

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

src/sub-blocks/BackgroundCard/__stories__/BackgroundCard.stories.tsx

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {Meta, StoryFn} from '@storybook/react';
22

3-
import {blockListTransform, blockTransform} from '../../../../.storybook/utils';
3+
import {blockTransform} from '../../../../.storybook/utils';
44
import CardLayout, {CardLayoutBlockProps} from '../../../blocks/CardLayout/CardLayout';
55
import {BlockBase} from '../../../components';
66
import {ConstructorRow} from '../../../containers/PageConstructor/components/ConstructorRow';
77
import {Grid} from '../../../grid';
8-
import {BackgroundCardProps} from '../../../models';
8+
import {BackgroundCardModel, BackgroundCardProps, CardLayoutBlockModel} from '../../../models';
99
import BackgroundCard from '../BackgroundCard';
1010

1111
import data from './data.json';
@@ -24,42 +24,45 @@ export default {
2424
},
2525
} as Meta;
2626

27-
const DefaultTemplate: StoryFn<BackgroundCardProps> = (args) => (
27+
const DefaultTemplate: StoryFn<BackgroundCardModel> = (args) => (
2828
<div style={{maxWidth: '400px'}}>
29-
<BackgroundCard {...args} />
29+
<BackgroundCard {...(blockTransform(args) as BackgroundCardProps)} />
3030
</div>
3131
);
3232

33-
const VariousContentTemplate: StoryFn<Record<number, {}>> = (args) => (
33+
const VariousContentTemplate: StoryFn<Record<number, BackgroundCardModel>> = (args) => (
3434
<div style={{display: 'flex'}}>
3535
{Object.values(args).map((item, index) => (
3636
<div key={index} style={{display: 'inline-table', maxWidth: '400px', padding: '0 8px'}}>
37-
<BackgroundCard {...item} />
37+
<BackgroundCard {...(blockTransform(item) as BackgroundCardProps)} />
3838
</div>
3939
))}
4040
</div>
4141
);
4242

43-
const CardThemesTemplate: StoryFn<Record<number, BackgroundCardProps>> = (args) => (
43+
const CardThemesTemplate: StoryFn<Record<number, BackgroundCardModel>> = (args) => (
4444
<div style={{display: 'flex'}}>
4545
{Object.values(args).map((item, index) => (
4646
<div style={{maxWidth: '400px', padding: '0 8px'}} key={index}>
47-
<BackgroundCard {...item} />
47+
<BackgroundCard {...(blockTransform(item) as BackgroundCardProps)} />
4848
</div>
4949
))}
5050
</div>
5151
);
5252

5353
const ControlPositionTemplate: StoryFn<
54-
Record<number, CardLayoutBlockProps & {children: BackgroundCardProps[]}>
54+
Record<number, CardLayoutBlockModel & {children: BackgroundCardModel[]}>
5555
> = (args) => (
5656
<Grid>
5757
<ConstructorRow>
5858
{Object.values(args).map(({children, ...rest}, contentLayoutIndex) => (
5959
<BlockBase key={contentLayoutIndex}>
60-
<CardLayout {...rest}>
60+
<CardLayout {...(blockTransform(rest) as CardLayoutBlockProps)}>
6161
{children.map((item, index) => (
62-
<BackgroundCard key={index} {...item} />
62+
<BackgroundCard
63+
key={index}
64+
{...(blockTransform(item) as BackgroundCardProps)}
65+
/>
6366
))}
6467
</CardLayout>
6568
</BlockBase>
@@ -78,69 +81,69 @@ export const BackgroundColor = VariousContentTemplate.bind([]);
7881
export const WithUrl = CardThemesTemplate.bind([]);
7982
export const ControlPosition = ControlPositionTemplate.bind([]);
8083

81-
Default.args = blockTransform(data.default) as BackgroundCardProps;
84+
Default.args = data.default as BackgroundCardProps;
8285

83-
VariousContent.args = blockListTransform(data.props) as BackgroundCardProps[];
86+
VariousContent.args = data.props as BackgroundCardModel[];
8487
VariousContent.parameters = {
8588
controls: {
8689
include: Object.keys(data.props),
8790
},
8891
};
8992

90-
WithBackgroundImage.args = blockListTransform(
91-
data.props.map((item) => ({...item, ...data.withBackgroundImage})),
92-
) as BackgroundCardProps[];
93+
WithBackgroundImage.args = data.props.map((item) => ({
94+
...item,
95+
...data.withBackgroundImage,
96+
})) as BackgroundCardModel[];
9397
WithBackgroundImage.parameters = {
9498
controls: {
9599
include: Object.keys(data.props),
96100
},
97101
};
98102

99-
Paddings.args = blockListTransform(
100-
data.withPaddings.map((item) => ({...item, ...data.withBackgroundImage})),
101-
) as BackgroundCardProps[];
103+
Paddings.args = data.withPaddings.map((item) => ({
104+
...item,
105+
...data.withBackgroundImage,
106+
})) as BackgroundCardModel[];
102107
Paddings.parameters = {
103108
controls: {
104109
include: Object.keys(data.withPaddings),
105110
},
106111
};
107112

108-
CardThemes.args = blockListTransform(data.cardThemes) as BackgroundCardProps[];
113+
CardThemes.args = data.cardThemes as BackgroundCardModel[];
109114
CardThemes.parameters = {
110115
controls: {
111116
include: Object.keys(data.cardThemes),
112117
},
113118
};
114119

115-
BorderLine.args = blockListTransform(
116-
data.props.map((item) => ({
117-
...item,
118-
...data.withBackgroundImage,
119-
...data.borderLine,
120-
})),
121-
) as BackgroundCardProps[];
120+
BorderLine.args = data.props.map((item) => ({
121+
...item,
122+
...data.withBackgroundImage,
123+
...data.borderLine,
124+
})) as BackgroundCardModel[];
122125
BorderLine.parameters = {
123126
controls: {
124127
include: Object.keys(data.props),
125128
},
126129
};
127130

128-
BackgroundColor.args = blockListTransform(data.backgroundColor) as BackgroundCardProps[];
131+
BackgroundColor.args = data.backgroundColor as BackgroundCardModel[];
129132
BackgroundColor.parameters = {
130133
controls: {
131134
include: Object.keys(data.backgroundColor),
132135
},
133136
};
134137

135-
WithUrl.args = blockListTransform(data.withUrl) as BackgroundCardProps[];
138+
WithUrl.args = data.withUrl as BackgroundCardModel[];
136139
WithUrl.parameters = {
137140
controls: {
138141
include: Object.keys(data.withUrl),
139142
},
140143
};
141144

142-
ControlPosition.args = blockListTransform(data.controlPosition) as (CardLayoutBlockProps & {
143-
children: BackgroundCardProps[];
145+
ControlPosition.args = data.controlPosition as unknown as (CardLayoutBlockModel & {
146+
children: BackgroundCardModel[];
144147
})[];
145148
ControlPosition.parameters = {
146149
controls: {

0 commit comments

Comments
 (0)