@redneckz/wildless-cms-uni-blocks 0.6.42 → 0.6.43

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 (155) hide show
  1. package/bin/migration-scripts/0.6.34.js +2 -0
  2. package/bin/migration-scripts/0.6.43.js +29 -0
  3. package/bundle/blocks.schema.json +1 -1
  4. package/bundle/bundle.umd.js +84 -70
  5. package/bundle/bundle.umd.min.js +1 -1
  6. package/bundle/components/ProductTile/ProductTileContent.d.ts +24 -2
  7. package/bundle/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  8. package/bundle/components/ProductTile/renderBenefit.d.ts +4 -0
  9. package/bundle/components/ProductTile/renderImage.d.ts +3 -0
  10. package/bundle/content-page-repository/transformImg.d.ts +1 -1
  11. package/bundle/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  12. package/bundle/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  13. package/dist/components/ProductTile/ProductTile.js +9 -22
  14. package/dist/components/ProductTile/ProductTile.js.map +1 -1
  15. package/dist/components/ProductTile/ProductTileContent.d.ts +24 -2
  16. package/dist/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  17. package/dist/components/ProductTile/renderAdditionalDescription.js +18 -0
  18. package/dist/components/ProductTile/renderAdditionalDescription.js.map +1 -0
  19. package/dist/components/ProductTile/renderBenefit.d.ts +4 -0
  20. package/dist/components/ProductTile/renderBenefit.js +32 -0
  21. package/dist/components/ProductTile/renderBenefit.js.map +1 -0
  22. package/dist/components/ProductTile/renderImage.d.ts +3 -0
  23. package/dist/components/ProductTile/renderImage.js +12 -0
  24. package/dist/components/ProductTile/renderImage.js.map +1 -0
  25. package/dist/components/TextBlock/TextBlock.js +13 -28
  26. package/dist/components/TextBlock/TextBlock.js.map +1 -1
  27. package/dist/content-page-repository/transformImg.d.ts +1 -1
  28. package/dist/content-page-repository/transformImg.js +4 -10
  29. package/dist/content-page-repository/transformImg.js.map +1 -1
  30. package/dist/content-page-repository/transformMarkdown.js +3 -3
  31. package/dist/content-page-repository/transformMarkdown.js.map +1 -1
  32. package/dist/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  33. package/dist/ui-kit/MarkdownText/MarkdownText.js +9 -0
  34. package/dist/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
  35. package/dist/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  36. package/dist/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
  37. package/dist/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
  38. package/dist/ui-kit/Text/Text.js +1 -5
  39. package/dist/ui-kit/Text/Text.js.map +1 -1
  40. package/lib/common.css +1 -1
  41. package/lib/components/ProductTile/ProductTile.js +10 -23
  42. package/lib/components/ProductTile/ProductTile.js.map +1 -1
  43. package/lib/components/ProductTile/ProductTileContent.d.ts +24 -2
  44. package/lib/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  45. package/lib/components/ProductTile/renderAdditionalDescription.js +15 -0
  46. package/lib/components/ProductTile/renderAdditionalDescription.js.map +1 -0
  47. package/lib/components/ProductTile/renderBenefit.d.ts +4 -0
  48. package/lib/components/ProductTile/renderBenefit.js +29 -0
  49. package/lib/components/ProductTile/renderBenefit.js.map +1 -0
  50. package/lib/components/ProductTile/renderImage.d.ts +3 -0
  51. package/lib/components/ProductTile/renderImage.js +9 -0
  52. package/lib/components/ProductTile/renderImage.js.map +1 -0
  53. package/lib/components/TextBlock/TextBlock.js +13 -28
  54. package/lib/components/TextBlock/TextBlock.js.map +1 -1
  55. package/lib/content-page-repository/transformImg.d.ts +1 -1
  56. package/lib/content-page-repository/transformImg.js +4 -10
  57. package/lib/content-page-repository/transformImg.js.map +1 -1
  58. package/lib/content-page-repository/transformMarkdown.js +3 -3
  59. package/lib/content-page-repository/transformMarkdown.js.map +1 -1
  60. package/lib/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  61. package/lib/ui-kit/MarkdownText/MarkdownText.js +7 -0
  62. package/lib/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
  63. package/lib/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  64. package/lib/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
  65. package/lib/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
  66. package/lib/ui-kit/Text/Text.js +1 -5
  67. package/lib/ui-kit/Text/Text.js.map +1 -1
  68. package/mobile/bundle/bundle.umd.js +2 -6
  69. package/mobile/bundle/bundle.umd.min.js +1 -1
  70. package/mobile/bundle/components/ProductTile/ProductTileContent.d.ts +24 -2
  71. package/mobile/bundle/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  72. package/mobile/bundle/components/ProductTile/renderBenefit.d.ts +4 -0
  73. package/mobile/bundle/components/ProductTile/renderImage.d.ts +3 -0
  74. package/mobile/bundle/content-page-repository/transformImg.d.ts +1 -1
  75. package/mobile/bundle/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  76. package/mobile/bundle/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  77. package/mobile/dist/components/ProductTile/ProductTile.js +9 -22
  78. package/mobile/dist/components/ProductTile/ProductTile.js.map +1 -1
  79. package/mobile/dist/components/ProductTile/ProductTileContent.d.ts +24 -2
  80. package/mobile/dist/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  81. package/mobile/dist/components/ProductTile/renderAdditionalDescription.js +18 -0
  82. package/mobile/dist/components/ProductTile/renderAdditionalDescription.js.map +1 -0
  83. package/mobile/dist/components/ProductTile/renderBenefit.d.ts +4 -0
  84. package/mobile/dist/components/ProductTile/renderBenefit.js +32 -0
  85. package/mobile/dist/components/ProductTile/renderBenefit.js.map +1 -0
  86. package/mobile/dist/components/ProductTile/renderImage.d.ts +3 -0
  87. package/mobile/dist/components/ProductTile/renderImage.js +12 -0
  88. package/mobile/dist/components/ProductTile/renderImage.js.map +1 -0
  89. package/mobile/dist/content-page-repository/transformImg.d.ts +1 -1
  90. package/mobile/dist/content-page-repository/transformImg.js +4 -10
  91. package/mobile/dist/content-page-repository/transformImg.js.map +1 -1
  92. package/mobile/dist/content-page-repository/transformMarkdown.js +3 -3
  93. package/mobile/dist/content-page-repository/transformMarkdown.js.map +1 -1
  94. package/mobile/dist/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  95. package/mobile/dist/ui-kit/MarkdownText/MarkdownText.js +9 -0
  96. package/mobile/dist/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
  97. package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  98. package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
  99. package/mobile/dist/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
  100. package/mobile/dist/ui-kit/Text/Text.js +1 -5
  101. package/mobile/dist/ui-kit/Text/Text.js.map +1 -1
  102. package/mobile/lib/components/ProductTile/ProductTile.js +10 -23
  103. package/mobile/lib/components/ProductTile/ProductTile.js.map +1 -1
  104. package/mobile/lib/components/ProductTile/ProductTileContent.d.ts +24 -2
  105. package/mobile/lib/components/ProductTile/renderAdditionalDescription.d.ts +4 -0
  106. package/mobile/lib/components/ProductTile/renderAdditionalDescription.js +15 -0
  107. package/mobile/lib/components/ProductTile/renderAdditionalDescription.js.map +1 -0
  108. package/mobile/lib/components/ProductTile/renderBenefit.d.ts +4 -0
  109. package/mobile/lib/components/ProductTile/renderBenefit.js +29 -0
  110. package/mobile/lib/components/ProductTile/renderBenefit.js.map +1 -0
  111. package/mobile/lib/components/ProductTile/renderImage.d.ts +3 -0
  112. package/mobile/lib/components/ProductTile/renderImage.js +9 -0
  113. package/mobile/lib/components/ProductTile/renderImage.js.map +1 -0
  114. package/mobile/lib/content-page-repository/transformImg.d.ts +1 -1
  115. package/mobile/lib/content-page-repository/transformImg.js +4 -10
  116. package/mobile/lib/content-page-repository/transformImg.js.map +1 -1
  117. package/mobile/lib/content-page-repository/transformMarkdown.js +3 -3
  118. package/mobile/lib/content-page-repository/transformMarkdown.js.map +1 -1
  119. package/mobile/lib/ui-kit/MarkdownText/MarkdownText.d.ts +2 -0
  120. package/mobile/lib/ui-kit/MarkdownText/MarkdownText.js +7 -0
  121. package/mobile/lib/ui-kit/MarkdownText/MarkdownText.js.map +1 -0
  122. package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.d.ts +6 -0
  123. package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.js +2 -0
  124. package/mobile/lib/ui-kit/MarkdownText/MarkdownTextProps.js.map +1 -0
  125. package/mobile/lib/ui-kit/Text/Text.js +1 -5
  126. package/mobile/lib/ui-kit/Text/Text.js.map +1 -1
  127. package/mobile/src/common.css +50 -0
  128. package/mobile/src/components/ProductTile/ProductTile.example.json +3 -0
  129. package/mobile/src/components/ProductTile/ProductTile.tsx +13 -44
  130. package/mobile/src/components/ProductTile/ProductTile.ui.json +14 -1
  131. package/mobile/src/components/ProductTile/ProductTileContent.ts +26 -2
  132. package/mobile/src/components/ProductTile/renderAdditionalDescription.tsx +30 -0
  133. package/mobile/src/components/ProductTile/renderBenefit.tsx +39 -0
  134. package/mobile/src/components/ProductTile/renderImage.tsx +15 -0
  135. package/mobile/src/content-page-repository/transformImg.ts +6 -14
  136. package/mobile/src/content-page-repository/transformMarkdown.ts +3 -3
  137. package/mobile/src/ui-kit/MarkdownText/MarkdownText.tsx +8 -0
  138. package/mobile/src/ui-kit/MarkdownText/MarkdownTextProps.ts +6 -0
  139. package/mobile/src/ui-kit/Text/Text.tsx +5 -7
  140. package/package.json +1 -1
  141. package/src/common.css +50 -0
  142. package/src/components/ProductTile/ProductTile.example.json +3 -0
  143. package/src/components/ProductTile/ProductTile.fixture.tsx +11 -4
  144. package/src/components/ProductTile/ProductTile.tsx +13 -44
  145. package/src/components/ProductTile/ProductTile.ui.json +14 -1
  146. package/src/components/ProductTile/ProductTileContent.ts +26 -2
  147. package/src/components/ProductTile/renderAdditionalDescription.tsx +30 -0
  148. package/src/components/ProductTile/renderBenefit.tsx +39 -0
  149. package/src/components/ProductTile/renderImage.tsx +15 -0
  150. package/src/components/TextBlock/TextBlock.tsx +49 -41
  151. package/src/content-page-repository/transformImg.ts +6 -14
  152. package/src/content-page-repository/transformMarkdown.ts +3 -3
  153. package/src/ui-kit/MarkdownText/MarkdownText.tsx +8 -0
  154. package/src/ui-kit/MarkdownText/MarkdownTextProps.ts +6 -0
  155. package/src/ui-kit/Text/Text.tsx +5 -7
