@redneckz/wildless-cms-uni-blocks 0.2.53 → 0.2.54

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 (51) hide show
  1. package/dist/BaseTile.d.ts +13 -0
  2. package/dist/BaseTile.js +35 -0
  3. package/dist/BaseTile.js.map +1 -0
  4. package/dist/Blocks.d.ts +2 -2
  5. package/dist/Blocks.js.map +1 -1
  6. package/dist/ExchangeRateTile.js +7 -5
  7. package/dist/ExchangeRateTile.js.map +1 -1
  8. package/dist/ProductBlock.d.ts +2 -0
  9. package/dist/ProductBlock.js +7 -2
  10. package/dist/ProductBlock.js.map +1 -1
  11. package/dist/ProductBlockInner.d.ts +3 -10
  12. package/dist/ProductBlockInner.js +3 -15
  13. package/dist/ProductBlockInner.js.map +1 -1
  14. package/dist/ProductTile.d.ts +4 -13
  15. package/dist/ProductTile.js +4 -11
  16. package/dist/ProductTile.js.map +1 -1
  17. package/dist/Tile.d.ts +3 -11
  18. package/dist/Tile.js +4 -26
  19. package/dist/Tile.js.map +1 -1
  20. package/lib/BaseTile.d.ts +13 -0
  21. package/lib/BaseTile.js +33 -0
  22. package/lib/BaseTile.js.map +1 -0
  23. package/lib/Blocks.d.ts +2 -2
  24. package/lib/Blocks.js.map +1 -1
  25. package/lib/ExchangeRateTile.js +7 -5
  26. package/lib/ExchangeRateTile.js.map +1 -1
  27. package/lib/ProductBlock.d.ts +2 -0
  28. package/lib/ProductBlock.js +8 -3
  29. package/lib/ProductBlock.js.map +1 -1
  30. package/lib/ProductBlockInner.d.ts +3 -10
  31. package/lib/ProductBlockInner.js +3 -15
  32. package/lib/ProductBlockInner.js.map +1 -1
  33. package/lib/ProductTile.d.ts +4 -13
  34. package/lib/ProductTile.js +4 -11
  35. package/lib/ProductTile.js.map +1 -1
  36. package/lib/Tile.d.ts +3 -11
  37. package/lib/Tile.js +5 -27
  38. package/lib/Tile.js.map +1 -1
  39. package/lib/common.css +1 -1
  40. package/package.json +6 -3
  41. package/src/BaseTile.tsx +87 -0
  42. package/src/Blocks.ts +3 -2
  43. package/src/ContentPage.page.json +212 -76
  44. package/src/ExchangeRateTile.tsx +7 -5
  45. package/src/ProductBlock.fixture.tsx +3 -2
  46. package/src/ProductBlock.tsx +25 -3
  47. package/src/ProductBlockInner.tsx +13 -70
  48. package/src/ProductTile.fixture.tsx +31 -23
  49. package/src/ProductTile.tsx +21 -70
  50. package/src/Tile.fixture.tsx +39 -29
  51. package/src/Tile.tsx +10 -79
@@ -43,11 +43,13 @@ export default {
43
43
  description: 'до 5 лет',
44
44
  },
45
45
  ]}
46
- button={{
47
- text: 'Подробнее',
48
- href: '/credit-cards',
49
- version: 'secondary',
50
- }}
46
+ buttons={[
47
+ {
48
+ text: 'Подробнее',
49
+ href: '/credit-cards',
50
+ version: 'secondary',
51
+ },
52
+ ]}
51
53
  image={cardWithMoney}
52
54
  />
53
55
  </div>
@@ -73,12 +75,14 @@ export default {
73
75
  description: 'до 3 лет',
74
76
  },
75
77
  ]}
76
- button={{
77
- href: 'https://rshb.ru',
78
- text: 'Подробнее',
79
- target: '_blank',
80
- version: 'secondary',
81
- }}
78
+ buttons={[
79
+ {
80
+ href: 'https://rshb.ru',
81
+ text: 'Подробнее',
82
+ target: '_blank',
83
+ version: 'secondary',
84
+ },
85
+ ]}
82
86
  image={letterWithMoney}
