@redneckz/wildless-cms-uni-blocks 0.14.531 → 0.14.532

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/bin/migration-scripts/0.14.519.js +13 -0
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +7 -10
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  6. package/bundle/components/StepsBlock/renderStepMobile.d.ts +4 -0
  7. package/dist/components/StepsBlock/StepsBlock.js +6 -9
  8. package/dist/components/StepsBlock/StepsBlock.js.map +1 -1
  9. package/dist/components/StepsBlock/StepsBlock.mobile.js +5 -26
  10. package/dist/components/StepsBlock/StepsBlock.mobile.js.map +1 -1
  11. package/dist/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  12. package/dist/components/StepsBlock/renderStepMobile.d.ts +4 -0
  13. package/dist/components/StepsBlock/renderStepMobile.js +48 -0
  14. package/dist/components/StepsBlock/renderStepMobile.js.map +1 -0
  15. package/lib/common.css +1 -1
  16. package/lib/components/StepsBlock/StepsBlock.fixture.mobile.d.ts +1 -0
  17. package/lib/components/StepsBlock/StepsBlock.js +7 -10
  18. package/lib/components/StepsBlock/StepsBlock.js.map +1 -1
  19. package/lib/components/StepsBlock/StepsBlock.mobile.js +5 -26
  20. package/lib/components/StepsBlock/StepsBlock.mobile.js.map +1 -1
  21. package/lib/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  22. package/lib/components/StepsBlock/renderStepMobile.d.ts +3 -0
  23. package/lib/components/StepsBlock/renderStepMobile.js +45 -0
  24. package/lib/components/StepsBlock/renderStepMobile.js.map +1 -0
  25. package/mobile/bundle/bundle.umd.js +41 -22
  26. package/mobile/bundle/bundle.umd.min.js +1 -1
  27. package/mobile/bundle/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  28. package/mobile/bundle/components/StepsBlock/renderStepMobile.d.ts +4 -0
  29. package/mobile/dist/components/StepsBlock/StepsBlock.js +5 -26
  30. package/mobile/dist/components/StepsBlock/StepsBlock.js.map +1 -1
  31. package/mobile/dist/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  32. package/mobile/dist/components/StepsBlock/renderStepMobile.d.ts +4 -0
  33. package/mobile/dist/components/StepsBlock/renderStepMobile.js +48 -0
  34. package/mobile/dist/components/StepsBlock/renderStepMobile.js.map +1 -0
  35. package/mobile/lib/common.css +1 -1
  36. package/mobile/lib/components/StepsBlock/StepsBlock.js +5 -26
  37. package/mobile/lib/components/StepsBlock/StepsBlock.js.map +1 -1
  38. package/mobile/lib/components/StepsBlock/StepsBlockContent.d.ts +3 -7
  39. package/mobile/lib/components/StepsBlock/renderStepMobile.d.ts +4 -0
  40. package/mobile/lib/components/StepsBlock/renderStepMobile.js +45 -0
  41. package/mobile/lib/components/StepsBlock/renderStepMobile.js.map +1 -0
  42. package/mobile/src/components/StepsBlock/StepsBlock.tsx +24 -112
  43. package/mobile/src/components/StepsBlock/StepsBlock.ui.json +3 -0
  44. package/mobile/src/components/StepsBlock/StepsBlockContent.ts +3 -6
  45. package/mobile/src/components/StepsBlock/renderStepMobile.tsx +139 -0
  46. package/package.json +1 -1
  47. package/src/components/StepsBlock/StepsBlock.fixture.mobile.tsx +44 -8
  48. package/src/components/StepsBlock/StepsBlock.fixture.tsx +0 -1
  49. package/src/components/StepsBlock/StepsBlock.mobile.tsx +24 -112
  50. package/src/components/StepsBlock/StepsBlock.tsx +8 -19
  51. package/src/components/StepsBlock/StepsBlock.ui.json +3 -0
  52. package/src/components/StepsBlock/StepsBlockContent.ts +3 -6
  53. package/src/components/StepsBlock/renderStepMobile.tsx +139 -0
