@redneckz/wildless-cms-uni-blocks 0.3.30 → 0.3.31

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 (135) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +15 -26
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/dist/components/Accordion/Accordion.js +2 -6
  5. package/dist/components/Accordion/Accordion.js.map +1 -1
  6. package/dist/components/Accordion/AccordionContent.d.ts +3 -3
  7. package/dist/components/Accordion/AccordionItem.js +4 -11
  8. package/dist/components/Accordion/AccordionItem.js.map +1 -1
  9. package/dist/components/Accordion/AccordionItem.mobile.js +6 -3
  10. package/dist/components/Accordion/AccordionItem.mobile.js.map +1 -1
  11. package/dist/components/Accordion/AccordionItemInner.js +2 -2
  12. package/dist/components/Accordion/AccordionItemInner.js.map +1 -1
  13. package/dist/components/Accordion/AccordionItemInner.mobile.js +2 -3
  14. package/dist/components/Accordion/AccordionItemInner.mobile.js.map +1 -1
  15. package/dist/components/Footer/MediaButton.js +1 -1
  16. package/dist/components/Footer/MediaButton.js.map +1 -1
  17. package/dist/components/Header/Header.js +1 -1
  18. package/dist/components/Header/Header.js.map +1 -1
  19. package/dist/components/OtherProducts/OtherProductsContent.d.ts +3 -12
  20. package/dist/components/TextBlock/TextBlockContent.d.ts +1 -1
  21. package/dist/ui-kit/BlocksList/EmbeddableBlocks.mobile.d.ts +8 -0
  22. package/dist/ui-kit/BlocksList/EmbeddableBlocks.mobile.js +17 -0
  23. package/dist/ui-kit/BlocksList/EmbeddableBlocks.mobile.js.map +1 -0
  24. package/dist/ui-kit/BlocksList/renderBlocksList.d.ts +2 -4
  25. package/dist/ui-kit/BlocksList/renderBlocksList.js +3 -3
  26. package/dist/ui-kit/BlocksList/renderBlocksList.js.map +1 -1
  27. package/dist/ui-kit/SwipeListControl/SwipeListControlDots.js +1 -1
  28. package/dist/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
  29. package/dist/ui-kit/SwipeListControl/utils/getScrollPoints.js +7 -1
  30. package/dist/ui-kit/SwipeListControl/utils/getScrollPoints.js.map +1 -1
  31. package/lib/common.css +1 -1
  32. package/lib/components/Accordion/Accordion.js +2 -6
  33. package/lib/components/Accordion/Accordion.js.map +1 -1
  34. package/lib/components/Accordion/AccordionContent.d.ts +3 -3
  35. package/lib/components/Accordion/AccordionItem.js +4 -11
  36. package/lib/components/Accordion/AccordionItem.js.map +1 -1
  37. package/lib/components/Accordion/AccordionItem.mobile.js +6 -3
  38. package/lib/components/Accordion/AccordionItem.mobile.js.map +1 -1
  39. package/lib/components/Accordion/AccordionItemInner.js +2 -2
  40. package/lib/components/Accordion/AccordionItemInner.js.map +1 -1
  41. package/lib/components/Accordion/AccordionItemInner.mobile.js +2 -3
  42. package/lib/components/Accordion/AccordionItemInner.mobile.js.map +1 -1
  43. package/lib/components/Footer/MediaButton.js +1 -1
  44. package/lib/components/Footer/MediaButton.js.map +1 -1
  45. package/lib/components/Header/Header.js +1 -1
  46. package/lib/components/Header/Header.js.map +1 -1
  47. package/lib/components/OtherProducts/OtherProductsContent.d.ts +3 -12
  48. package/lib/components/TextBlock/TextBlockContent.d.ts +1 -1
  49. package/lib/ui-kit/BlocksList/EmbeddableBlocks.mobile.d.ts +8 -0
  50. package/lib/ui-kit/BlocksList/EmbeddableBlocks.mobile.js +15 -0
  51. package/lib/ui-kit/BlocksList/EmbeddableBlocks.mobile.js.map +1 -0
  52. package/lib/ui-kit/BlocksList/renderBlocksList.d.ts +2 -4
  53. package/lib/ui-kit/BlocksList/renderBlocksList.js +3 -3
  54. package/lib/ui-kit/BlocksList/renderBlocksList.js.map +1 -1
  55. package/lib/ui-kit/SwipeListControl/SwipeListControl.fixture.mobile.d.ts +3 -0
  56. package/lib/ui-kit/SwipeListControl/SwipeListControlDots.js +1 -1
  57. package/lib/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
  58. package/lib/ui-kit/SwipeListControl/utils/getScrollPoints.d.ts +4 -1
  59. package/lib/ui-kit/SwipeListControl/utils/getScrollPoints.js +7 -1
  60. package/lib/ui-kit/SwipeListControl/utils/getScrollPoints.js.map +1 -1
  61. package/mobile/bundle/bundle.umd.js +76 -184
  62. package/mobile/bundle/bundle.umd.min.js +1 -1
  63. package/mobile/dist/components/Accordion/AccordionContent.d.ts +3 -3
  64. package/mobile/dist/components/Accordion/AccordionItem.js +6 -3
  65. package/mobile/dist/components/Accordion/AccordionItem.js.map +1 -1
  66. package/mobile/dist/components/Accordion/AccordionItemInner.js +2 -3
  67. package/mobile/dist/components/Accordion/AccordionItemInner.js.map +1 -1
  68. package/mobile/dist/components/Footer/MediaButton.js +1 -1
  69. package/mobile/dist/components/Footer/MediaButton.js.map +1 -1
  70. package/mobile/dist/components/OtherProducts/OtherProductsContent.d.ts +3 -12
  71. package/mobile/dist/components/TextBlock/TextBlockContent.d.ts +1 -1
  72. package/mobile/dist/ui-kit/BlocksList/EmbeddableBlocks.d.ts +0 -4
  73. package/mobile/dist/ui-kit/BlocksList/EmbeddableBlocks.js +0 -8
  74. package/mobile/dist/ui-kit/BlocksList/EmbeddableBlocks.js.map +1 -1
  75. package/mobile/dist/ui-kit/BlocksList/renderBlocksList.d.ts +2 -4
  76. package/mobile/dist/ui-kit/BlocksList/renderBlocksList.js +3 -3
  77. package/mobile/dist/ui-kit/BlocksList/renderBlocksList.js.map +1 -1
  78. package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlDots.js +1 -1
  79. package/mobile/dist/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
  80. package/mobile/dist/ui-kit/SwipeListControl/utils/getScrollPoints.js +7 -1
  81. package/mobile/dist/ui-kit/SwipeListControl/utils/getScrollPoints.js.map +1 -1
  82. package/mobile/lib/components/Accordion/AccordionContent.d.ts +3 -3
  83. package/mobile/lib/components/Accordion/AccordionItem.js +6 -3
  84. package/mobile/lib/components/Accordion/AccordionItem.js.map +1 -1
  85. package/mobile/lib/components/Accordion/AccordionItemInner.js +2 -3
  86. package/mobile/lib/components/Accordion/AccordionItemInner.js.map +1 -1
  87. package/mobile/lib/components/Footer/MediaButton.js +1 -1
  88. package/mobile/lib/components/Footer/MediaButton.js.map +1 -1
  89. package/mobile/lib/components/OtherProducts/OtherProductsContent.d.ts +3 -12
  90. package/mobile/lib/components/TextBlock/TextBlockContent.d.ts +1 -1
  91. package/mobile/lib/ui-kit/BlocksList/EmbeddableBlocks.d.ts +0 -4
  92. package/mobile/lib/ui-kit/BlocksList/EmbeddableBlocks.js +0 -8
  93. package/mobile/lib/ui-kit/BlocksList/EmbeddableBlocks.js.map +1 -1
  94. package/mobile/lib/ui-kit/BlocksList/renderBlocksList.d.ts +2 -4
  95. package/mobile/lib/ui-kit/BlocksList/renderBlocksList.js +3 -3
  96. package/mobile/lib/ui-kit/BlocksList/renderBlocksList.js.map +1 -1
  97. package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlDots.js +1 -1
  98. package/mobile/lib/ui-kit/SwipeListControl/SwipeListControlDots.js.map +1 -1
  99. package/mobile/lib/ui-kit/SwipeListControl/utils/getScrollPoints.js +7 -1
  100. package/mobile/lib/ui-kit/SwipeListControl/utils/getScrollPoints.js.map +1 -1
  101. package/mobile/src/components/Accordion/Accordion.example.json +3 -0
  102. package/mobile/src/components/Accordion/AccordionContent.ts +4 -5
  103. package/mobile/src/components/Accordion/AccordionItem.tsx +32 -27
  104. package/mobile/src/components/Accordion/AccordionItemInner.tsx +8 -11
  105. package/mobile/src/components/Footer/MediaButton.tsx +1 -1
  106. package/mobile/src/components/Header/Header.example.json +3 -0
  107. package/mobile/src/components/OtherProducts/OtherProductsContent.ts +3 -12
  108. package/mobile/src/components/TextBlock/TextBlockContent.ts +1 -1
  109. package/mobile/src/ui-kit/BlocksList/EmbeddableBlocks.tsx +0 -8
  110. package/mobile/src/ui-kit/BlocksList/renderBlocksList.tsx +4 -12
  111. package/mobile/src/ui-kit/SwipeListControl/SwipeListControlDots.tsx +1 -1
  112. package/mobile/src/ui-kit/SwipeListControl/utils/getScrollPoints.spec.ts +18 -0
  113. package/mobile/src/ui-kit/SwipeListControl/utils/getScrollPoints.ts +10 -2
  114. package/package.json +1 -1
  115. package/src/components/Accordion/Accordion.example.json +3 -0
  116. package/src/components/Accordion/Accordion.fixture.mobile.tsx +1 -0
  117. package/src/components/Accordion/Accordion.fixture.tsx +2 -0
  118. package/src/components/Accordion/Accordion.tsx +4 -17
  119. package/src/components/Accordion/AccordionContent.ts +4 -5
  120. package/src/components/Accordion/AccordionItem.mobile.tsx +32 -27
  121. package/src/components/Accordion/AccordionItem.tsx +23 -49
  122. package/src/components/Accordion/AccordionItemInner.mobile.tsx +8 -11
  123. package/src/components/Accordion/AccordionItemInner.tsx +8 -10
  124. package/src/components/Footer/MediaButton.tsx +1 -1
  125. package/src/components/Header/Header.example.json +3 -0
  126. package/src/components/Header/Header.tsx +8 -1
  127. package/src/components/OtherProducts/OtherProducts.fixture.tsx +61 -6
  128. package/src/components/OtherProducts/OtherProductsContent.ts +3 -12
  129. package/src/components/TextBlock/TextBlockContent.ts +1 -1
  130. package/src/ui-kit/BlocksList/EmbeddableBlocks.mobile.tsx +15 -0
  131. package/src/ui-kit/BlocksList/renderBlocksList.tsx +4 -12
  132. package/src/ui-kit/SwipeListControl/SwipeListControl.fixture.mobile.tsx +24 -6
  133. package/src/ui-kit/SwipeListControl/SwipeListControlDots.tsx +1 -1
  134. package/src/ui-kit/SwipeListControl/utils/getScrollPoints.spec.ts +18 -0
  135. package/src/ui-kit/SwipeListControl/utils/getScrollPoints.ts +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.3.30",
