@redneckz/wildless-cms-uni-blocks 0.2.93 → 0.2.94

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 (44) hide show
  1. package/bundle/bundle.umd.js +41 -27
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/dist/components/ContentPage/ContentPage.d.ts +9 -1
  4. package/dist/components/ContentPage/ContentPage.js +20 -17
  5. package/dist/components/ContentPage/ContentPage.js.map +1 -1
  6. package/dist/components/ContentPage/toMobilePage.js +13 -2
  7. package/dist/components/ContentPage/toMobilePage.js.map +1 -1
  8. package/dist/components/Header/Header.js +3 -3
  9. package/dist/components/Header/Header.js.map +1 -1
  10. package/dist/components/LinkDocs/LinkDocs.js +3 -3
  11. package/dist/components/LinkDocs/LinkDocs.js.map +1 -1
  12. package/dist/components/ProductBlock/ProductBlock.js +1 -1
  13. package/dist/components/ProductBlock/ProductBlock.js.map +1 -1
  14. package/dist/components/ProductBlock/ProductBlockInner.js +1 -1
  15. package/dist/components/ProductBlock/ProductBlockInner.js.map +1 -1
  16. package/dist/types.d.ts +8 -0
  17. package/lib/common.css +1 -1
  18. package/lib/components/ContentPage/ContentPage.d.ts +9 -1
  19. package/lib/components/ContentPage/ContentPage.js +20 -17
  20. package/lib/components/ContentPage/ContentPage.js.map +1 -1
  21. package/lib/components/ContentPage/toMobilePage.js +13 -2
  22. package/lib/components/ContentPage/toMobilePage.js.map +1 -1
  23. package/lib/components/Header/Header.js +3 -3
  24. package/lib/components/Header/Header.js.map +1 -1
  25. package/lib/components/LinkDocs/LinkDocs.fixture.d.ts +3 -3
  26. package/lib/components/LinkDocs/LinkDocs.js +3 -3
  27. package/lib/components/LinkDocs/LinkDocs.js.map +1 -1
  28. package/lib/components/ProductBlock/ProductBlock.js +1 -1
  29. package/lib/components/ProductBlock/ProductBlock.js.map +1 -1
  30. package/lib/components/ProductBlock/ProductBlockInner.js +1 -1
  31. package/lib/components/ProductBlock/ProductBlockInner.js.map +1 -1
  32. package/lib/types.d.ts +8 -0
  33. package/package.json +1 -1
  34. package/src/components/ContentPage/ContentPage.page.json +31 -49
  35. package/src/components/ContentPage/ContentPage.tsx +71 -36
  36. package/src/components/ContentPage/toMobilePage.ts +19 -2
  37. package/src/components/Header/Header.tsx +14 -12
  38. package/src/components/LinkDocs/LinkDocs.example.json +26 -0
  39. package/src/components/LinkDocs/LinkDocs.fixture.tsx +5 -5
  40. package/src/components/LinkDocs/LinkDocs.tsx +3 -3
  41. package/src/components/ProductBlock/ProductBlock.fixture.tsx +1 -0
  42. package/src/components/ProductBlock/ProductBlock.tsx +3 -1
  43. package/src/components/ProductBlock/ProductBlockInner.tsx +1 -1
  44. package/src/types.ts +11 -1
@@ -11,26 +11,32 @@
11
11
  "date": "2022-04-08",
12
12
  "style": ["p-20", "pt-0", "gap-5", "bg-secondary-light"],
13
13
  "likeControl": true,