@@ -1,14 +1,16 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import type { BlockVersion } from '../../model/BlockVersion';
3
- import { VersionAdditionalStyleMap, VersionStyleMap } from '../../model/BlockVersion';
3
+ import { VersionStyleMap } from '../../model/BlockVersion';
4
4
  import type { UniBlockProps } from '../../model/JSXBlock';
5
5
  import type { Picture } from '../../model/Picture';
6
6
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
7
7
  import { ButtonSection } from '../../ui-kit/Button/ButtonSection';
8
- import { Img } from '../../ui-kit/Img/Img';
9
8
  import { getTileRightPadding } from '../BaseTile/getTileRightPadding';
10
9
  import { Headline } from '../Headline/Headline';
11
- import type { ProductTileContent, TextBenefit } from './ProductTileContent';
10
+ import type { Benefit, ProductTileContent } from './ProductTileContent';
11
+ import { renderAdditionalDescription } from './renderAdditionalDescription';
12
+ import { renderBenefit } from './renderBenefit';
13
+ import { renderImage } from './renderImage';
12
14
 
13
15
  export interface ProductTileProps extends ProductTileContent, UniBlockProps {}
14
16
 
@@ -43,7 +45,7 @@ export const ProductTile = JSX<ProductTileProps>(
43
45
  {...rest}
44
46
  />
45
47
  {renderBenefits(benefits, version, image)}
46
- {additionalDescription ? renderAdditionalDescription(additionalDescription, image) : null}
48
+ {renderAdditionalDescription(additionalDescription, image)}
47
49
  {buttons?.length ? (
48
50
  <ButtonSection buttons={buttons} className="mt-5 gap-4 z-10 text-l" />
49
51
  ) : null}
@@ -53,53 +55,20 @@ export const ProductTile = JSX<ProductTileProps>(
53
55
  ),
54
56
  );