@@ -1,32 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { type BlockVersion } from '../../model/BlockVersion';
3
- import { type SizeVersion } from '../../model/SizeVersion';
4
2
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
- import { Img } from '../../ui-kit/Img/Img';
6
3
  import { renderButtonsSection } from '../../ui-kit/LinkButton/renderButtonsSection';
7
- import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
8
- import { RichText } from '../../ui-kit/RichText/RichText';
9
4
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
10
- import { isIcon } from '../../utils/isIcon';
11
5
  import { style } from '../../utils/style';
12
6
  import { Headline } from '../Headline/Headline';
13
- import { getIconTextStyle } from './getIconTextStyle';
14
- import { type StepProps, type StepsBlockContent } from './StepsBlockContent';
15
- import { STEPS_BLOCK_STYLE } from './StepsBlockStyleMaps';
16
-
17
- type StepIconVersion = Record<'icon' | 'image', string>;
18
-
19
- const STEPS_SIZE_MAP: Record<SizeVersion, StepIconVersion> = {
20
- normal: { icon: 'h-11 w-11', image: 'h-14 w-14' },
21
- small: { icon: 'h-12 w-12', image: 'h-14 w-14' },
22
- };
23
-
24
- const STEPS_TILE_DESCRIPTION_HEIGHT_MAP: Record<SizeVersion, string> = {
25
- normal: '',
26
- small: 'min-h-6xl',
27
- };
28
-
29
- const styleMap = STEPS_BLOCK_STYLE;
7
+ import { renderStepMobile } from './renderStepMobile';
8
+ import { type StepsBlockContent } from './StepsBlockContent';
30
9
 
31
10
  export interface StepsBlockProps extends StepsBlockContent, UniBlockProps {}
32
11
 
@@ -35,102 +14,35 @@ export const StepsBlock = JSX<StepsBlockProps>(
35
14
  className = '',
36
15
  title,
37
16
  description,
38
- steps,
17
+ steps = [],
39
18
  buttons,
40
- size = 'normal',
41
19
  stepVersion = 'gray',
42
20
  version = 'primary',
43
21
  ...rest
44
- }) => (
45
- <BlockWrapper
46
- className={style('box-border flex flex-col gap-xl', className)}
47
- defaultPadding="p-6xl"
48
- version={version}
49
- {...rest}
50
- >
51
- <Headline
52
- title={title}
53
- description={description}
54
- headlineVersion="M"
55
- isEmbedded={true}
56
- align="text-left"
57
- />
58
- {steps?.length ? (
59
- <div className="box-border">
60
- <div className="flex flex-col gap-6xl justify-between">
61
- {steps.map(renderStep(size, stepVersion))}
62
- </div>
63
- </div>
64
- ) : null}
65
- {renderButtonsSection(buttons, { isVertical: true })}
66
- </BlockWrapper>
67
- ),
68
- );
69
-
70
- // TODO: Create universal function for this case
71
- const renderStep = (size: SizeVersion, stepVersion: BlockVersion) => (step: StepProps, i: number) =>
72
- (
73
- <div key={String(i)} className="contents">
74
- <div className="flex flex-row items-center relative">
75
- <div className="overflow-hidden flex flex-shrink-0 items-center">
76
- {renderIconArea(size, stepVersion)(step, i)}
77
- </div>
78
- <div
79
- className={style(
80
- 'flex flex-col justify-center h-fit',
81
- STEPS_TILE_DESCRIPTION_HEIGHT_MAP[size],
82
- )}
83
- >
84
- {step.label ? (
85
- <Paragraph size="text-l" align="text-left">
86
- {step.label}
87
- </Paragraph>
88
- ) : null}
89
- {step.description ? (
90
- <div className={style('text-s font-light text-left', styleMap.description)}>
91
- {step.description}
92
- </div>
93
- ) : null}
94
- <RichText __html={step.__html} />
95
- </div>
96
- </div>
97
- </div>
98
- );
99
-
100
- const renderIconArea =
101
- (size: SizeVersion, stepVersion: BlockVersion) => (step: StepProps, i: number) => {
102
- const iconVersion = stepVersion === 'secondary' ? 'white' : 'color';
103
- const isImg = Boolean(step?.icon?.src);
104
- const iconAreaSize = STEPS_SIZE_MAP[size][isImg ? 'image' : 'icon'];
105
- const containerVersion = isImg ? stepVersion === 'transparent' : stepVersion;
22
+ }) => {
23
+ const isBigSizeSteps = steps.length > 3;
106
24
 
107
25
  return (
108
26
  <BlockWrapper
109
- className={style(iconAreaSize, 'z-10 mr-s flex justify-center content-center rounded-md')}
110
- defaultPadding=""
111
- version={containerVersion as BlockVersion}
27
+ className={style('box-border flex flex-col gap-xl', className)}
28
+ defaultPadding="p-6xl"
29
+ version={version}
30
+ {...rest}
112
31
  >
113
- <span className="flex max-w-full max-h-full items-center justify-center">
114
- {isIcon(step?.icon) ? (
115
- <Img
116
- image={{ ...step.icon, iconVersion: step.icon?.iconVersion || iconVersion }}
117
- imageClassName="max-w-full max-h-full"
118
- width={getIconSizeStyle(size)}
119
- height={getIconSizeStyle(size)}
120
- />
121
- ) : (
122
- <span
123
- className={style(
124
- 'text-h4',
125
- stepVersion === 'transparent' ? styleMap.iconText : getIconTextStyle(stepVersion),
126
- )}
127
- >
128
- {i + 1}
129
- </span>
130
- )}
131
- </span>
32
+ <Headline
33
+ title={title}
34
+ description={description}
35
+ headlineVersion="M"
36
+ isEmbedded={true}
37
+ align="text-left"
38
+ />
39
+ {steps?.length ? (
40
+ <div className="flex flex-col gap-6xl justify-between box-border">
41
+ {steps.map(renderStepMobile(isBigSizeSteps, version, stepVersion))}
42
+ </div>
43
+ ) : null}
44
+ {renderButtonsSection(buttons, { isVertical: true })}
132
45
  </BlockWrapper>
133
46
  );
134
- };
135
-
136
- const getIconSizeStyle = (size: string) => (size === 'normal' ? '38' : '24');
47
+ },
48
+ );
@@ -18,6 +18,9 @@
18
18
  "icon": {
19
19
  "ui:field": "icon"
20
20
  },