14
- "blocks": [
15
- {
16
- "type": "Header",
17
- "style": ["col-span-12", "-mx-20", "mb-5", "shadow-[0_8px_32px_0px_#00000014]"],
18
- "content": {
19
- "defaultLocation": "Москва",
20
- "topItems": [
21
- {
22
- "href": "https://rshb.ru/",
23
- "text": "Бизнес клиентам",
24
- "target": "_blank"
25
- },
26
- {
27
- "href": "https://rshb.ru/",
28
- "text": "Частным клиентам",
29
- "target": "_blank"
14
+ "slots": {
15
+ "header": {
16
+ "blocks": [
17
+ {
18
+ "type": "Header",
19
+ "style": ["-mx-20", "mb-5", "shadow-[0_8px_32px_0px_#00000014]"],
20
+ "content": {
21
+ "defaultLocation": "Москва",
22
+ "topItems": [
23
+ {
24
+ "href": "https://rshb.ru/",
25
+ "text": "Бизнес клиентам",
26
+ "target": "_blank"
27
+ },
28
+ {
29
+ "href": "https://rshb.ru/",
30
+ "text": "Частным клиентам",
31
+ "target": "_blank"
32
+ }
33
+ ]
30
34
  }
31
- ]
32
- }
33
- },
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ "blocks": [
34
40
  {
35
41
  "type": "ProductGallery",
36
42
  "style": ["col-span-12"],
@@ -1523,11 +1529,7 @@
1523
1529
  {
1524
1530
  "label": "Бесплатно",
1525
1531
  "list": {
1526
- "items": [
1527
- "item 1",
1528
- "item 2",
1529
- "item 3"
1530
- ]
1532
+ "items": ["item 1", "item 2", "item 3"]
1531
1533
  }
1532
1534
  }
1533
1535
  ],
@@ -1575,11 +1577,7 @@
1575
1577
  {
1576
1578
  "list": {
1577
1579
  "isDotted": false,
1578
- "items": [
1579
- "item 1",
1580
- "item 2",
1581
- "item 3"
1582
- ]
1580
+ "items": ["item 1", "item 2", "item 3"]
1583
1581
  }
1584
1582
  }
1585
1583
  ],
@@ -1596,11 +1594,7 @@
1596
1594
  {
1597
1595
  "list": {
1598
1596
  "version": "primary",
1599
- "items": [
1600
- "item 1",
1601
- "item 2",
1602
- "item 3"
1603
- ]
1597
+ "items": ["item 1", "item 2", "item 3"]
1604
1598
  }
1605
1599
  }
1606
1600
  ],
@@ -1716,11 +1710,7 @@
1716
1710
  {
1717
1711
  "label": "Бесплатно",
1718
1712
  "list": {
1719
- "items": [
1720
- "item 1",
1721
- "item 2",
1722
- "item 3"
1723
- ]
1713
+ "items": ["item 1", "item 2", "item 3"]
1724
1714
  }
1725
1715
  }
1726
1716
  ],
@@ -1768,11 +1758,7 @@
1768
1758
  {
1769
1759
  "list": {
1770
1760
  "isDotted": false,
1771
- "items": [
1772
- "item 1",
1773
- "item 2",
1774
- "item 3"
1775
- ]
1761
+ "items": ["item 1", "item 2", "item 3"]
1776
1762
  }
1777
1763
  }
1778
1764
  ],
@@ -1789,11 +1775,7 @@
1789
1775
  {
1790
1776
  "list": {
1791
1777
  "version": "primary",
1792
- "items": [
1793
- "item 1",
1794
- "item 2",
1795
- "item 3"
1796
- ]
1778
+ "items": ["item 1", "item 2", "item 3"]
1797
1779
  }
1798
1780
  }
1799
1781
  ],
@@ -3,6 +3,7 @@ import type { BlockDef, ContentPageDef, UniBlockProps } from '../../types';
3
3
  import type { BlockContent } from '../BlockContent';
4
4
  import { LikeControl } from '../LikeControl/LikeControl';
5
5
  import { Placeholder } from '../Placeholder/Placeholder';
6
+ import { ContentPageContext } from './ContentPageContext';
6
7
 
7
8
  interface BlockDecoratorProps<VNode> {
8
9
  blockClassName: string;
@@ -20,12 +21,21 @@ export type JSXBlock = (
20
21
  context?: any,
21
22
  ) => any;
22
23
 
24
+ export type BlocksRegistry = Record<string, JSXBlock>;
25
+
23
26
  export interface ContentPageProps extends UniBlockProps {
24
- blocksRegistry: Record<string, JSXBlock>;
27
+ blocksRegistry: BlocksRegistry;
25
28
  data: ContentPageDef;
26
29
  blockDecorator?: BlockDecorator;
27
30
  }
28
31
 
32
+ export interface RenderBlockFunc {
33
+ block: BlockDef;
34
+ blockDecorator: BlockDecorator;
35
+ blocksRegistry: BlocksRegistry;
36
+ context: ContentPageContext;
37
+ }
38
+
29
39
  const defaultBlockDecorator: BlockDecorator = ({ blockClassName, block, render }) =>
30
40
  render({ blockClassName, block });
31
41
 
@@ -34,14 +44,32 @@ export const ContentPage = JSX<ContentPageProps>(
34
44
  className,
35
45
  context,
36
46
  blocksRegistry,
37
- data: { style: pageStyle, blocks, likeControl, colorPalette = 'pc' },
47
+ data: { style: pageStyle, blocks, slots = {}, likeControl, colorPalette = 'pc' },
38
48
  blockDecorator = defaultBlockDecorator,
39
49
  }) => {
50
+ const { header } = slots;
51
+
40
52
  return (
41
- <section className="relative" data-theme={colorPalette}>
42
- <div className={`grid grid-cols-12 gap-1 ${style2className(pageStyle)} ${className || ''}`}>
43
- {blocks?.length ? blocks.map(renderBlock) : null}
44
- </div>
53
+ <section
54
+ className={`relative ${style2className(pageStyle)} ${className || ''}`}
55
+ data-theme={colorPalette}
56
+ >
57
+ {header?.blocks?.length ? (
58
+ <div className={`${style2className(header?.style)}`}>
59
+ {header.blocks.map((block, i) =>
60
+ renderBlock({ block, blockDecorator, blocksRegistry, context }, i),
61
+ )}
62
+ </div>
63
+ ) : null}
64
+
65
+ {blocks?.length ? (
66
+ <div className="container grid grid-cols-12 gap-1">
67
+ {blocks.map((block, i) =>
68
+ renderBlock({ block, blockDecorator, blocksRegistry, context }, i),
69
+ )}
70
+ </div>
71
+ ) : null}
72
+
45
73
  {likeControl && (
46
74
  <div className="flex items-end absolute bottom-0 right-0 h-full pointer-events-none">
47
75
  <LikeControl
@@ -52,39 +80,46 @@ export const ContentPage = JSX<ContentPageProps>(
52
80
  )}
53
81
  </section>
54
82
  );
55
-
56
- function renderBlock(block: BlockDef, i: number) {
57
- const { type } = block;
58
- if (!(type in blocksRegistry)) {
59
- console.warn(`No block with "${type}" is registered`);
60
- }
61
-
62
- const BlockComponent = blocksRegistry[type] || Placeholder;
63
- return blockDecorator(
64
- {
65
- blockClassName: style2className(block.style),
66
- block,
67
- render: (props) => {
68
- const { version, content, blocks } = props.block;
69
- return (
70
- <BlockComponent
71
- key={`${type}-${i}`}
72
- className={props.blockClassName}
73
- version={version}
74
- context={context}
75
- {...content}
76
- >
77
- {blocks?.length ? blocks.map(renderBlock) : null}
78
- </BlockComponent>
79
- );
80
- },
81
- },
82
- `block-${i}`,
83
- );
84
- }
85
83
  },
86
84
  );
87
85
 
86
+ function renderBlock(
87
+ { block, blockDecorator, blocksRegistry, context }: RenderBlockFunc,
88
+ i: number,
89
+ ) {
90
+ const { type } = block;
91
+ if (!(type in blocksRegistry)) {
92
+ console.warn(`No block with "${type}" is registered`);
93
+ }
94
+
95
+ const BlockComponent = blocksRegistry[type] || Placeholder;
96
+ return blockDecorator(
97
+ {
98
+ blockClassName: style2className(block.style),
99
+ block,
100
+ render: (props) => {
101
+ const { version, content, blocks } = props.block;
102
+ return (
103
+ <BlockComponent
104
+ key={`${type}-${i}`}
105
+ className={props.blockClassName}
106
+ version={version}
107
+ context={context}
108
+ {...content}
109
+ >
110
+ {blocks?.length
111
+ ? blocks.map((block, i) =>
112
+ renderBlock({ block, blockDecorator, blocksRegistry, context }, i),
113
+ )
114
+ : null}
115
+ </BlockComponent>
116
+ );
117
+ },
118
+ },
119
+ `block-${i}`,
120
+ );
121
+ }
122
+
88
123
  function style2className(style: string[] | undefined | null): string {
89
124
  return style ? style.join(' ') : '';
90
125
  }
@@ -1,13 +1,30 @@
1
1
  import type { BlockDef, ContentPageDef } from '../../types';
2
2
 
3
3
  export function toMobilePage(contentPage: ContentPageDef): ContentPageDef {
4
- const blocks = contentPage.blocks?.filter(({ mobile }) => !mobile?.hidden).map(toMobileBlock);
4
+ const { blocks, slots } = contentPage;
5
+
5
6
  return {
6
7
  ...contentPage,
7
- blocks,
8
+ blocks: getMobileBlocks(blocks),
9
+ slots:
10
+ slots &&
11
+ Object.keys(slots).reduce(
12
+ (res, key) => ({
13
+ ...res,
14
+ [key]: {
15
+ ...slots[key],
16
+ blocks: getMobileBlocks(slots[key].blocks),
17
+ },
18
+ }),
19
+ {},
20
+ ),
8
21
  };
9
22
  }
10
23
 
24
+ function getMobileBlocks(blocks?: BlockDef[]) {
25
+ return blocks?.filter(({ mobile }) => !mobile?.hidden).map(toMobileBlock);
26
+ }
27
+
11
28
  function toMobileBlock(block: BlockDef): BlockDef {
12
29
  const { mobile } = block;
13
30
  if (mobile) {
@@ -1,11 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { useLink } from '../../hooks/useLink';
3
+ import { useSitemap } from '../../hooks/useSitemap';
2
4
  import { mergeTopItems } from '../../mergeTopItems';
3
5
  import type { UniBlockProps } from '../../types';
4
6
  import { HeaderItem } from '../../ui-kit/HeaderItem/HeaderItem';
5
7
  import { Logo } from '../../ui-kit/Logo/Logo';
6
8
  import { TopItem } from '../../ui-kit/TopItem/TopItem';
7
- import { useLink } from '../../hooks/useLink';
8
- import { useSitemap } from '../../hooks/useSitemap';
9
9
  import type { HeaderContent } from './HeaderContent';
10
10
  import { HeaderSecondaryMenu } from './HeaderSecondaryMenu';
11
11
  import { isSubItemActive } from './isSubItemActive';
@@ -43,17 +43,19 @@ export const Header = JSX<HeaderProps>(({ className, defaultLocation, context, t
43
43
 
44
44
  return (
45
45
  <header className={`pt-5 pb-8 px-20 bg-white ${className || ''}`}>
46
- <div className="flex items-center">
47
- <Logo className="mr-8" />
48
- {topMenu}
49
- <HeaderSecondaryMenu
50
- context={context}
51
- className="ml-auto"
52
- defaultLocation={defaultLocation}
53
- />
46
+ <div className="container">
47
+ <div className="flex items-center">
48
+ <Logo className="mr-8" />
49
+ {topMenu}
50
+ <HeaderSecondaryMenu
51
+ context={context}
52
+ className="ml-auto"
53
+ defaultLocation={defaultLocation}
54
+ />
55
+ </div>
56
+ <div className="mt-5 h-[1px] bg-main-divider" />
57
+ <nav className="mt-5">{subMenu}</nav>
54
58
  </div>
55
- <div className="mt-5 h-[1px] bg-main-divider" />
56
- <nav className="mt-5">{subMenu}</nav>
57
59
  </header>
58
60
  );
59
61
  });
@@ -0,0 +1,26 @@
1
+ {
2
+ "title": "Дополнительные документы",
3
+ "icon": "DocIcon",
4
+ "documents": [
5
+ {
6
+ "text": "Документ №1",
7
+ "href": "/documents/document1.doc",
8
+ "fileSize": "123КБ"
9
+ },
10
+ {
11
+ "text": "Документ №2",
12
+ "href": "/documents/document2.rtf",
13
+ "target": "_blank"
14
+ },
15
+ {
16
+ "text": "Документ №3",
17
+ "href": "/abc3/map.jpeg",
18
+ "fileSize": "2МБ"
19
+ },
20
+ {
21
+ "text": "Документ №4",
22
+ "href": "/abc/map.rar"
23
+ }
24
+ ],
25
+ "columnsMode": "double"
26
+ }
@@ -27,9 +27,9 @@ export const LINK_DOCS: LinkDocsContent = {
27
27
  ],
28
28
  };
29
29
 
30
- export const LINK_DOCS_TWO_COLUMNS: LinkDocsContent = {
30
+ export const LINK_DOCS_ONE_COLUMN: LinkDocsContent = {
31
31
  ...LINK_DOCS,
32
- columnsMode: 'double',
32
+ columnsMode: 'single',
33
33
  };
34
34
 
35
35
  export const LINK_DOCS_ANOTHER_ICON: LinkDocsContent = {
@@ -44,8 +44,8 @@ export const LINK_DOCS_NO_ICON: LinkDocsContent = {
44
44
  };
45
45
 
46
46
  export default {
47
- 'one column': <LinkDocs context={context} {...LINK_DOCS} />,
48
- 'two column': <LinkDocs context={context} {...LINK_DOCS_TWO_COLUMNS} />,
47
+ 'two columns (default)': <LinkDocs context={context} {...LINK_DOCS} />,
48
+ 'one column': <LinkDocs context={context} {...LINK_DOCS_ONE_COLUMN} />,
49
49
  'another icon': <LinkDocs context={context} {...LINK_DOCS_ANOTHER_ICON} />,
50
- 'no icon': <LinkDocs context={context} {...LINK_DOCS_NO_ICON} />,
50
+ 'no icon and title': <LinkDocs context={context} {...LINK_DOCS_NO_ICON} />,
51
51
  };
@@ -13,7 +13,7 @@ const titleAlignStyleMap: Record<AlignType, string> = {
13
13
 
14
14
  const titleMarginsStyleMap: Record<LinkColumnsMode, string> = {
15
15
  double: 'mb-8',
16
- single: '',
16
+ single: 'mb-[26px]',
17
17
  };
18
18
 
19
19
  const linkColumnsModeStyleMap: Record<LinkColumnsMode, string> = {
@@ -24,7 +24,7 @@ const linkColumnsModeStyleMap: Record<LinkColumnsMode, string> = {
24
24
  export interface LinkDocsProps extends LinkDocsContent, UniBlockProps {}
25
25
 
26
26
  export const LinkDocs = JSX<LinkDocsProps>(
27
- ({ className, title, align, documents, icon, columnsMode = 'single' }) => {
27
+ ({ className, title, align, documents, icon, columnsMode = 'double' }) => {
28
28
  const containerClasses = linkColumnsModeStyleMap[columnsMode];
29
29
 
30
30
  return (
@@ -49,7 +49,7 @@ export const LinkDocs = JSX<LinkDocsProps>(
49
49
  role="listitem"
50
50
  {...linkProps}
51
51
  >
52
- {icon && <Icon className="mr-3.5" name={icon} width="24px" height="24px" />}
52
+ {icon && <Icon className="mr-2.5" name={icon} width="24px" height="24px" />}
53
53
  <span className="self-center">
54
54
  {text}
55
55
  <span className="text-secondary-text group-hover:text-primary-main">
@@ -6,6 +6,7 @@ import type { Picture } from '../../model/Picture';
6
6
  const image: Picture = {
7
7
  src: 'money-1.png',
8
8
  format: 'webp',
9
+ alt: 'Потребительский кредит наличными',
9
10
  size: {
10
11
  width: 280,
11
12
  height: 280,
@@ -14,7 +14,9 @@ export const ProductBlock = JSX<ProductBlockProps>((props) => {
14
14
  const { handlerDecorator } = context;
15
15
  return (
16
16
  <section
17
- className={`font-sans bg-white pt-10 pl-[50px] pb-[50px] pr-[7.5rem] ${className || ''}`}
17
+ className={`font-sans bg-white pt-10 pl-[50px] pb-[50px] pr-[7.5rem] box-border min-h-[420px] ${
18
+ className || ''
19
+ }`}
18
20
  >
19
21
  {breadcrumbs?.length ? (
20
22
  <div className="text-xs mb-6">
@@ -43,7 +43,7 @@ function renderBenefit(benefit: Benefit, i: number) {
43
43
  height="24"
44
44
  />
45
45
  )}
46
- <div className="flex gap-1 flex-col h-full">
46
+ <div className="flex gap-1 flex-col h-full max-w-[149px]">
47
47
  <h4 className="font-medium text-primary-text text-xl m-0">{benefit.label}</h4>
48
48
  {benefit.description && (
49
49
  <div className="font-normal text-sm text-secondary-text">{benefit.description}</div>
package/src/types.ts CHANGED
@@ -15,6 +15,15 @@ export interface BlockDef {
15
15
  };
16
16
  }
17
17
 
18
+ export interface Slot {
19
+ style?: string[];
20
+ blocks?: BlockDef[];
21
+ }
22
+
23
+ export interface SlotsMap {
24
+ header?: Slot;
25
+ }
26
+
18
27
  export interface ContentPageMeta {
19
28
  title: string;
20
29
  slug: string;
@@ -26,7 +35,8 @@ export interface ContentPageMeta {
26
35
 
27
36
  export interface ContentPageDef extends ContentPageMeta {
28
37
  style?: string[];
29
- blocks?: BlockDef[];
38
+ blocks?: BlockDef[]; //! for compatibility
39
+ slots?: SlotsMap;
30
40
  likeControl?: boolean;
31
41
  colorPalette?: ColorPalette;
32
42
  }