55
57
 
56
- function renderBenefits(benefits: TextBenefit[], version: BlockVersion, image?: Picture) {
58
+ function renderBenefits(benefits: Benefit[], version: BlockVersion, image?: Picture) {
59
+ if (!benefits.length) {
60
+ return null;
61
+ }
62
+
57
63
  // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
58
- const BENEFITS_WIDTH = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
64
+ const benefitsWidth = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
59
65
 
60
66
  return (
61
67
  <div
62
68
  className={`z-10 grid grid-cols-[max-content_1fr] auto-rows-auto gap-x-6 gap-y-2.5 items-baseline
63
- ${BENEFITS_WIDTH}`}
69
+ ${benefitsWidth}`}
64
70
  >
65
71
  {benefits.length ? benefits.map(renderBenefit(version)) : null}
66
72
  </div>
67
73
  );
68
74
  }
69
-
70
- const renderBenefit =
71
- (version: BlockVersion = 'primary') =>
72
- (benefit: TextBenefit, i: number) => {
73
- const { label = '', description = '' } = benefit;
74
-
75
- return [
76
- <div key={`label-${i}`} className="text-h6">
77
- {label}
78
- </div>,
79
- <div key={`desc-${i}`} className={`text-m-light ${VersionAdditionalStyleMap[version]}`}>
80
- {description}
81
- </div>,
82
- ];
83
- };
84
-
85
- function renderAdditionalDescription(additionalDescription: string, image?: Picture) {
86
- // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
87
- const DESCRIPTION_WIDTH = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
88
-
89
- return (
90
- <div className={`text-m-light mt-2.5 z-10 ${DESCRIPTION_WIDTH}`}>{additionalDescription}</div>
91
- );
92
- }
93
-
94
- function renderImage(image?: Picture, isImageOnRightSide?: boolean) {
95
- if (!image?.src) {
96
- return null;
97
- }
98
-
99
- return (
100
- <Img
101
- className={`absolute ${isImageOnRightSide ? 'right-0' : 'left-0'} bottom-0`}
102
- image={image}
103
- />
104
- );
105
- }
@@ -1 +1,14 @@
1
- {}
1
+ {
2
+ "content": {
3
+ "benefits": {
4
+ "items": {
5
+ "md": {
6
+ "ui:widget": "html"
7
+ },
8
+ "type": {
9
+ "ui:widget": "hidden"
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
@@ -2,8 +2,32 @@ import type { BlockVersion } from '../../model/BlockVersion';
2
2
  import type { DescriptionProps, HeadlineProps, LabelProps } from '../../model/HeadlineType';
3
3
  import type { Picture } from '../../model/Picture';
4
4
  import type { ButtonContent } from '../../ui-kit/Button/ButtonProps';
5
+ import type { MarkdownTextProps } from '../../ui-kit/MarkdownText/MarkdownTextProps';
5
6
 
6
- export type TextBenefit = DescriptionProps & LabelProps;
7
+ /**
8
+ * @title Стандартный
9
+ */
10
+ type TextBenefit = DescriptionProps &
11
+ LabelProps & {
12
+ /** @default default */
13
+ type: 'default';
14
+ };
15
+
16
+ /**
17
+ * @title Форматированный текст
18
+ */
19
+ type MarkdownTextContent = MarkdownTextProps & {
20
+ /** @default md */
21
+ type: 'md';
22
+ };
23
+
24
+ /**
25
+ * @title Преимущество
26
+ * @default{
27
+ * "type": "default"
28
+ * }
29
+ */
30
+ export type Benefit = TextBenefit | MarkdownTextContent;
7
31
 
8
32
  /**
9
33
  * @title Продуктовая плитка
@@ -30,7 +54,7 @@ export type ProductTileContent = HeadlineProps &
30
54
  * @title Преимущества
31
55
  * @maxItems 7
32
56
  */
33
- benefits?: TextBenefit[];
57
+ benefits?: Benefit[];
34
58
  /** @title Дополнительное описание */
35
59
  additionalDescription?: string;
36
60
  /** @title Картинка справа/текст слева */
@@ -0,0 +1,30 @@
1
+ import type { BlockVersion } from '../../model/BlockVersion';
2
+ import type { Picture } from '../../model/Picture';
3
+ import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
4
+ import type { TextColor } from '../../ui-kit/Text/TextProps';
5
+
6
+ const DESCRIPTION_STYLE_MAP: Record<BlockVersion, TextColor> = {
7
+ primary: 'text-secondary-text',
8
+ secondary: 'text-white',
9
+ };
10
+
11
+ export function renderAdditionalDescription(
12
+ additionalDescription?: string,
13
+ image?: Picture,
14
+ version: BlockVersion = 'primary',
15
+ ) {
16
+ if (!additionalDescription) {
17
+ return null;
18
+ }
19
+
20
+ // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
21
+ const descriptionWidth = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
22
+
23
+ return (
24
+ <div className={`mt-2.5 z-10 ${descriptionWidth}`}>
25
+ <Paragraph size="text-m" font="font-light" color={DESCRIPTION_STYLE_MAP[version]}>
26
+ {additionalDescription}
27
+ </Paragraph>
28
+ </div>
29
+ );
30
+ }
@@ -0,0 +1,39 @@
1
+ import type { BlockVersion } from '../../model/BlockVersion';
2
+ import { MarkdownText } from '../../ui-kit/MarkdownText/MarkdownText';
3
+ import { Text } from '../../ui-kit/Text/Text';
4
+ import type { TextColor } from '../../ui-kit/Text/TextProps';
5
+ import { assertUnreachable } from '../../utils/assertUnreachable';
6
+ import type { Benefit } from './ProductTileContent';
7
+
8
+ const LABEL_STYLE_MAP: Record<BlockVersion, TextColor> = {
9
+ primary: 'text-secondary-text',
10
+ secondary: 'text-white',
11
+ };
12
+
13
+ export const renderBenefit =
14
+ (version: BlockVersion = 'primary') =>
15
+ // Linter doesn't understand that switch processes all cases
16
+ // eslint-disable-next-line consistent-return
17
+ (benefit: Benefit, i: number) => {
18
+ const { type } = benefit;
19
+
20
+ if (!(type === 'default' || type === 'md')) {
21
+ return null;
22
+ }
23
+
24
+ switch (type) {
25
+ case 'default':
26
+ return [
27
+ <Text key={`label-${i}`} size="text-h6">
28
+ {benefit.label}
29
+ </Text>,
30
+ <Text key={`desc-${i}`} size="text-m-light" color={LABEL_STYLE_MAP[version]}>
31
+ {benefit.description}
32
+ </Text>,
33
+ ];
34
+ case 'md':
35
+ return <MarkdownText md={benefit.md} />;
36
+ default:
37
+ assertUnreachable(benefit);
38
+ }
39
+ };
@@ -0,0 +1,15 @@
1
+ import type { Picture } from '../../model/Picture';
2
+ import { Img } from '../../ui-kit/Img/Img';
3
+
4
+ export function renderImage(image?: Picture, isImageOnRightSide?: boolean) {
5
+ if (!image?.src) {
6
+ return null;
7
+ }
8
+
9
+ return (
10
+ <Img
11
+ className={`absolute ${isImageOnRightSide ? 'right-0' : 'left-0'} bottom-0`}
12
+ image={image}
13
+ />
14
+ );
15
+ }
@@ -1,13 +1,13 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import util from 'util';
4
- import sharp from 'sharp';
5
3
  import type { ResizeOptions, Sharp } from 'sharp';
4
+ import sharp from 'sharp';
5
+ import util from 'util';
6
6
  import type { ImageSize } from '../model/ImageSize';
7
- import type { TransformationOptions } from './TransformationOptions';
8
7
  import type { ImgAlignment, ImgSource, Picture } from '../model/Picture';
9
- import { transformSrc } from './transformSrc';
10
8
  import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty';
9
+ import type { TransformationOptions } from './TransformationOptions';
10
+ import { transformSrc } from './transformSrc';
11
11
 
12
12
  const mkdir = util.promisify(fs.mkdir);
13
13
 
@@ -126,20 +126,12 @@ function getCompositionResizeSize(
126
126
  const { width, height } = size;
127
127
  const { width: containerWidth, height: containerHeight } = containerSize;
128
128
 
129
- let widthRatio = 0;
130
- let heightRatio = 0;
131
-
132
129
  if (!(width || height)) {
133
130
  return undefined;
134
131
  }
135
132
 
136
- if (width) {
137
- widthRatio = containerWidth / width;
138
- }
139
-
140
- if (height) {
141
- heightRatio = containerHeight / height;
142
- }
133
+ const widthRatio = width ? containerWidth / width : 0;
134
+ const heightRatio = height ? containerHeight / height : 0;
143
135
 
144
136
  return widthRatio > heightRatio
145
137
  ? { width: Math.min(Number(width), containerWidth) }
@@ -1,6 +1,6 @@
1
- import { unified } from 'unified';
2
- import remarkParse from 'remark-parse';
3
1
  import remarkHtml from 'remark-html';
2
+ import remarkParse from 'remark-parse';
3
+ import { unified } from 'unified';
4
4
 
5
5
  export async function transformMarkdown(markdown: string | null | undefined): Promise<string> {
6
6
  if (!markdown) {
@@ -9,5 +9,5 @@ export async function transformMarkdown(markdown: string | null | undefined): Pr
9
9
 
10
10
  const result = await unified().use(remarkParse).use(remarkHtml).process(markdown);
11
11
 
12
- return result.toString('utf-8');
12
+ return result.toString('utf-8').replaceAll(/<h(\d)>([^<]*)<\/h\d>/g, '<p class="h$1">$2</p>');
13
13
  }
@@ -0,0 +1,8 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import type { MarkdownTextProps } from './MarkdownTextProps';
3
+
4
+ export const MarkdownText = JSX<MarkdownTextProps>((props) => {
5
+ const { md = '' } = props;
6
+
7
+ return <div className="md-container" dangerouslySetInnerHTML={{ __html: md }} />;
8
+ });
@@ -0,0 +1,6 @@
1
+ type Markdown = string;
2
+
3
+ export interface MarkdownTextProps {
4
+ /** @title Текст */
5
+ md?: Markdown;
6
+ }
@@ -8,10 +8,8 @@ interface TextProps {
8
8
  font?: FontWeight;
9
9
  }
10
10
 
11
- export const Text = JSX<TextProps>((props) => {
12
- const { size = '', color = '', align = '', font = '', children } = props;
13
-
14
- const textClasses = `font-sans ${size} ${color} ${align} ${font}`;
15
-
16
- return <span className={textClasses}>{children}</span>;
17
- });
11
+ export const Text = JSX<TextProps>(({ size, color, align, font, children }) => (
12
+ <span className={['font-sans', size, color, align, font].filter(Boolean).join(' ')}>
13
+ {children}
14
+ </span>
15
+ ));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.6.42",
3
+ "version": "0.6.43",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
package/src/common.css CHANGED
@@ -151,6 +151,56 @@ html {
151
151
  }
152
152
  }
153
153
 
154
+ @layer components {
155
+ .md-container .h1 {
156
+ @apply text-h1;
157
+ }
158
+
159
+ .md-container .h2 {
160
+ @apply text-h2;
161
+ }
162
+
163
+ .md-container .h3 {
164
+ @apply text-h3;
165
+ }
166
+
167
+ .md-container .h4 {
168
+ @apply text-h4;
169
+ }
170
+
171
+ .md-container .h5 {
172
+ @apply text-h5;
173
+ }
174
+
175
+ .md-container .h6 {
176
+ @apply text-h6;
177
+ }
178
+
179
+ .md-container ul {
180
+ @apply list-inside list-disc;
181
+ }
182
+
183
+ .md-container ol {
184
+ @apply list-inside list-decimal;
185
+ }
186
+
187
+ .md-container p {
188
+ @apply text-l font-light;
189
+ }
190
+
191
+ .md-container li {
192
+ @apply text-l font-light;
193
+ }
194
+
195
+ .md-container li > p {
196
+ @apply inline;
197
+ }
198
+
199
+ .md-container a {
200
+ @apply text-primary-main;
201
+ }
202
+ }
203
+
154
204
  /*
155
205
  Styling Yandex Map element
156
206
  */
@@ -12,14 +12,17 @@
12
12
  "version": "primary",
13
13
  "benefits": [
14
14
  {
15
+ "type": "default",
15
16
  "label": "Преимущество 1",
16
17
  "description": "Описание"
17
18
  },
18
19
  {
20
+ "type": "default",
19
21
  "label": "Преимущество 2",
20
22
  "description": "Описание"
21
23
  },
22
24
  {
25
+ "type": "default",
23
26
  "label": "Преимущество 3",
24
27
  "description": "Описание"
25
28
  }
@@ -2,7 +2,7 @@ import type { Picture } from '../../model/Picture';
2
2
  import '../../setup-fixture';
3
3
  import type { ButtonProps } from '../../ui-kit/Button/ButtonProps';
4
4
  import { ProductTile } from './ProductTile';
5
- import type { ProductTileContent } from './ProductTileContent';
5
+ import type { Benefit, ProductTileContent } from './ProductTileContent';
6
6
 
7
7
  const imageSize = {
8
8
  height: 242,
@@ -37,38 +37,45 @@ const building: Picture = {
37
37
  size: imageSize,
38
38
  };
39
39
 
40
- const benefits = [
40
+ const benefits: Benefit[] = [
41
41
  {
42
+ type: 'default',
42
43
  label: 'до 5 млн Р',
43
44
  description: 'Кредитный лимит',
44
45
  },
45
46
  {
47
+ type: 'default',
46
48
  label: 'от 12,5%',
47
49
  description: 'Процентная ставка',
48
50
  },
49
51
  {
52
+ type: 'default',
50
53
  label: 'до 5 лет',
51
54
  description: 'Срок кредитования',
52
55
  },
53
56
  ];
54
57
 
55
- const benefits2 = [
58
+ const benefits2: Benefit[] = [
56
59
  {
60
+ type: 'default',
57
61
  label: '1 год',
58
62
  description: 'срок программы',
59
63
  },
60
64
  ];
61
65
 
62
- const multilineBenefits = [
66
+ const multilineBenefits: Benefit[] = [
63
67
  {
68
+ type: 'default',
64
69
  label: 'Широкий',
65
70
  description: 'выбор платёжных систем',
66
71
  },
67
72
  {
73
+ type: 'default',
68
74
  label: 'Специальные',
69
75
  description: 'условия по снятию наличных условия по снятию наличных',
70
76
  },
71
77
  {
78
+ type: 'default',
72
79
  label: '0,5 балла',
73
80
  description: '«Урожай» за 100 рублей «Урожай» за 100 рублей',
74
81
  },
@@ -1,14 +1,16 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import type { BlockVersion } from '../../model/BlockVersion';
3
- import { VersionAdditionalStyleMap, VersionStyleMap } from '../../model/BlockVersion';
3
+ import { VersionStyleMap } from '../../model/BlockVersion';
4
4
  import type { UniBlockProps } from '../../model/JSXBlock';
5
5
  import type { Picture } from '../../model/Picture';
6
6
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
7
7
  import { ButtonSection } from '../../ui-kit/Button/ButtonSection';
8
- import { Img } from '../../ui-kit/Img/Img';
9
8
  import { getTileRightPadding } from '../BaseTile/getTileRightPadding';
10
9
  import { Headline } from '../Headline/Headline';
11
- import type { ProductTileContent, TextBenefit } from './ProductTileContent';
10
+ import type { Benefit, ProductTileContent } from './ProductTileContent';
11
+ import { renderAdditionalDescription } from './renderAdditionalDescription';
12
+ import { renderBenefit } from './renderBenefit';
13
+ import { renderImage } from './renderImage';
12
14
 
13
15
  export interface ProductTileProps extends ProductTileContent, UniBlockProps {}
14
16
 
@@ -43,7 +45,7 @@ export const ProductTile = JSX<ProductTileProps>(
43
45
  {...rest}
44
46
  />
45
47
  {renderBenefits(benefits, version, image)}
46
- {additionalDescription ? renderAdditionalDescription(additionalDescription, image) : null}
48
+ {renderAdditionalDescription(additionalDescription, image)}
47
49
  {buttons?.length ? (
48
50
  <ButtonSection buttons={buttons} className="mt-5 gap-4 z-10 text-l" />
49
51
  ) : null}
@@ -53,53 +55,20 @@ export const ProductTile = JSX<ProductTileProps>(
53
55
  ),
54
56
  );
55
57
 
56
- function renderBenefits(benefits: TextBenefit[], version: BlockVersion, image?: Picture) {
58
+ function renderBenefits(benefits: Benefit[], version: BlockVersion, image?: Picture) {
59
+ if (!benefits.length) {
60
+ return null;
61
+ }
62
+
57
63
  // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
58
- const BENEFITS_WIDTH = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
64
+ const benefitsWidth = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
59
65
 
60
66
  return (
61
67
  <div
62
68
  className={`z-10 grid grid-cols-[max-content_1fr] auto-rows-auto gap-x-6 gap-y-2.5 items-baseline
63
- ${BENEFITS_WIDTH}`}
69
+ ${benefitsWidth}`}
64
70
  >
65
71
  {benefits.length ? benefits.map(renderBenefit(version)) : null}
66
72
  </div>
67
73
  );
68
74
  }