3
+ "version": "0.3.31",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -3,6 +3,7 @@
3
3
  "accordionItems": [
4
4
  {
5
5
  "label": "Аккордеон 1",
6
+ "labelIcon": "CardIcon",
6
7
  "blocks": [
7
8
  {
8
9
  "blockListType": "TextBlock",
@@ -18,6 +19,7 @@
18
19
  },
19
20
  {
20
21
  "label": "Аккордеон 2",
22
+ "labelIcon": "CardIcon",
21
23
  "blocks": [
22
24
  {
23
25
  "blockListType": "TextBlock",
@@ -33,6 +35,7 @@
33
35
  },
34
36
  {
35
37
  "label": "Аккордеон 3",
38
+ "labelIcon": "CardIcon",
36
39
  "blocks": [
37
40
  {
38
41
  "blockListType": "TextBlock",
@@ -45,6 +45,7 @@ const propsTextBlock: AccordionProps = {
45
45
  },
46
46
  {
47
47
  label: 'Accordion label 2',
48
+ labelIcon: 'CardIcon',
48
49
  blocks: [PICTURE_TEXT_ACCORDION_BLOCK],
49
50
  },
50
51
  {
@@ -63,6 +63,8 @@ const MINI_GALLERY_ACCORDION_BLOCK: MiniGalleryBlockListDef = {
63
63
 
64
64
  const propsBlock: AccordionProps = {
65
65
  context,
66
+ title: 'Accordion title',
67
+ description: 'Accordion description',
66
68
  accordionItems: [
67
69
  {
68
70
  label: 'Accordion label 1',
@@ -1,5 +1,4 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { BlockVersion } from '../../model/BlockVersion';
3
2
  import type { UniBlockProps } from '../../types';
4
3
  import { Heading } from '../../ui-kit/Heading/Heading';
5
4
  import type { AccordionContent } from './AccordionContent';
@@ -7,28 +6,16 @@ import { AccordionItem } from './AccordionItem';
7
6
 
8
7
  export interface AccordionProps extends AccordionContent, UniBlockProps {}
9
8
 
10
- const accordionStyleMap: Record<BlockVersion, string> = {
11
- primary: 'bg-white text-primary-text',
12
- secondary: 'bg-primary-main text-white',
13
- };
14
-
15
9
  export const Accordion = JSX<AccordionProps>(
16
- ({ title, accordionItems, context, className = '', version = 'primary', anchor = null }) => {
10
+ ({ title, description, accordionItems, context, className = '', anchor = null }) => {
17
11
  return (
18
- <section
19
- className={`p-[50px] font-sans ${className} ${accordionStyleMap[version]}`}
20
- id={anchor}
21
- >
12
+ <section className={`p-[50px] font-sans bg-white text-primary-text ${className}`} id={anchor}>
22
13
  {title ? <Heading headingType="h4" className="mb-2.5" title={title} /> : null}
14
+ {description ? <div className="mb-2.5 text-base">{description}</div> : null}
23
15
  {accordionItems?.length ? (
24
16
  <ul className="list-none m-0 p-0">
25
17
  {accordionItems.map((item, i) => (
26
- <AccordionItem
27
- key={`AccordionItem${i}`}
28
- {...item}
29
- version={version}
30
- context={context}
31
- />
18
+ <AccordionItem key={`AccordionItem${i}`} {...item} context={context} />
32
19
  ))}
33
20
  </ul>
34
21
  ) : null}
@@ -1,5 +1,6 @@
1
- import type { BlockDef, ColumnsCount } from '../../ui-kit/BlocksList/BlocksListProps';
1
+ import type { BlockDef } from '../../ui-kit/BlocksList/BlocksListProps';
2
2
  import type { BlockVersion } from '../../model/BlockVersion';
3
+ import type { IconName } from '../../icons/IconName';
3
4
  /**
4
5
  * @title Элемент списка
5
6
  */
@@ -20,9 +21,7 @@ export interface AccordionItemCommonProps {
20
21
  * @default false
21
22
  */
22
23
  bordered?: boolean; // TODO: только для мобильной версии
23
- version?: BlockVersion;
24
-
25
- columns?: ColumnsCount;
24
+ labelIcon?: IconName; // TODO: только для мобильной версии
26
25
  }
27
26
 
28
27
  /**
@@ -35,7 +34,7 @@ export interface AccordionContent {
35
34
  /** @title Список */
36
35
  accordionItems?: AccordionItemCommonProps[];
37
36
  /** @title Описание */
38
- description?: string; // TODO: только для мобильной версии
37
+ description?: string;
39
38
  /**
40
39
  * @title Отображать/скрывать обводку у элемента списка
41
40
  * @default false
@@ -7,34 +7,39 @@ import { useActiveHandler } from './useActiveHandler';
7
7
 
8
8
  export interface AccordionItemProps extends AccordionItemCommonProps, UniBlockProps {}
9
9
 
10
- export const AccordionItem = JSX<AccordionItemProps>(({ label, blocks, bordered, context }) => {
11
- const { hasContent, icon, handleToggle } = useActiveHandler({
12
- context,
13
- blocks,
14
- });
10
+ export const AccordionItem = JSX<AccordionItemProps>(
11
+ ({ label, labelIcon, blocks, bordered, context }) => {
12
+ const { hasContent, icon, handleToggle } = useActiveHandler({
13
+ context,
14
+ blocks,
15
+ });
15
16
 
16
- return (
17
- <li
18
- className={`${
19
- bordered ? 'border p-4 rounded mb-4' : 'border-0 border-b last:border-b-0'
20
- } border-solid border-main-divider`}
21
- >
22
- <button
23
- className={`border-none bg-transparent flex justify-between text-left w-full font-sans text-primary-text
17
+ return (
18
+ <li className={`${borderedLiClass(bordered)} border-solid border-main-divider`}>
19
+ <button
20
+ className={`border-none bg-transparent flex justify-between text-left w-full font-sans text-primary-text
24
21
  ${bordered ? '' : 'py-[14px] px-0'}
25
22
  ${hasContent ? 'group cursor-pointer' : ''}`}
26
- onClick={handleToggle}
27
- >
28
- <span
29
- className={`text-m-title-xs pr-2.5 font-medium ${
30
- hasContent ? 'group-hover:text-primary-main' : ''
31
- }`}
23
+ onClick={handleToggle}
32
24
  >
33
- {label}
34
- </span>
35
- {hasContent ? <Icon name={icon} width="24" height="24" asSVG /> : null}
36
- </button>
37
- {hasContent ? <AccordionItemInner blocks={blocks} context={context} /> : null}
38
- </li>
39
- );
40
- });
25
+ <span
26
+ className={`text-m-title-xs pr-2.5 font-medium flex ${
27
+ hasContent ? 'group-hover:text-primary-main' : ''
28
+ }`}
29
+ >
30
+ {labelIcon ? (
31
+ <Icon name={labelIcon} width="24" height="24" asSVG className="mr-3" />
32
+ ) : null}
33
+ {label}
34
+ </span>
35
+ {hasContent ? <Icon name={icon} width="24" height="24" asSVG /> : null}
36
+ </button>
37
+ {hasContent ? <AccordionItemInner blocks={blocks} context={context} /> : null}
38
+ </li>
39
+ );
40
+ },
41
+ );
42
+
43
+ function borderedLiClass(bordered) {
44
+ return bordered ? 'border p-4 rounded mb-4' : 'border-0 border-b last:border-b-0';
45
+ }
@@ -1,5 +1,4 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { BlockVersion } from '../../model/BlockVersion';
3
2
  import type { UniBlockProps } from '../../types';
4
3
  import { Icon } from '../../ui-kit/Icon/Icon';
5
4
  import type { AccordionItemCommonProps } from './AccordionContent';
@@ -8,52 +7,27 @@ import { useActiveHandler } from './useActiveHandler';
8
7
 
9
8
  export interface AccordionItemProps extends AccordionItemCommonProps, UniBlockProps {}
10
9
 
11
- const buttonStyleMap: Record<BlockVersion, string> = {
12
- primary: 'text-primary-text',
13
- secondary: 'text-white',
14
- };
10
+ export const AccordionItem = JSX<AccordionItemProps>(({ label, isExpanded, blocks, context }) => {
11
+ const { isActive, hasContent, icon, handleToggle } = useActiveHandler({
12
+ context,
13
+ blocks,
14
+ initialState: isExpanded,
15
+ });
15
16
 
16
- const buttonHoverStyleMap: Record<BlockVersion, string> = {
17
- primary: 'group-hover:text-primary-main',
18
- secondary: 'group-hover:text-white',
19
- };
20
-
21
- export const AccordionItem = JSX<AccordionItemProps>(
22
- ({ label, isExpanded, blocks, columns, context, version = 'primary' }) => {
23
- const { isActive, hasContent, icon, handleToggle } = useActiveHandler({
24
- context,
25
- blocks,
26
- initialState: isExpanded,
27
- });
28
-
29
- return (
30
- <li className="border-0 border-b border-solid border-main-divider last:border-b-0">
31
- <button
32
- className={`border-none bg-transparent px-0 py-5 flex justify-between text-left w-full font-sans ${
33
- buttonStyleMap[version]
34
- }
35
- ${hasContent ? 'group cursor-pointer' : ''}`}
36
- onClick={handleToggle}
37
- >
38
- <span
39
- className={`text-xl pr-2.5 font-medium ${
40
- hasContent ? buttonHoverStyleMap[version] : ''
41
- }`}
42
- >
43
- {label}
44
- </span>
45
- {hasContent ? <Icon name={icon} width="24" height="24" asSVG /> : null}
46
- </button>
47
- {hasContent ? (
48
- <AccordionItemInner
49
- isExpanded={isActive}
50
- columns={columns}
51
- blocks={blocks}
52
- version={version}
53
- context={context}
54
- />
55
- ) : null}
56
- </li>
57
- );
58
- },
59
- );
17
+ return (
18
+ <li className="border-0 border-b border-solid border-main-divider last:border-b-0">
19
+ <button
20
+ className={`border-none bg-transparent px-0 py-5 flex justify-between text-left w-full font-sans
21
+ ${hasContent ? 'group cursor-pointer' : ''}
22
+ `}
23
+ onClick={handleToggle}
24
+ >
25
+ <span className={`text-xl pr-2.5 font-medium`}>{label}</span>
26
+ {hasContent ? <Icon name={icon} width="24" height="24" asSVG /> : null}
27
+ </button>
28
+ {hasContent ? (
29
+ <AccordionItemInner isExpanded={isActive} blocks={blocks} context={context} />
30
+ ) : null}
31
+ </li>
32
+ );
33
+ });
@@ -2,14 +2,11 @@ import { JSX } from '@redneckz/uni-jsx';
2
2
  import type { AccordionItemProps } from './AccordionItem';
3
3
  import { renderBlocksList } from '../../ui-kit/BlocksList/renderBlocksList';
4
4
 
5
- export const AccordionItemInner = JSX<AccordionItemProps>(
6
- ({ blocks, context, version = 'primary' }) => {
7
- const className = 'mb-5 last:mb-0 first:mt-2';
8
- const columns = 1;
9
- return (
10
- <div className="transition-all duration-300 max-h-0 overflow-hidden group-last:last:pb-0">
11
- {renderBlocksList({ context, className, columns, blocks, version })}
12
- </div>
13
- );
14
- },
15
- );
5
+ export const AccordionItemInner = JSX<AccordionItemProps>(({ blocks, context }) => {
6
+ const className = 'mb-5 last:mb-0 first:mt-2';
7
+ return (
8
+ <div className="transition-all duration-300 max-h-0 overflow-hidden group-last:last:pb-0">
9
+ {renderBlocksList({ context, className, blocks })}
10
+ </div>
11
+ );
12
+ });
@@ -2,13 +2,11 @@ import { JSX } from '@redneckz/uni-jsx';
2
2
  import type { AccordionItemProps } from './AccordionItem';
3
3
  import { renderBlocksList } from '../../ui-kit/BlocksList/renderBlocksList';
4
4
 
5
- export const AccordionItemInner = JSX<AccordionItemProps>(
6
- ({ blocks, columns = 1, context, version = 'primary' }) => {
7
- const className = 'mb-5 last:mb-0 pb-5';
8
- return (
9
- <div className="transition-all duration-300 max-h-0 overflow-hidden">
10
- {renderBlocksList({ context, className, columns, blocks, version })}
11
- </div>
12
- );
13
- },
14
- );
5
+ export const AccordionItemInner = JSX<AccordionItemProps>(({ blocks, context }) => {
6
+ const className = 'mb-5 last:mb-0 pb-5';
7
+ return (
8
+ <div className="transition-all duration-300 max-h-0 overflow-hidden">
9
+ {renderBlocksList({ context, className, blocks })}
10
+ </div>
11
+ );
12
+ });
@@ -32,7 +32,7 @@ export const MediaButton = JSX<MediaButtonProps>(({ href }) => {
32
32
 
33
33
  return (
34
34
  <a
35
- className="flex items-center justify-center border border-solid border-main-divider rounded-full no-underline outline-none w-[38px] h-[38px] hover:text-primary-main"
35
+ className="flex items-center justify-center border border-solid border-main-divider rounded-full no-underline outline-none w-[40px] h-[40px] box-border hover:text-primary-main"
36
36
  href={href}
37
37
  aria-label={label}
38
38
  target="_blank"
@@ -0,0 +1,3 @@
1
+ {
2
+ "defaultLocation": "Москва"
3
+ }
@@ -20,7 +20,14 @@ const BORDER_COLORS: Record<BgColorVersion, string> = {
20
20
  export interface HeaderProps extends HeaderContent, UniBlockProps {}
21
21
 
22
22
  export const Header = JSX<HeaderProps>(
23
- ({ className, defaultLocation, bgColor = 'bg-white', context, topItems, anchor = null }) => {
23
+ ({
24
+ className,
25
+ defaultLocation = 'Москва',
26
+ bgColor = 'bg-white',
27
+ context,
28
+ topItems,
29
+ anchor = null,
30
+ }) => {
24
31
  const router = context.useRouter();
25
32
  const sitemap = useSitemap(context.useAsyncData);
26
33
  const { handlerDecorator } = context;
@@ -3,13 +3,24 @@ import { PRODUCT_BLOCK } from '../ProductBlock/ProductBlock.fixture';
3
3
  import { PRODUCT_TILE, PRODUCT_PENSION_TILE } from '../ProductTile/ProductTile.fixture';
4
4
  import { TEXT_BLOCK } from '../TextBlock/TextBlock.fixture';
5
5
  import { TILE, TILE_PREMIUM } from '../Tile/Tile.fixture';
6
- import type { OtherProductsProps } from './OtherProducts';
6
+ import { HEADLINE } from '../Headline/Headline.fixture';
7
+ import { PICTURE_TEXT } from '../PictureText/PictureText.fixture';
8
+ import { linkDocsContentExample } from '../LinkDocs/linkDocsContentExample';
9
+ import { defaultProps as GALLERY } from '../Gallery/Gallery.fixture';
10
+ import { defaultProps as MINI_GALLERY } from '../MiniGallery/MiniGallery.fixture';
7
11
  import { OtherProducts } from './OtherProducts';
12
+ import type { OtherProductsProps } from './OtherProducts';
13
+
8
14
  import type {
9
15
  ProductBlockBlockListDef,
10
16
  ProductTileBlockListDef,
11
17
  TextBlockBlockListDef,
12
18
  TileBlockListDef,
19
+ GalleryBlockListDef,
20
+ HeadlineBlockListDef,
21
+ LinkDocsBlockListDef,
22
+ MiniGalleryBlockListDef,
23
+ PictureTextBlockListDef,
13
24
  } from '../../ui-kit/BlocksList/BlocksListProps';
14
25
 
15
26
  const TEXT_BLOCK_OTHER_BLOCK: TextBlockBlockListDef = {
@@ -42,11 +53,36 @@ const PRODUCT_PENSION_TILES__OTHER_BLOCK: ProductTileBlockListDef = {
42
53
  ...PRODUCT_PENSION_TILE,
43
54
  };
44
55
 
56
+ const HEADLINE_OTHER_BLOCK: HeadlineBlockListDef = {
57
+ blockListType: 'Headline',
58
+ ...HEADLINE,
59
+ };
60
+
61
+ const PICTURE_TEXT_OTHER_BLOCK: PictureTextBlockListDef = {
62
+ blockListType: 'PictureText',
63
+ ...PICTURE_TEXT,
64
+ };
65
+
66
+ const LINK_DOCS_OTHER_BLOCK: LinkDocsBlockListDef = {
67
+ blockListType: 'LinkDocs',
68
+ ...linkDocsContentExample,
69
+ };
70
+
71
+ const GALLERY_OTHER_BLOCK: GalleryBlockListDef = {
72
+ blockListType: 'Gallery',
73
+ ...GALLERY,
74
+ };
75
+
76
+ const MINI_GALLERY_OTHER_BLOCK: MiniGalleryBlockListDef = {
77
+ blockListType: 'MiniGallery',
78
+ ...MINI_GALLERY,
79
+ };
80
+
45
81
  const propsBlock: OtherProductsProps = {
46
82
  context,
47
83
  blockItems: [
48
84
  {
49
- label: 'Другие кредитные карты Россельхозбанка 1',
85
+ label: 'OtherProducts №1 Tiles',
50
86
  blocks: [
51
87
  TILES_PREMIUM_OTHER_BLOCK,
52
88
  TILES_PREMIUM_OTHER_BLOCK,
@@ -55,7 +91,7 @@ const propsBlock: OtherProductsProps = {
55
91
  ],
56
92
  },
57
93
  {
58
- label: 'Другие кредитные карты Россельхозбанка 2',
94
+ label: 'OtherProducts №2 Product_Tiles',
59
95
  blocks: [
60
96
  PRODUCT_TILES_OTHER_BLOCK,
61
97
  PRODUCT_TILES_OTHER_BLOCK,
@@ -64,12 +100,11 @@ const propsBlock: OtherProductsProps = {
64
100
  ],
65
101
  },
66
102
  {
67
- label: 'Другие кредитные карты Россельхозбанка 3',
103
+ label: 'OtherProducts №3 Product_Block',
68
104
  blocks: [PRODUCT_BLOCK_OTHER_BLOCK, PRODUCT_BLOCK_OTHER_BLOCK],
69
105
  },
70
-
71
106
  {
72
- label: 'Другие кредитные карты Россельхозбанка 4',
107
+ label: 'OtherProducts №4 Text_Block',
73
108
  blocks: [
74
109
  TEXT_BLOCK_OTHER_BLOCK,
75
110
  TEXT_BLOCK_OTHER_BLOCK,
@@ -77,6 +112,26 @@ const propsBlock: OtherProductsProps = {
77
112
  TEXT_BLOCK_OTHER_BLOCK,
78
113
  ],
79
114
  },
115
+ {
116
+ label: 'OtherProducts №5 Picture_Text',
117
+ blocks: [PICTURE_TEXT_OTHER_BLOCK],
118
+ },
119
+ {
120
+ label: 'OtherProducts №6 Headline',
121
+ blocks: [HEADLINE_OTHER_BLOCK],
122
+ },
123
+ {
124
+ label: 'OtherProducts №7 Link_Docs',
125
+ blocks: [LINK_DOCS_OTHER_BLOCK],
126
+ },
127
+ {
128
+ label: 'OtherProducts №8 Gallery',
129
+ blocks: [GALLERY_OTHER_BLOCK],
130
+ },
131
+ {
132
+ label: 'OtherProducts №9 Mini_Gallery',
133
+ blocks: [MINI_GALLERY_OTHER_BLOCK],
134
+ },
80
135
  ],
81
136
  };
82
137
 
@@ -15,11 +15,6 @@ export interface blockItemCommonProps {
15
15
  isExpanded?: boolean;
16
16
  /** @title Блоки */
17
17
  blocks?: BlockDef[];
18
- /**
19
- * @title Отображать/скрывать обводку элемента
20
- * @default false
21
- */
22
- bordered?: boolean; // TODO: только для мобильной версии
23
18
  columns?: ColumnsCount;
24
19
  }
25
20
 
@@ -29,13 +24,9 @@ export interface blockItemCommonProps {
29
24
  export interface OtherProductsContent {
30
25
  /** @title Заголовок */
31
26
  title?: string;
32
- /** @title Список */
33
- blockItems?: blockItemCommonProps[];
34
- /** @title Подзаголовок */
35
- description?: string; // TODO: только для мобильной версии
36
27
  /**
37
- * @title Отображать/скрывать обводку у элемента списка
38
- * @default false
28
+ * @title Список
29
+ * @maxItems 10
39
30
  */
40
- bordered?: boolean; // TODO: только для мобильной версии
31
+ blockItems?: blockItemCommonProps[];
41
32
  }
@@ -23,7 +23,7 @@ export interface TextBlockContent {
23
23
  iconVersion?: TextBlockIconVersion;
24
24
  image?: Picture;
25
25
  blockVersion?: TextBlockVersion;
26
- /** @title Маркеры списка (моб.) */ // TODO: mobile prop
26
+ /** @title Буллиты */ // TODO: mobile prop
27
27
  isDotted?: boolean;
28
28
  /** @title Список (моб.) */ // TODO: mobile prop
29
29
  items?: string[];
@@ -0,0 +1,15 @@
1
+ import { Headline } from '../../components/Headline/Headline';
2
+ import { LinkDocs } from '../../components/LinkDocs/LinkDocs';
3
+ import { ProductBlock } from '../../components/ProductBlock/ProductBlock';
4
+ import { TextBlock } from '../../components/TextBlock/TextBlock';
5
+ import { Gallery } from '../../components/Gallery/Gallery';
6
+ import { LinkList } from '../../components/LinkList/LinkList';
7
+
8
+ export const EmbeddableBlocks = {
9
+ Headline,
10
+ LinkDocs,
11
+ TextBlock,
12
+ ProductBlock,
13
+ Gallery,
14
+ LinkList,
15
+ };
@@ -2,27 +2,19 @@ import type { JSXBlock } from '../../components/ContentPage/ContentPage';
2
2
  import type { ContentPageContext } from '../../components/ContentPage/ContentPageContext';
3
3
  import type { BlockDef, ColumnsCount } from './BlocksListProps';
4
4
  import { EmbeddableBlocks } from './EmbeddableBlocks';
5
- import { BlockVersion } from '../../model/BlockVersion';
6
5
 
7
6
  type EmbeddableBlocksProps = {
8
7
  blocks?: BlockDef[];
9
8
  context: ContentPageContext;
10
9
  columns?: ColumnsCount;
11
10
  className?: string;
12
- version?: BlockVersion;
13
11
  };
14
12
 
15
- export const renderBlocksList = ({
16
- blocks,
17
- context,
18
- className,
19
- columns,
20
- version,
21
- }: EmbeddableBlocksProps) =>
22
- blocks?.length ? blocks.map(renderBlock({ context, className, columns, version })) : null;
13
+ export const renderBlocksList = ({ blocks, context, className, columns }: EmbeddableBlocksProps) =>
14
+ blocks?.length ? blocks.map(renderBlock({ context, className, columns })) : null;
23
15
 
24
16
  export const renderBlock =
25
- ({ context, columns, className, version }: EmbeddableBlocksProps) =>
17
+ ({ context, columns, className }: EmbeddableBlocksProps) =>
26
18
  (block: BlockDef, i: number) => {
27
19
  const type = block?.blockListType;
28
20
  if (!type || !(type in EmbeddableBlocks)) {
@@ -32,7 +24,7 @@ export const renderBlock =
32
24
  const EmbeddedBlock: JSXBlock = EmbeddableBlocks[type];
33
25
  return (
34
26
  <div className={`${className} ${columnsCountClass}`} key={`block_${i}`}>
35
- <EmbeddedBlock context={context} {...block} blockVersion={version} className="!p-0" />
27
+ <EmbeddedBlock context={context} {...block} className="!p-0" />
36
28
  </div>
37
29
  );
38
30
  };
@@ -1,16 +1,34 @@
1
1
  import { SwipeListControl } from './SwipeListControl';
2
2
  import { mobileContext } from '../../setup-fixture';
3
3
 
4
- const children = new Array(4).fill(0).map((_, i) => (
5
- <div key={String(i)} className="border border-main-stroke rounded-md text-center h-12">
6
- {`Element #${i}`}
7
- </div>
8
- ));
4
+ const generateChildren = (count: number) =>
5
+ new Array(count).fill(0).map((_, i) => (
6
+ <div key={String(i)} className="border border-main-stroke rounded-md text-center h-12">
7
+ {`Element #${i}`}
8
+ </div>
9
+ ));
9
10
 
10
11
  export default {
11
12
  default: (
12
13
  <div className="px-4 py-5 bg-white">
13
- <SwipeListControl context={mobileContext}>{children}</SwipeListControl>
14
+ <SwipeListControl context={mobileContext}>{generateChildren(5)}</SwipeListControl>
15
+ </div>
16
+ ),
17
+ 'w/o dots': (
18
+ <div className="px-4 py-5 bg-white">
19
+ <SwipeListControl context={mobileContext} showDots={false}>
20
+ {generateChildren(5)}
21
+ </SwipeListControl>
22
+ </div>
23
+ ),
24
+ '1 element': (
25
+ <div className="px-4 py-5 bg-white">
26
+ <SwipeListControl context={mobileContext}>{generateChildren(1)}</SwipeListControl>
27
+ </div>
28
+ ),
29
+ '2 elements': (
30
+ <div className="px-4 py-5 bg-white">
31
+ <SwipeListControl context={mobileContext}>{generateChildren(2)}</SwipeListControl>
14
32
  </div>
15
33
  ),
16
34
  };
@@ -22,7 +22,7 @@ export const SwipeListControlDots = JSX<SwipeListControlDotsProps>(
22
22
  const contentContainer = (e.currentTarget as HTMLElement).parentElement
23
23
  ?.previousElementSibling;
24
24
 
25
- contentContainer?.children[idx]?.scrollIntoView({ behavior: 'smooth' });
25
+ contentContainer?.children[idx]?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
26
26
  };
27
27
 
28
28
  return showDots && children?.length ? (
@@ -17,8 +17,26 @@ const scrollPoints: [number, number][] = [
17
17
  [1414, 1914],
18
18
  ];
19
19
 
20
+ const twoItemsScrollPointsProps = {
21
+ gap: 14,
22
+ padding: 16,
23
+ clientWidth: 414,
24
+ scrollWidth: 794,
25
+ childElementCount: 2,
26
+ itemWidth: 380,
27
+ };
28
+
29
+ const twoItemsScrollPoints: [number, number][] = [
30
+ [0, 380],
31
+ [380, 794],
32
+ ];
33
+
20
34
  describe('getScrollPoints', () => {
21
35
  it('should return array containing scroll breakpoints delimiting each child', () => {
22
36
  expect(getScrollPoints(props)).toEqual(scrollPoints);
23
37
  });
38
+
39
+ it('should correctly handle case with 2 items in container', () => {
40
+ expect(getScrollPoints(twoItemsScrollPointsProps)).toEqual(twoItemsScrollPoints);
41
+ });
24
42
  });
@@ -16,9 +16,17 @@ export const getScrollPoints = ({
16
16
  scrollWidth: number;
17
17
  childElementCount: number;
18
18
  itemWidth: number;
19
- }) => {
20
- const scrollItemWidth = itemWidth + gap;
19
+ }): [number, number][] => {
21
20
  const scrollableDistance = scrollWidth - clientWidth;
21
+
22
+ if (childElementCount === 2) {
23
+ return [
24
+ [0, scrollableDistance],
25
+ [scrollableDistance, scrollWidth],
26
+ ];
27
+ }
28
+
29
+ const scrollItemWidth = itemWidth + gap;
22
30
  const edgeScrollDistance = clientWidth - gap - padding;
23
31
 
24
32
  const lastScrollableIdx = childElementCount - 2;