21
+ "image": {
22
+ "ui:field": "picture"
23
+ },
21
24
  "button": {
22
25
  "href": {
23
26
  "ui:field": "attachmentHref"
@@ -2,7 +2,7 @@ import { type BlockVersion } from '../../model/BlockVersion';
2
2
  import { type BulletsProps } from '../../model/Bullets';
3
3
  import { type DescriptionProps, type LabelProps, type TitleProps } from '../../model/HeadlineType';
4
4
  import { type IconProps } from '../../model/Picture';
5
- import { type SizeVersion } from '../../model/SizeVersion';
5
+ import { type ImageContent } from '../../ui-kit/Img/ImgProps';
6
6
  import { type ButtonsSectionContent } from '../../ui-kit/LinkButton/ButtonsSectionContent';
7
7
  import { type LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
8
8
  import type { RichTextProps } from '../../ui-kit/RichText/RichTextProps';
@@ -12,6 +12,7 @@ import { type UniBlockContent } from '../../UniBlock/UniBlockProps';
12
12
  * @title Шаг
13
13
  */
14
14
  export type StepProps = DescriptionProps &
15
+ ImageContent &
15
16
  LabelProps &
16
17
  RichTextProps &
17
18
  IconProps &
@@ -34,10 +35,6 @@ export type StepsBlockContent = UniBlockContent &
34
35
  * @maxItems 5
35
36
  */
36
37
  steps?: StepProps[];
37
- /**
38
- * @title Тема шагов
39
- */
38
+ /** @title Тема шагов */
40
39
  stepVersion?: BlockVersion;
41
- /** @title Размер шагов */
42
- size?: SizeVersion; // TODO: mobile content
43
40
  };
@@ -0,0 +1,139 @@
1
+ import { type BlockVersion } from '../../model/BlockVersion';
2
+ import { type IconVersion } from '../../model/IconVersion';
3
+ import { type LinkButtonVersion } from '../../model/LinkButtonVersion';
4
+ import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
+ import { Img } from '../../ui-kit/Img/Img';
6
+ import { LinkButton } from '../../ui-kit/LinkButton/LinkButton';
7
+ import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
8
+ import { RichText } from '../../ui-kit/RichText/RichText';
9
+ import { isIcon } from '../../utils/isIcon';
10
+ import { style } from '../../utils/style';
11
+ import { getIconTextStyle } from './getIconTextStyle';
12
+ import { type StepProps } from './StepsBlockContent';
13
+ import { STEPS_BLOCK_STYLE } from './StepsBlockStyleMaps';
14
+
15
+ const styleMap = STEPS_BLOCK_STYLE;
16
+
17
+ export const renderStepMobile =
18
+ (stepsSize: boolean, version: BlockVersion, stepVersion: BlockVersion) =>
19
+ (step: StepProps, i: number) => {
20
+ const { button, image } = step;
21
+
22
+ const styleStepMobile = button?.text && image?.src;
23
+
24
+ return (
25
+ <div key={String(i)} className="contents">
26
+ <div className={style('flex items-center relative', image?.src ? 'flex-col' : 'flex-row')}>
27
+ {image?.src ? renderText(step) : null}
28
+ <div className="overflow-hidden flex flex-shrink-0 items-center">
29
+ {renderIconArea(stepsSize, stepVersion)(step, i)}
30
+ </div>
31
+ <div
32
+ className={style('flex flex-col justify-center h-fit w-full', {
33
+ 'min-h-6xl': stepsSize,
34
+ })}
35
+ >
36
+ {image?.src ? null : renderText(step)}
37
+ {styleStepMobile ? (
38
+ <LinkButton
39
+ className="box-border py-s w-full max-w-60 mt-lg"
40
+ version={version as LinkButtonVersion}
41
+ {...button}
42
+ >
43
+ {button?.text}
44
+ </LinkButton>
45
+ ) : null}
46
+ </div>
47
+ </div>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ const renderIconArea =
53
+ (stepsSize: boolean, stepVersion: BlockVersion) => (step: StepProps, i: number) => {
54
+ const iconVersion = stepVersion === 'secondary' ? 'white' : 'color';
55
+ const isImg = Boolean(step?.icon?.src);
56
+ const iconAreaSize = getIconAreaSize(stepsSize, isImg);
57
+ const containerVersion = isImg ? stepVersion === 'transparent' : stepVersion;
58
+ const isImgSrc = step.image?.src;
59
+
60
+ return (
61
+ <BlockWrapper
62
+ className={style(
63
+ { 'w-32': Boolean(isImgSrc) },
64
+ 'z-10 mr-s flex justify-center content-center rounded-md',
65
+ !isImgSrc && iconAreaSize,
66
+ )}
67
+ defaultPadding=""
68
+ version={containerVersion as BlockVersion}
69
+ >
70
+ <div className="flex max-w-full max-h-full items-center justify-center">
71
+ {renderIcon({ step, iconVersion, i, stepVersion })}
72
+ </div>
73
+ </BlockWrapper>
74
+ );
75
+ };
76
+
77
+ const renderText = (step: StepProps) => {
78
+ const visibleStyle = Boolean(step.button?.text && step.image?.src);
79
+
80
+ return (
81
+ <div
82
+ className={style({
83
+ 'mb-lg w-full': visibleStyle,
84
+ })}
85
+ >
86
+ {step?.label ? (
87
+ <Paragraph size="text-l" align="text-left">
88
+ {step.label}
89
+ </Paragraph>
90
+ ) : null}
91
+ {step?.description ? (
92
+ <div className={style('text-s font-light text-left', styleMap.description)}>
93
+ {step.description}
94
+ </div>
95
+ ) : null}
96
+ <RichText __html={step.__html} />
97
+ </div>
98
+ );
99
+ };
100
+
101
+ const getIconAreaSize = (stepsSize: boolean, isImg: boolean) => {
102
+ return stepsSize && isImg ? 'h-14 w-14' : 'h-11 w-11';
103
+ };
104
+
105
+ const renderIcon = ({
106
+ step,
107
+ iconVersion,
108
+ i,
109
+ stepVersion,
110
+ }: {
111
+ step: StepProps;
112
+ iconVersion: IconVersion;
113
+ i: number;
114
+ stepVersion: BlockVersion;
115
+ }) => {
116
+ if (isIcon(step?.icon)) {
117
+ return (
118
+ <Img
119
+ image={{ ...step.icon, iconVersion: step.icon?.iconVersion || iconVersion }}
120
+ imageClassName="max-w-full max-h-full"
121
+ width="24"
122
+ height="24"
123
+ />
124
+ );
125
+ } else if (isIcon(step.image)) {
126
+ return <Img image={{ ...step.image, size: { width: 120, height: 120 } }} />;
127
+ }
128
+
129
+ return (
130
+ <span
131
+ className={style(
132
+ 'text-h4',
133
+ stepVersion === 'transparent' ? styleMap.iconText : getIconTextStyle(stepVersion),
134
+ )}
135
+ >
136
+ {i + 1}
137
+ </span>
138
+ );
139
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.531",
3
+ "version": "0.14.532",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -1,8 +1,15 @@
1
+ import { type Picture } from '../../model/Picture';
1
2
  import '../../setup-fixture';
2
3
 
3
4
  import { StepsBlock } from './StepsBlock';
4
5
  import { type StepProps } from './StepsBlockContent';
5
6
 
7
+ const percentImage: Picture = {
8
+ src: '3-6-percent.png',
9
+ format: 'webp',
10
+ alt: 'Ставка от 3,6% годовых',
11
+ };
12
+
6
13
  const steps: StepProps[] = [
7
14
  {
8
15
  label: 'Заявка на кредит',
@@ -20,6 +27,36 @@ const steps: StepProps[] = [
20
27
  },
21
28
  ];
22
29
 
30
+ const STEPS_WITH_ICONS: StepProps[] = [
31
+ {
32
+ label: 'В мобильном приложении или интернет-банке',
33
+ description: 'Для всех клиентов Россельхозбанка',
34
+ icon: { icon: 'SignDocsIcon', iconVersion: 'normal' },
35
+ },
36
+ {
37
+ label: 'Через Госуслуги',
38
+ description: 'При наличии данных в Единой биометрической системе',
39
+ icon: { icon: 'SignDocsIcon', iconVersion: 'normal' },
40
+ },
41
+ {
42
+ label: 'В офисах Россельхозбанка',
43
+ description: 'Откройте вклад',
44
+ image: percentImage,
45
+ },
46
+ ];
47
+
48
+ const BUTTONS = [
49
+ { text: 'Войти в интернет-банк' },
50
+ { text: 'Оформить' },
51
+ { text: 'Офисы на карте' },
52
+ ];
53
+
54
+ const STEPS_WITH_BUTTONS_AND_ICONS: StepProps[] = STEPS_WITH_ICONS.map((step, i) => ({
55
+ ...step,
56
+ button: BUTTONS[i],
57
+ stepVersion: 'primary',
58
+ }));
59
+
23
60
  export default {
24
61
  primary: (
25
62
  <div className="container grid grid-cols-12">
@@ -27,7 +64,6 @@ export default {
27
64
  <StepsBlock
28
65
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
29
66
  description="Откройте мультивалютный вклад, чтобы распределить свои вложения"
30
- size="normal"
31
67
  steps={steps}
32
68
  stepVersion="gray"
33
69
  buttons={[
@@ -47,20 +83,25 @@ export default {
47
83
  <div className="col-span-12">
48
84
  <StepsBlock
49
85
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
50
- size="small"
51
86
  steps={steps}
52
87
  stepVersion="gray"
53
88
  />
54
89
  </div>
55
90
  </div>
56
91
  ),
92
+ 'primary with button': (
93
+ <div className="container grid grid-cols-12">
94
+ <div className="col-span-12">
95
+ <StepsBlock steps={STEPS_WITH_BUTTONS_AND_ICONS} />
96
+ </div>
97
+ </div>
98
+ ),
57
99
  'primary with images': (
58
100
  <div className="container grid grid-cols-12">
59
101
  <div className="col-span-12">
60
102
  <StepsBlock
61
103
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
62
104
  description="Откройте мультивалютный вклад, чтобы распределить свои вложения"
63
- size="small"
64
105
  stepVersion="primary"
65
106
  steps={[
66
107
  {
@@ -90,7 +131,6 @@ export default {
90
131
  <div className="col-span-12">
91
132
  <StepsBlock
92
133
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
93
- size="small"
94
134
  steps={[
95
135
  {
96
136
  label: 'Заявка на кредит',
@@ -115,7 +155,6 @@ export default {
115
155
  <StepsBlock
116
156
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
117
157
  description="Откройте мультивалютный вклад, чтобы распределить свои вложения"
118
- size="normal"
119
158
  steps={steps}
120
159
  version="secondary"
121
160
  stepVersion="primary"
@@ -128,7 +167,6 @@ export default {
128
167
  <div className="col-span-12">
129
168
  <StepsBlock
130
169
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
131
- size="small"
132
170
  steps={steps}
133
171
  version="secondary"
134
172
  stepVersion="primary"
@@ -142,7 +180,6 @@ export default {
142
180
  <StepsBlock
143
181
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
144
182
  description="Откройте мультивалютный вклад, чтобы распределить свои вложения"
145
- size="small"
146
183
  steps={[
147
184
  {
148
185
  description: 'Оставьте онлайн-заявку на потребительский кредит',
@@ -173,7 +210,6 @@ export default {
173
210
  <div className="col-span-12">
174
211
  <StepsBlock
175
212
  title="Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит"
176
- size="small"
177
213
  steps={[
178
214
  {
179
215
  label: 'Заявка на кредит',
@@ -80,7 +80,6 @@ const STEPS_WITH_BUTTON_PROPS: StepsBlockProps = {
80
80
  })),
81
81
  title: TITLE,
82
82
  stepVersion: 'primary',
83
- size: 'small',
84
83
  buttons: [
85
84
  { text: 'Оформить', version: 'primary' },
86
85
  { text: 'Оформить', version: 'primary' },
@@ -1,32 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { type BlockVersion } from '../../model/BlockVersion';
3
- import { type SizeVersion } from '../../model/SizeVersion';
4
2
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
- import { Img } from '../../ui-kit/Img/Img';
6
3
  import { renderButtonsSection } from '../../ui-kit/LinkButton/renderButtonsSection';
7
- import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
8
- import { RichText } from '../../ui-kit/RichText/RichText';
9
4
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
10
- import { isIcon } from '../../utils/isIcon';
11
5
  import { style } from '../../utils/style';
12
6
  import { Headline } from '../Headline/Headline';
13
- import { getIconTextStyle } from './getIconTextStyle';
14
- import { type StepProps, type StepsBlockContent } from './StepsBlockContent';
15
- import { STEPS_BLOCK_STYLE } from './StepsBlockStyleMaps';
16
-
17
- type StepIconVersion = Record<'icon' | 'image', string>;
18
-
19
- const STEPS_SIZE_MAP: Record<SizeVersion, StepIconVersion> = {
20
- normal: { icon: 'h-11 w-11', image: 'h-14 w-14' },
21
- small: { icon: 'h-12 w-12', image: 'h-14 w-14' },
22
- };
23
-
24
- const STEPS_TILE_DESCRIPTION_HEIGHT_MAP: Record<SizeVersion, string> = {
25
- normal: '',
26
- small: 'min-h-6xl',
27
- };
28
-
29
- const styleMap = STEPS_BLOCK_STYLE;
7
+ import { renderStepMobile } from './renderStepMobile';
8
+ import { type StepsBlockContent } from './StepsBlockContent';
30
9
 
31
10
  export interface StepsBlockProps extends StepsBlockContent, UniBlockProps {}
32
11
 
@@ -35,102 +14,35 @@ export const StepsBlock = JSX<StepsBlockProps>(
35
14
  className = '',
36
15
  title,
37
16
  description,
38
- steps,
17
+ steps = [],
39
18
  buttons,
40
- size = 'normal',
41
19
  stepVersion = 'gray',
42
20
  version = 'primary',
43
21
  ...rest
44
- }) => (
45
- <BlockWrapper
46
- className={style('box-border flex flex-col gap-xl', className)}
47
- defaultPadding="p-6xl"
48
- version={version}
49
- {...rest}
50
- >
51
- <Headline
52
- title={title}
53
- description={description}
54
- headlineVersion="M"
55
- isEmbedded={true}
56
- align="text-left"
57
- />
58
- {steps?.length ? (
59
- <div className="box-border">
60
- <div className="flex flex-col gap-6xl justify-between">
61
- {steps.map(renderStep(size, stepVersion))}
62
- </div>
63
- </div>
64
- ) : null}
65
- {renderButtonsSection(buttons, { isVertical: true })}
66
- </BlockWrapper>
67
- ),
68
- );
69
-
70
- // TODO: Create universal function for this case
71
- const renderStep = (size: SizeVersion, stepVersion: BlockVersion) => (step: StepProps, i: number) =>
72
- (
73
- <div key={String(i)} className="contents">
74
- <div className="flex flex-row items-center relative">
75
- <div className="overflow-hidden flex flex-shrink-0 items-center">
76
- {renderIconArea(size, stepVersion)(step, i)}
77
- </div>
78
- <div
79
- className={style(
80
- 'flex flex-col justify-center h-fit',
81
- STEPS_TILE_DESCRIPTION_HEIGHT_MAP[size],
82
- )}
83
- >
84
- {step.label ? (
85
- <Paragraph size="text-l" align="text-left">
86
- {step.label}
87
- </Paragraph>
88
- ) : null}
89
- {step.description ? (
90
- <div className={style('text-s font-light text-left', styleMap.description)}>
91
- {step.description}
92
- </div>
93
- ) : null}
94
- <RichText __html={step.__html} />
95
- </div>
96
- </div>
97
- </div>
98
- );
99
-
100
- const renderIconArea =
101
- (size: SizeVersion, stepVersion: BlockVersion) => (step: StepProps, i: number) => {
102
- const iconVersion = stepVersion === 'secondary' ? 'white' : 'color';
103
- const isImg = Boolean(step?.icon?.src);
104
- const iconAreaSize = STEPS_SIZE_MAP[size][isImg ? 'image' : 'icon'];
105
- const containerVersion = isImg ? stepVersion === 'transparent' : stepVersion;
22
+ }) => {
23
+ const isBigSizeSteps = steps.length > 3;
106
24
 
107
25
  return (
108
26
  <BlockWrapper
109
- className={style(iconAreaSize, 'z-10 mr-s flex justify-center content-center rounded-md')}
110
- defaultPadding=""
111
- version={containerVersion as BlockVersion}
27
+ className={style('box-border flex flex-col gap-xl', className)}
28
+ defaultPadding="p-6xl"
29
+ version={version}
30
+ {...rest}
112
31
  >
113
- <span className="flex max-w-full max-h-full items-center justify-center">
114
- {isIcon(step?.icon) ? (
115
- <Img
116
- image={{ ...step.icon, iconVersion: step.icon?.iconVersion || iconVersion }}
117
- imageClassName="max-w-full max-h-full"
118
- width={getIconSizeStyle(size)}
119
- height={getIconSizeStyle(size)}
120
- />
121
- ) : (
122
- <span
123
- className={style(
124
- 'text-h4',
125
- stepVersion === 'transparent' ? styleMap.iconText : getIconTextStyle(stepVersion),
126
- )}
127
- >
128
- {i + 1}
129
- </span>
130
- )}
131
- </span>
32
+ <Headline
33
+ title={title}
34
+ description={description}
35
+ headlineVersion="M"
36
+ isEmbedded={true}
37
+ align="text-left"
38
+ />
39
+ {steps?.length ? (
40
+ <div className="flex flex-col gap-6xl justify-between box-border">
41
+ {steps.map(renderStepMobile(isBigSizeSteps, version, stepVersion))}
42
+ </div>
43
+ ) : null}
44
+ {renderButtonsSection(buttons, { isVertical: true })}
132
45
  </BlockWrapper>
133
46
  );
134
- };
135
-
136
- const getIconSizeStyle = (size: string) => (size === 'normal' ? '38' : '24');
47
+ },
48
+ );