69
-
70
- const renderBenefit =
71
- (version: BlockVersion = 'primary') =>
72
- (benefit: TextBenefit, i: number) => {
73
- const { label = '', description = '' } = benefit;
74
-
75
- return [
76
- <div key={`label-${i}`} className="text-h6">
77
- {label}
78
- </div>,
79
- <div key={`desc-${i}`} className={`text-m-light ${VersionAdditionalStyleMap[version]}`}>
80
- {description}
81
- </div>,
82
- ];
83
- };
84
-
85
- function renderAdditionalDescription(additionalDescription: string, image?: Picture) {
86
- // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
87
- const DESCRIPTION_WIDTH = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
88
-
89
- return (
90
- <div className={`text-m-light mt-2.5 z-10 ${DESCRIPTION_WIDTH}`}>{additionalDescription}</div>
91
- );
92
- }
93
-
94
- function renderImage(image?: Picture, isImageOnRightSide?: boolean) {
95
- if (!image?.src) {
96
- return null;
97
- }
98
-
99
- return (
100
- <Img
101
- className={`absolute ${isImageOnRightSide ? 'right-0' : 'left-0'} bottom-0`}
102
- image={image}
103
- />
104
- );
105
- }
@@ -1 +1,14 @@
1
- {}
1
+ {
2
+ "content": {
3
+ "benefits": {
4
+ "items": {
5
+ "md": {
6
+ "ui:widget": "html"
7
+ },
8
+ "type": {
9
+ "ui:widget": "hidden"
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
@@ -2,8 +2,32 @@ import type { BlockVersion } from '../../model/BlockVersion';
2
2
  import type { DescriptionProps, HeadlineProps, LabelProps } from '../../model/HeadlineType';
3
3
  import type { Picture } from '../../model/Picture';
4
4
  import type { ButtonContent } from '../../ui-kit/Button/ButtonProps';
5
+ import type { MarkdownTextProps } from '../../ui-kit/MarkdownText/MarkdownTextProps';
5
6
 
6
- export type TextBenefit = DescriptionProps & LabelProps;
7
+ /**
8
+ * @title Стандартный
9
+ */
10
+ type TextBenefit = DescriptionProps &
11
+ LabelProps & {
12
+ /** @default default */
13
+ type: 'default';
14
+ };
15
+
16
+ /**
17
+ * @title Форматированный текст
18
+ */
19
+ type MarkdownTextContent = MarkdownTextProps & {
20
+ /** @default md */
21
+ type: 'md';
22
+ };
23
+
24
+ /**
25
+ * @title Преимущество
26
+ * @default{
27
+ * "type": "default"
28
+ * }
29
+ */
30
+ export type Benefit = TextBenefit | MarkdownTextContent;
7
31
 
8
32
  /**
9
33
  * @title Продуктовая плитка
@@ -30,7 +54,7 @@ export type ProductTileContent = HeadlineProps &
30
54
  * @title Преимущества
31
55
  * @maxItems 7
32
56
  */
33
- benefits?: TextBenefit[];
57
+ benefits?: Benefit[];
34
58
  /** @title Дополнительное описание */
35
59
  additionalDescription?: string;
36
60
  /** @title Картинка справа/текст слева */
@@ -0,0 +1,30 @@
1
+ import type { BlockVersion } from '../../model/BlockVersion';
2
+ import type { Picture } from '../../model/Picture';
3
+ import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
4
+ import type { TextColor } from '../../ui-kit/Text/TextProps';
5
+
6
+ const DESCRIPTION_STYLE_MAP: Record<BlockVersion, TextColor> = {
7
+ primary: 'text-secondary-text',
8
+ secondary: 'text-white',
9
+ };
10
+
11
+ export function renderAdditionalDescription(
12
+ additionalDescription?: string,
13
+ image?: Picture,
14
+ version: BlockVersion = 'primary',
15
+ ) {
16
+ if (!additionalDescription) {
17
+ return null;
18
+ }
19
+
20
+ // picture width = 242px. Text can overlay picture 20px deep. Outer paddings_x = 36px. 242-36-20 = 186px
21
+ const descriptionWidth = image?.src ? 'max-w-[calc(100%-186px)]' : '100%';
22
+
23
+ return (
24
+ <div className={`mt-2.5 z-10 ${descriptionWidth}`}>
25
+ <Paragraph size="text-m" font="font-light" color={DESCRIPTION_STYLE_MAP[version]}>
26
+ {additionalDescription}
27
+ </Paragraph>
28
+ </div>
29
+ );
30
+ }