@redneckz/wildless-cms-uni-blocks 0.2.53 → 0.2.56
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.
- package/dist/BaseTile.d.ts +13 -0
- package/dist/BaseTile.js +35 -0
- package/dist/BaseTile.js.map +1 -0
- package/dist/Blocks.d.ts +2 -2
- package/dist/Blocks.js.map +1 -1
- package/dist/ContentPage.d.ts +4 -1
- package/dist/ContentPage.js +3 -4
- package/dist/ContentPage.js.map +1 -1
- package/dist/ContentPageContext.d.ts +2 -0
- package/dist/ExchangeRateTile.js +7 -5
- package/dist/ExchangeRateTile.js.map +1 -1
- package/dist/Footer/Footer.mobile.d.ts +5 -0
- package/dist/Footer/Footer.mobile.js +7 -0
- package/dist/Footer/Footer.mobile.js.map +1 -0
- package/dist/Header/Header.js +2 -2
- package/dist/Header/Header.js.map +1 -1
- package/dist/Header/HeaderContent.d.ts +1 -1
- package/dist/Header/HeaderSecondaryMenu.d.ts +5 -2
- package/dist/Header/HeaderSecondaryMenu.js +3 -2
- package/dist/Header/HeaderSecondaryMenu.js.map +1 -1
- package/dist/MobileBlocks.d.ts +13 -0
- package/dist/MobileBlocks.js +27 -0
- package/dist/MobileBlocks.js.map +1 -0
- package/dist/ProductBlock.d.ts +2 -0
- package/dist/ProductBlock.js +7 -2
- package/dist/ProductBlock.js.map +1 -1
- package/dist/ProductBlockInner.d.ts +3 -10
- package/dist/ProductBlockInner.js +3 -15
- package/dist/ProductBlockInner.js.map +1 -1
- package/dist/ProductTile.d.ts +4 -13
- package/dist/ProductTile.js +4 -11
- package/dist/ProductTile.js.map +1 -1
- package/dist/Tile.d.ts +3 -11
- package/dist/Tile.js +4 -26
- package/dist/Tile.js.map +1 -1
- package/dist/api/DaDataAPI.d.ts +3 -0
- package/dist/api/DaDataAPI.js +33 -0
- package/dist/api/DaDataAPI.js.map +1 -0
- package/dist/api/LikeAPI.d.ts +1 -1
- package/dist/api/LikeAPI.js +2 -2
- package/dist/api/LikeAPI.js.map +1 -1
- package/dist/content-page-repository/ContentPageRepository.d.ts +1 -0
- package/dist/content-page-repository/ContentPageRepository.js +6 -0
- package/dist/content-page-repository/ContentPageRepository.js.map +1 -1
- package/dist/content-page-repository/index.d.ts +1 -0
- package/dist/content-page-repository/index.js +3 -1
- package/dist/content-page-repository/index.js.map +1 -1
- package/dist/content-page-repository/toMobilePage.d.ts +2 -0
- package/dist/content-page-repository/toMobilePage.js +23 -0
- package/dist/content-page-repository/toMobilePage.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/utils/getCurrentPosition.d.ts +1 -0
- package/dist/utils/getCurrentPosition.js +5 -0
- package/dist/utils/getCurrentPosition.js.map +1 -0
- package/lib/BaseTile.d.ts +13 -0
- package/lib/BaseTile.js +33 -0
- package/lib/BaseTile.js.map +1 -0
- package/lib/Blocks.d.ts +2 -2
- package/lib/Blocks.js.map +1 -1
- package/lib/ContentPage.d.ts +4 -1
- package/lib/ContentPage.js +3 -4
- package/lib/ContentPage.js.map +1 -1
- package/lib/ContentPageContext.d.ts +2 -0
- package/lib/ExchangeRateTile.js +7 -5
- package/lib/ExchangeRateTile.js.map +1 -1
- package/lib/Footer/Footer.mobile.d.ts +5 -0
- package/lib/Footer/Footer.mobile.js +5 -0
- package/lib/Footer/Footer.mobile.js.map +1 -0
- package/lib/Header/Header.js +2 -2
- package/lib/Header/Header.js.map +1 -1
- package/lib/Header/HeaderContent.d.ts +1 -1
- package/lib/Header/HeaderSecondaryMenu.d.ts +5 -2
- package/lib/Header/HeaderSecondaryMenu.js +3 -2
- package/lib/Header/HeaderSecondaryMenu.js.map +1 -1
- package/lib/MobileBlocks.d.ts +13 -0
- package/lib/MobileBlocks.js +25 -0
- package/lib/MobileBlocks.js.map +1 -0
- package/lib/ProductBlock.d.ts +2 -0
- package/lib/ProductBlock.js +8 -3
- package/lib/ProductBlock.js.map +1 -1
- package/lib/ProductBlockInner.d.ts +3 -10
- package/lib/ProductBlockInner.js +3 -15
- package/lib/ProductBlockInner.js.map +1 -1
- package/lib/ProductTile.d.ts +4 -13
- package/lib/ProductTile.js +4 -11
- package/lib/ProductTile.js.map +1 -1
- package/lib/Tile.d.ts +3 -11
- package/lib/Tile.js +5 -27
- package/lib/Tile.js.map +1 -1
- package/lib/api/DaDataAPI.d.ts +3 -0
- package/lib/api/DaDataAPI.js +30 -0
- package/lib/api/DaDataAPI.js.map +1 -0
- package/lib/api/LikeAPI.d.ts +1 -1
- package/lib/api/LikeAPI.js +2 -2
- package/lib/api/LikeAPI.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/content-page-repository/ContentPageRepository.d.ts +1 -0
- package/lib/content-page-repository/ContentPageRepository.js +6 -0
- package/lib/content-page-repository/ContentPageRepository.js.map +1 -1
- package/lib/content-page-repository/index.d.ts +1 -0
- package/lib/content-page-repository/index.js +1 -0
- package/lib/content-page-repository/index.js.map +1 -1
- package/lib/content-page-repository/toMobilePage.d.ts +2 -0
- package/lib/content-page-repository/toMobilePage.js +20 -0
- package/lib/content-page-repository/toMobilePage.js.map +1 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +14 -0
- package/lib/utils/getCurrentPosition.d.ts +1 -0
- package/lib/utils/getCurrentPosition.js +2 -0
- package/lib/utils/getCurrentPosition.js.map +1 -0
- package/package.json +9 -3
- package/src/BaseTile.tsx +87 -0
- package/src/Blocks.ts +3 -2
- package/src/ContentPage.fixture.tsx +23 -3
- package/src/ContentPage.page.json +255 -77
- package/src/ContentPage.tsx +10 -5
- package/src/ContentPageContext.tsx +3 -0
- package/src/ExchangeRateTile.tsx +7 -5
- package/src/Footer/Footer.mobile.tsx +12 -0
- package/src/Header/Header.fixture.tsx +1 -1
- package/src/Header/Header.tsx +6 -2
- package/src/Header/HeaderContent.ts +1 -1
- package/src/Header/HeaderSecondaryMenu.tsx +48 -34
- package/src/MobileBlocks.ts +25 -0
- package/src/ProductBlock.fixture.tsx +3 -2
- package/src/ProductBlock.tsx +25 -3
- package/src/ProductBlockInner.tsx +13 -70
- package/src/ProductTile.fixture.tsx +31 -23
- package/src/ProductTile.tsx +21 -70
- package/src/Tile.fixture.tsx +39 -29
- package/src/Tile.tsx +10 -79
- package/src/api/DaDataAPI.ts +34 -0
- package/src/api/LikeAPI.ts +12 -9
- package/src/content-page-repository/ContentPageRepository.ts +7 -0
- package/src/content-page-repository/index.ts +1 -0
- package/src/content-page-repository/toMobilePage.ts +21 -0
- package/src/index.ts +14 -2
- package/src/setup-fixture.ts +15 -0
- package/src/types.ts +17 -0
- package/src/utils/getCurrentPosition.ts +4 -0
package/src/Tile.fixture.tsx
CHANGED
|
@@ -35,11 +35,13 @@ export default {
|
|
|
35
35
|
'Кредиты наличными на любые цели',
|
|
36
36
|
'Получите деньги без залога и поручителей',
|
|
37
37
|
]}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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 {
|
|
5
|
-
import type {
|
|
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
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
)
|
|
89
|
-
}
|
|
19
|
+
);
|
|
20
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getCurrentPosition } from '../utils/getCurrentPosition';
|
|
2
|
+
|
|
3
|
+
import type { DaDataResult } from '../types';
|
|
4
|
+
|
|
5
|
+
export function DaDataAPI(baseURL = '') {
|
|
6
|
+
async function getFetcherAddress() {
|
|
7
|
+
if (!('geolocation' in navigator)) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const coords = await getCurrentPosition();
|
|
13
|
+
const response = await fetch(`${baseURL}/geolocate`, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
mode: 'cors',
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
lat: coords.latitude,
|
|
18
|
+
lon: coords.longitude,
|
|
19
|
+
count: 1,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const data = (await response.json()) as DaDataResult;
|
|
24
|
+
return data?.suggestions?.[0]?.data?.city;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
getFetcherAddress,
|
|
33
|
+
};
|
|
34
|
+
}
|
package/src/api/LikeAPI.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface LikeData {
|
|
|
10
10
|
const AUTH_PREFIX = 'guest';
|
|
11
11
|
const STORAGE_KEY = 'likesToken';
|
|
12
12
|
|
|
13
|
-
export function LikeAPI(projectId: string, baseURL
|
|
13
|
+
export function LikeAPI(projectId: string, baseURL = '') {
|
|
14
14
|
async function getLikeCount(...nodeIds: string[]): Promise<LikeData[]> {
|
|
15
15
|
if (!nodeIds.length) {
|
|
16
16
|
return [];
|
|
@@ -19,14 +19,17 @@ export function LikeAPI(projectId: string, baseURL: string) {
|
|
|
19
19
|
const { token: Authorization } = await auth();
|
|
20
20
|
|
|
21
21
|
try {
|
|
22
|
-
const response = await fetch(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const response = await fetch(
|
|
23
|
+
`${baseURL}/assist/v1/public/projects/${projectId}/nodes/likes`,
|
|
24
|
+
{
|
|
25
|
+
method: 'POST',
|
|
26
|
+
mode: 'cors',
|
|
27
|
+
headers: { 'Content-Type': 'application/json', Authorization },
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
node_ids: nodeIds,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
);
|
|
30
33
|
|
|
31
34
|
const { likes } = await response.json();
|
|
32
35
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import glob from 'glob';
|
|
2
2
|
import util from 'util';
|
|
3
3
|
import type { ContentPageDef } from '../types';
|
|
4
|
+
import { toMobilePage } from './toMobilePage';
|
|
4
5
|
import type { TransformationOptions } from './TransformationOptions';
|
|
5
6
|
import { transformContentPage } from './transformContentPage';
|
|
6
7
|
|
|
@@ -20,6 +21,11 @@ export function ContentPageRepository({
|
|
|
20
21
|
return pages.find((content) => content.slug === slug);
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
async function getMobilePageBySlug(slug: string): Promise<ContentPageDef | undefined> {
|
|
25
|
+
const page = await getContentPageBySlug(slug);
|
|
26
|
+
return page && toMobilePage(page);
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
const cache: Record<string, ContentPageDef> = {};
|
|
24
30
|
async function readPage(filePath: string): Promise<ContentPageDef> {
|
|
25
31
|
if (!(filePath in cache)) {
|
|
@@ -34,5 +40,6 @@ export function ContentPageRepository({
|
|
|
34
40
|
return {
|
|
35
41
|
getAllContentPages,
|
|
36
42
|
getContentPageBySlug,
|
|
43
|
+
getMobilePageBySlug,
|
|
37
44
|
};
|
|
38
45
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BlockDef, ContentPageDef } from '../types';
|
|
2
|
+
|
|
3
|
+
export function toMobilePage(contentPage: ContentPageDef): ContentPageDef {
|
|
4
|
+
const blocks = contentPage.blocks?.filter(({ mobile }) => !mobile?.hidden).map(toMobileBlock);
|
|
5
|
+
return {
|
|
6
|
+
...contentPage,
|
|
7
|
+
blocks,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toMobileBlock(block: BlockDef): BlockDef {
|
|
12
|
+
const { mobile } = block;
|
|
13
|
+
if (mobile) {
|
|
14
|
+
return {
|
|
15
|
+
...block,
|
|
16
|
+
style: mobile.style?.length ? mobile.style : block.style,
|
|
17
|
+
};
|
|
18
|
+
} else {
|
|
19
|
+
return block;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export type { ProjectSettings } from './ProjectSettings';
|
|
2
2
|
export { projectSettings } from './ProjectSettings';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export { LikeAPI } from './api/LikeAPI';
|
|
5
|
+
export { DaDataAPI } from './api/DaDataAPI';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
BlockDef,
|
|
9
|
+
UniBlockProps,
|
|
10
|
+
ContentPageMeta,
|
|
11
|
+
ContentPageDef,
|
|
12
|
+
Img,
|
|
13
|
+
ImgSource,
|
|
14
|
+
Picture,
|
|
15
|
+
} from './types';
|
|
5
16
|
export type {
|
|
6
17
|
ContentPageContext,
|
|
7
18
|
Router,
|
|
@@ -14,7 +25,8 @@ export { ContentPageHead } from './ContentPageHead';
|
|
|
14
25
|
export { ContentPage } from './ContentPage';
|
|
15
26
|
|
|
16
27
|
export { Blocks } from './Blocks';
|
|
17
|
-
export {
|
|
28
|
+
export type { BlockContent } from './Blocks';
|
|
29
|
+
export { MobileBlocks } from './MobileBlocks';
|
|
18
30
|
|
|
19
31
|
export * as url from './utils/url';
|
|
20
32
|
export { joinList } from './utils/joinList';
|
package/src/setup-fixture.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { setup } from '@redneckz/uni-jsx';
|
|
2
|
+
|
|
2
3
|
import runtime from 'react/jsx-runtime';
|
|
3
4
|
import { useState, useEffect } from 'react';
|
|
5
|
+
import { DaDataAPI } from './api/DaDataAPI';
|
|
4
6
|
import type { ContentPageContext } from './ContentPageContext';
|
|
5
7
|
|
|
6
8
|
const { jsx, jsxs } = runtime as any;
|
|
@@ -8,6 +10,8 @@ setup(jsx, jsxs);
|
|
|
8
10
|
|
|
9
11
|
const TEST_ORIGIN = 'http://localhost:5001';
|
|
10
12
|
|
|
13
|
+
const DaData = DaDataAPI('https://10.80.4.9');
|
|
14
|
+
|
|
11
15
|
export const context: ContentPageContext = {
|
|
12
16
|
useState,
|
|
13
17
|
useRouter: () => ({
|
|
@@ -27,6 +31,17 @@ export const context: ContentPageContext = {
|
|
|
27
31
|
}, [key, fetcher]);
|
|
28
32
|
return { data };
|
|
29
33
|
},
|
|
34
|
+
useGeolocation: (defaultLocation) => {
|
|
35
|
+
const [city, setCity] = useState(defaultLocation);
|
|
36
|
+
|
|
37
|
+
const getCity = () => {
|
|
38
|
+
DaData.getFetcherAddress().then((_) => {
|
|
39
|
+
setCity(_ || defaultLocation);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return [city, getCity];
|
|
44
|
+
},
|
|
30
45
|
useLikeService: () => ({
|
|
31
46
|
likeCount: 0,
|
|
32
47
|
like: () => {
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,9 @@ export interface BlockDef {
|
|
|
22
22
|
version?: BlockVersion;
|
|
23
23
|
content?: BlockContent;
|
|
24
24
|
blocks?: BlockDef[];
|
|
25
|
+
mobile?: Pick<BlockDef, 'content' | 'style'> & {
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
};
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export interface ContentPageMeta {
|
|
@@ -92,3 +95,17 @@ export interface Benefit {
|
|
|
92
95
|
description?: string;
|
|
93
96
|
icon?: string;
|
|
94
97
|
}
|
|
98
|
+
|
|
99
|
+
export interface DaDataResult {
|
|
100
|
+
suggestions?: DaDataSuggestion<DaDataAddress>[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface DaDataSuggestion<T> {
|
|
104
|
+
value?: string;
|
|
105
|
+
unrestricted_value?: string;
|
|
106
|
+
data?: T;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface DaDataAddress {
|
|
110
|
+
city?: string | null;
|
|
111
|
+
}
|