83
87
  />
84
88
  </div>
@@ -104,12 +108,14 @@ export default {
104
108
  description: 'до 10 лет',
105
109
  },
106
110
  ]}
107
- button={{
108
- href: 'https://rshb.ru',
109
- text: 'Подробнее',
110
- target: '_blank',
111
- version: 'secondary',
112
- }}
111
+ buttons={[
112
+ {
113
+ href: 'https://rshb.ru',
114
+ text: 'Подробнее',
115
+ target: '_blank',
116
+ version: 'secondary',
117
+ },
118
+ ]}
113
119
  image={building}
114
120
  />
115
121
  </div>
@@ -135,12 +141,14 @@ export default {
135
141
  description: 'до 5 лет',
136
142
  },
137
143
  ]}
138
- button={{
139
- href: 'https://rshb.ru',
140
- text: 'Подробнее',
141
- target: '_blank',
142
- version: 'secondary',
143
- }}
144
+ buttons={[
145
+ {
146
+ href: 'https://rshb.ru',
147
+ text: 'Подробнее',
148
+ target: '_blank',
149
+ version: 'secondary',
150
+ },
151
+ ]}
144
152
  />
145
153
  </div>
146
154
  ),
@@ -1,79 +1,30 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import type { ContentPageContext } from './ContentPageContext';
3
- import { Img } from './Img';
4
- import { BlockVersion, Picture } from './types';
5
- import type { ButtonProps } from './ui-kit/Button';
6
- import { Button } from './ui-kit/Button';
7
- import { useLink } from './useLink';
8
- import type { Benefit } from './types';
2
+ import type { UniBlockProps, Benefit } from './types';
3
+ import { BlockVersion } from './types';
4
+ import { Tile } from './Tile';
5
+ import type { BaseTileContent } from './BaseTile';
9
6
 
10
- export interface ProductTileContent {
11
- title?: string;
12
- description?: string;
7
+ export interface ProductTileContent extends BaseTileContent {
13
8
  benefits?: Benefit[];
14
- image?: Picture;
15
- button?: ButtonProps;
16
- version?: BlockVersion;
17
9
  }
18
10
 
19
- export interface ProductTileProps extends ProductTileContent {
20
- className?: string;
21
- context: ContentPageContext;
22
- }
23
-
24
- const productTileStyleMap: Record<BlockVersion, string> = {
25
- primary: 'bg-white text-primary-text',
26
- secondary: 'bg-primary-main text-white',
27
- };
11
+ export interface ProductTileProps extends ProductTileContent, UniBlockProps {}
28
12
 
29
- export const ProductTile = JSX<ProductTileProps>(
30
- ({ className, context, title, description, button, image, benefits, version = 'primary' }) => {
31
- const router = context.useRouter();
32
- const { handlerDecorator } = context;
33
- return (
34
- <section className={`font-sans p-9 ${className || ''} ${productTileStyleMap[version]}`}>
35
- <div className="flex flex-col w-full">
36
- {title && (
37
- <h3 className="font-medium text-title-sm m-0 whitespace-pre-wrap max-w-[600px]">
38
- {title}
39
- </h3>
40
- )}
41
- {description && (
42
- <div className="font-normal text-base max-w-[600px] mt-4">{description}</div>
43
- )}
44
- <div className="flex mt-5">
45
- <div className="grow flex flex-col">
46
- <div className="flex">
47
- {benefits?.length ? (
48
- <div className="mr-8">{benefits.map(renderBenefitDescription)}</div>
49
- ) : null}
50
- {benefits?.length ? (
51
- <div className="pt-1">
52
- {benefits.map((_, i) => renderBenefitLabel(_, i, version))}
53
- </div>
54
- ) : null}
55
- </div>
56
- {button?.text && (
57
- <div className="mt-auto">
58
- <Button
59
- className="mt-8"
60
- {...useLink({ router, handlerDecorator }, button)}
61
- version="secondary"
62
- />
63
- </div>
64
- )}
65
- </div>
66
- {image && (
67
- <div className="mt-auto flex-none h-[220px] w-[220px]">
68
- <Img image={image} />
69
- </div>
70
- )}
71
- </div>
72
- </div>
73
- </section>
74
- );
75
- },
76
- );
13
+ export const ProductTile = JSX<ProductTileProps>((props) => {
14
+ const { benefits, version } = props;
15
+ return (
16
+ <Tile {...props}>
17
+ <div className="flex mt-5 mb-10">
18
+ {benefits?.length ? (
19
+ <div className="mr-8">{benefits.map(renderBenefitDescription)}</div>
20
+ ) : null}
21
+ {benefits?.length ? (
22
+ <div className="pt-1">{benefits.map((_, i) => renderBenefitLabel(_, i, version))}</div>
23
+ ) : null}
24
+ </div>
25
+ </Tile>
26
+ );
27
+ });
77
28
 
78
29
  function renderBenefitLabel(benefit: Benefit, i: number, version = 'primary') {
79
30
  const labelStyleMap: Record<BlockVersion, string> = {
@@ -35,11 +35,13 @@ export default {
35
35
  'Кредиты наличными на любые цели',
36
36
  'Получите деньги без залога и поручителей',
37
37
  ]}
38
- button={{
39
- text: 'Подробнее',
40
- href: '/credit-cards',
41
- version: 'secondary',
42
- }}
38
+ buttons={[
39
+ {
40
+ text: 'Подробнее',
41
+ href: '/credit-cards',
42
+ version: 'secondary',
43
+ },
44
+ ]}
43
45
  image={image}
44
46
  />
45
47
  </div>
@@ -54,12 +56,14 @@ export default {
54
56
  description={
55
57
  'Широкий выбор ипотечных программ с государственной поддержкой. Специальные предложения от 12,2 %'
56
58
  }
57
- button={{
58
- href: 'https://rshb.ru',
59
- text: 'Подробнее',
60
- target: '_blank',
61
- version: 'secondary',
62
- }}
59
+ buttons={[
60
+ {
61
+ href: 'https://rshb.ru',
62
+ text: 'Подробнее',
63
+ target: '_blank',
64
+ version: 'secondary',
65
+ },
66
+ ]}
63
67
  />
64
68
  </div>
65
69
  ),
@@ -70,12 +74,14 @@ export default {
70
74
  className="col-span-6"
71
75
  title="Банковские пластиковые карты"
72
76
  items={['Счета в разных валютах', 'Бесплатное обслуживание', 'Кэшбэк до 15% от покупок']}
73
- button={{
74
- href: 'https://rshb.ru',
75
- text: 'Подробнее',
76
- target: '_blank',
77
- version: 'secondary',
78
- }}
77
+ buttons={[
78
+ {
79
+ href: 'https://rshb.ru',
80
+ text: 'Подробнее',
81
+ target: '_blank',
82
+ version: 'secondary',
83
+ },
84
+ ]}
79
85
  image={image2}
80
86
  />
81
87
  </div>
@@ -89,12 +95,14 @@ export default {
89
95
  description={
90
96
  'Выделенные зоны обслуживания и персональный финансовый консультант. Полный спектр премиальных продуктов, подчеркивающих ваш статус'
91
97
  }
92
- button={{
93
- href: 'https://rshb.ru',
94
- text: 'Подробнее',
95
- target: '_blank',
96
- version: 'secondary',
97
- }}
98
+ buttons={[
99
+ {
100
+ href: 'https://rshb.ru',
101
+ text: 'Подробнее',
102
+ target: '_blank',
103
+ version: 'secondary',
104
+ },
105
+ ]}
98
106
  image={image3}
99
107
  />
100
108
  </div>
@@ -111,12 +119,14 @@ export default {
111
119
  'Площадки для создания комфортной жизни за городом',
112
120
  'Подробная база вакансий для жителей сельской местности',
113
121
  ]}
114
- button={{
115
- href: 'https://rshb.ru',
116
- text: 'Подробнее',
117
- target: '_blank',
118
- version: 'secondary',
119
- }}
122
+ buttons={[
123
+ {
124
+ href: 'https://rshb.ru',
125
+ text: 'Подробнее',
126
+ target: '_blank',
127
+ version: 'secondary',
128
+ },
129
+ ]}
120
130
  image={image4}
121
131
  />
122
132
  </div>
package/src/Tile.tsx CHANGED
@@ -1,89 +1,20 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { Img } from './Img';
3
2
  import type { BlockVersion, Picture, UniBlockProps } from './types';
4
- import { BlockItem } from './ui-kit/BlockItem';
5
- import type { ButtonProps } from './ui-kit/Button';
6
- import { Button } from './ui-kit/Button';
7
- import { useLink } from './useLink';
3
+ import { BaseTile } from './BaseTile';
4
+ import type { BaseTileContent } from './BaseTile';
8
5
 
9
- export interface TileContent {
10
- title?: string;
11
- description?: string;
12
- image?: Picture;
13
- items?: string[];
14
- button?: ButtonProps;
15
- version?: BlockVersion;
16
- }
17
-
18
- export interface TileProps extends TileContent, UniBlockProps {}
6
+ export interface TileProps extends BaseTileContent, UniBlockProps {}
19
7
 
20
8
  const tileStyleMap: Record<BlockVersion, string> = {
21
9
  primary: 'bg-white text-primary-text',
22
10
  secondary: 'bg-primary-main text-white',
23
11
  };
24
12
 
25
- const TITLE_CLASSES = 'font-medium m-0 whitespace-pre-wrap max-w-[600px]';
26
-
27
- export const Tile = JSX<TileProps>(
28
- ({
29
- className,
30
- context,
31
- title,
32
- description,
33
- children,
34
- button,
35
- image,
36
- items,
37
- version = 'primary',
38
- }) => {
39
- const router = context.useRouter();
40
- const { handlerDecorator } = context;
41
- return (
42
- <section
43
- className={`flex flex-col font-sans p-9 ${className || ''} ${tileStyleMap[version]}`}
44
- >
45
- {title && renderTitle(title, className)}
46
- <div className="grow flex justify-between mt-6">
47
- <div className="flex flex-col justify-between items-start">
48
- {description || children ? (
49
- <div className="font-normal text-base max-w-[600px]">{description || children}</div>
50
- ) : (
51
- renderItems(items, version)
52
- )}
53
- {button?.text && (
54
- <Button
55
- className="mt-6"
56
- {...useLink({ router, handlerDecorator }, button)}
57
- version="secondary"
58
- />
59
- )}
60
- </div>
61
- {image?.src && <Img className="mt-auto h-[220px] w-[220px]" image={image} />}
62
- </div>
63
- </section>
64
- );
65
- },
66
- );
67
-
68
- function renderTitle(title: string, className: string = '') {
69
- const colSpanPrefix = 'col-span-';
70
- const colSpanStr = className.split(/\s+/).find((_) => _.startsWith(colSpanPrefix));
71
- const colSpan = colSpanStr ? parseInt(colSpanStr.substring(colSpanPrefix.length), 10) : 12;
72
- if (colSpan <= 4) {
73
- return <h3 className={`${TITLE_CLASSES} text-title-xs`}>{title}</h3>;
74
- } else if (colSpan <= 8) {
75
- return <h3 className={`${TITLE_CLASSES} text-title-sm`}>{title}</h3>;
76
- } else {
77
- return <h2 className={`${TITLE_CLASSES} text-title`}>{title}</h2>;
78
- }
79
- }
80
-
81
- function renderItems(items?: string[], version?: BlockVersion) {
82
- return items?.length ? (
83
- <section className="max-w-[600px]" role="list">
84
- {items.map((_, i) => (
85
- <BlockItem key={String(i)} className={i ? 'mt-2.5' : ''} text={_} version={version} />
86
- ))}
13
+ export const Tile = JSX<TileProps>((props) => {
14
+ const { children, className, version = 'primary' } = props;
15
+ return (
16
+ <section className={`font-sans p-9 ${className || ''} ${tileStyleMap[version]}`}>
17
+ <BaseTile {...props}>{children}</BaseTile>
87
18
  </section>
88
- ) : null;
89
- }
19
+ );
20
+ });