@developer_tribe/react-builder 0.1.0 → 0.1.2
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/package.json +4 -2
- package/scripts/build-components.js +550 -0
- package/scripts/prebuild.js +11 -0
- package/src/AttributesEditor.tsx +107 -0
- package/src/RenderMainNode.tsx +37 -0
- package/src/RenderPage.tsx +61 -0
- package/src/assets/devices.json +730 -0
- package/src/assets/samples/carousel-sample.json +108 -0
- package/src/assets/samples/getSamples.ts +28 -0
- package/src/assets/samples/simple-1.json +46 -0
- package/src/assets/samples/simple-2.json +233 -0
- package/src/assets/samples/vpn-onboard-1.json +799 -0
- package/src/assets/samples/vpn-onboard-2.json +790 -0
- package/src/assets/samples/vpn-onboard-3.json +803 -0
- package/src/assets/samples/vpn-onboard-4.json +804 -0
- package/src/build-components/Button/Button.tsx +13 -0
- package/src/build-components/Button/ButtonProps.generated.ts +21 -0
- package/src/build-components/Button/ButtonProps.ts +3 -0
- package/src/build-components/Button/pattern.json +25 -0
- package/src/build-components/Carousel/Carousel.tsx +27 -0
- package/src/build-components/Carousel/CarouselProps.generated.ts +6 -0
- package/src/build-components/Carousel/CarouselProps.ts +3 -0
- package/src/build-components/Carousel/pattern.json +9 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +47 -0
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +9 -0
- package/src/build-components/CarouselButtons/CarouselButtonsProps.ts +3 -0
- package/src/build-components/CarouselButtons/pattern.json +12 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +40 -0
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +14 -0
- package/src/build-components/CarouselDots/CarouselDotsProps.ts +3 -0
- package/src/build-components/CarouselDots/pattern.json +18 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +18 -0
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +6 -0
- package/src/build-components/CarouselItem/CarouselItemProps.ts +3 -0
- package/src/build-components/CarouselItem/pattern.json +9 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +26 -0
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +6 -0
- package/src/build-components/CarouselProvider/CarouselProviderProps.ts +3 -0
- package/src/build-components/CarouselProvider/pattern.json +9 -0
- package/src/build-components/Image/Image.tsx +35 -0
- package/src/build-components/Image/ImageProps.generated.ts +12 -0
- package/src/build-components/Image/ImageProps.ts +3 -0
- package/src/build-components/Image/pattern.json +15 -0
- package/src/build-components/Onboard/Onboard.tsx +14 -0
- package/src/build-components/Onboard/OnboardProps.generated.ts +6 -0
- package/src/build-components/Onboard/OnboardProps.ts +3 -0
- package/src/build-components/Onboard/pattern.json +9 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitle.tsx +28 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.generated.ts +21 -0
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.ts +4 -0
- package/src/build-components/OnboardBoardTitle/pattern.json +25 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +59 -0
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +13 -0
- package/src/build-components/OnboardButton/OnboardButtonProps.ts +3 -0
- package/src/build-components/OnboardButton/pattern.json +16 -0
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +76 -0
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +12 -0
- package/src/build-components/OnboardButtons/OnboardButtonsProps.ts +3 -0
- package/src/build-components/OnboardButtons/pattern.json +15 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDot.tsx +14 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.generated.ts +14 -0
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.ts +4 -0
- package/src/build-components/OnboardExpandingDot/pattern.json +18 -0
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +13 -0
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +24 -0
- package/src/build-components/OnboardFooter/OnboardFooterProps.ts +3 -0
- package/src/build-components/OnboardFooter/pattern.json +28 -0
- package/src/build-components/OnboardImage/OnboardImage.tsx +14 -0
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +12 -0
- package/src/build-components/OnboardImage/OnboardImageProps.ts +3 -0
- package/src/build-components/OnboardImage/pattern.json +15 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +29 -0
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +6 -0
- package/src/build-components/OnboardItem/OnboardItemProps.ts +3 -0
- package/src/build-components/OnboardItem/pattern.json +9 -0
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +65 -0
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +6 -0
- package/src/build-components/OnboardProvider/OnboardProviderProps.ts +3 -0
- package/src/build-components/OnboardProvider/pattern.json +9 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +28 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +21 -0
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.ts +3 -0
- package/src/build-components/OnboardSubtitle/pattern.json +25 -0
- package/src/build-components/RenderNode.generated.tsx +97 -0
- package/src/build-components/Text/Text.tsx +23 -0
- package/src/build-components/Text/TextProps.generated.ts +21 -0
- package/src/build-components/Text/TextProps.ts +3 -0
- package/src/build-components/Text/pattern.json +26 -0
- package/src/build-components/View/View.tsx +62 -0
- package/src/build-components/View/ViewProps.generated.ts +24 -0
- package/src/build-components/View/ViewProps.ts +3 -0
- package/src/build-components/View/pattern.json +28 -0
- package/src/build-components/other.ts +6 -0
- package/src/index.ts +24 -0
- package/src/styles/index.scss +114 -0
- package/src/types/Device.ts +12 -0
- package/src/types/Node.ts +19 -0
- package/src/types/PreviewConfig.ts +19 -0
- package/src/types/Project.ts +11 -0
- package/src/types/TargetedScreenSize.ts +4 -0
- package/src/utils/analyseNode.ts +77 -0
- package/src/utils/generateRandomKeyForNode.ts +3 -0
- package/src/utils/getDevices.ts +6 -0
- package/src/utils/isCarousel.ts +36 -0
- package/src/utils/isOnboard.ts +54 -0
- package/src/utils/novaToJson.ts +254 -0
- package/src/utils/patterns.ts +63 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { ButtonProps } from './ButtonProps';
|
|
4
|
+
|
|
5
|
+
type ButtonComponentProps = {
|
|
6
|
+
node: NodeData<ButtonProps['attributes']>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function Button({ node }: ButtonComponentProps) {
|
|
10
|
+
return String(node?.type ?? 'button');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default React.memo(Button);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface ButtonPropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
color?: string;
|
|
7
|
+
fontSize?: number;
|
|
8
|
+
fontWeight?:
|
|
9
|
+
| 'normal'
|
|
10
|
+
| 'bold'
|
|
11
|
+
| '100'
|
|
12
|
+
| '200'
|
|
13
|
+
| '300'
|
|
14
|
+
| '400'
|
|
15
|
+
| '500'
|
|
16
|
+
| '600'
|
|
17
|
+
| '700'
|
|
18
|
+
| '800'
|
|
19
|
+
| '900';
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "button",
|
|
6
|
+
"children": "string",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"color": "string",
|
|
9
|
+
"fontSize": "number",
|
|
10
|
+
"fontWeight": [
|
|
11
|
+
"normal",
|
|
12
|
+
"bold",
|
|
13
|
+
"100",
|
|
14
|
+
"200",
|
|
15
|
+
"300",
|
|
16
|
+
"400",
|
|
17
|
+
"500",
|
|
18
|
+
"600",
|
|
19
|
+
"700",
|
|
20
|
+
"800",
|
|
21
|
+
"900"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { CarouselProps } from './CarouselProps';
|
|
4
|
+
import RenderNode from '../RenderNode.generated';
|
|
5
|
+
import { isCarouselItem } from '../../utils/isCarousel';
|
|
6
|
+
|
|
7
|
+
type CarouselComponentProps = {
|
|
8
|
+
node: NodeData<CarouselProps['attributes']>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function Carousel({ node }: CarouselComponentProps) {
|
|
12
|
+
// Ensure children are carouselItems
|
|
13
|
+
const renderChildren = () => {
|
|
14
|
+
if (Array.isArray(node.children)) {
|
|
15
|
+
return node.children.map((item, index) => (
|
|
16
|
+
<RenderNode key={index} node={item} />
|
|
17
|
+
));
|
|
18
|
+
}
|
|
19
|
+
return isCarouselItem(node.children) ? (
|
|
20
|
+
<RenderNode node={node.children} />
|
|
21
|
+
) : null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return <div className="embla__container">{renderChildren()}</div>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default React.memo(Carousel);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { CarouselButtonsProps } from './CarouselButtonsProps';
|
|
4
|
+
import { carouselContext } from '../CarouselProvider/CarouselProvider';
|
|
5
|
+
|
|
6
|
+
type CarouselButtonsComponentProps = {
|
|
7
|
+
node: NodeData<CarouselButtonsProps['attributes']>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function CarouselButtons({ node }: CarouselButtonsComponentProps) {
|
|
11
|
+
const emblaApi = useContext(carouselContext);
|
|
12
|
+
const buttonTypes = node.attributes?.buttonType || [
|
|
13
|
+
'previous_button',
|
|
14
|
+
'next_button',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className="embla__buttons">
|
|
19
|
+
{buttonTypes.includes('previous_button') && (
|
|
20
|
+
<button
|
|
21
|
+
onClick={() => emblaApi?.scrollPrev()}
|
|
22
|
+
className="embla__button embla__button--prev"
|
|
23
|
+
>
|
|
24
|
+
Previous
|
|
25
|
+
</button>
|
|
26
|
+
)}
|
|
27
|
+
{buttonTypes.includes('next_button') && (
|
|
28
|
+
<button
|
|
29
|
+
onClick={() => emblaApi?.scrollNext()}
|
|
30
|
+
className="embla__button embla__button--next"
|
|
31
|
+
>
|
|
32
|
+
Next
|
|
33
|
+
</button>
|
|
34
|
+
)}
|
|
35
|
+
{buttonTypes.includes('skip_button') && (
|
|
36
|
+
<button
|
|
37
|
+
onClick={() => emblaApi?.scrollTo(node.attributes?.skipNumber)}
|
|
38
|
+
className="embla__button embla__button--skip"
|
|
39
|
+
>
|
|
40
|
+
Skip
|
|
41
|
+
</button>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default React.memo(CarouselButtons);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { CarouselDotsProps } from './CarouselDotsProps';
|
|
4
|
+
import { carouselContext } from '../CarouselProvider/CarouselProvider';
|
|
5
|
+
|
|
6
|
+
type CarouselDotsComponentProps = {
|
|
7
|
+
node: NodeData<CarouselDotsProps['attributes']>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function CarouselDots({ node }: CarouselDotsComponentProps) {
|
|
11
|
+
const dotType = node.attributes?.dotType || 'normal_dot';
|
|
12
|
+
const emblaApi = useContext(carouselContext);
|
|
13
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
14
|
+
const [scrollSnaps, setScrollSnaps] = useState<number[]>([]);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!emblaApi) return;
|
|
18
|
+
setScrollSnaps(emblaApi.scrollSnapList());
|
|
19
|
+
setSelectedIndex(emblaApi.selectedScrollSnap());
|
|
20
|
+
emblaApi.on('select', () => {
|
|
21
|
+
setSelectedIndex(emblaApi.selectedScrollSnap());
|
|
22
|
+
});
|
|
23
|
+
}, [emblaApi]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={`embla__dots embla__dots--${dotType}`}>
|
|
27
|
+
{scrollSnaps.map((snap, index) => (
|
|
28
|
+
<button
|
|
29
|
+
key={index}
|
|
30
|
+
onClick={() => emblaApi?.scrollTo(snap)}
|
|
31
|
+
className={`embla__dot ${selectedIndex === index ? 'embla__dot--selected' : ''}`}
|
|
32
|
+
>
|
|
33
|
+
{index === selectedIndex ? '●' : '○'}
|
|
34
|
+
</button>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default React.memo(CarouselDots);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface CarouselDotsPropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
dotType?:
|
|
7
|
+
| 'expanding_dot'
|
|
8
|
+
| 'normal_dot'
|
|
9
|
+
| 'scaling_dot'
|
|
10
|
+
| 'sliding_border'
|
|
11
|
+
| 'sliding_dot'
|
|
12
|
+
| 'liquid_like';
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "carouselDots",
|
|
6
|
+
"children": "never",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"dotType": [
|
|
9
|
+
"expanding_dot",
|
|
10
|
+
"normal_dot",
|
|
11
|
+
"scaling_dot",
|
|
12
|
+
"sliding_border",
|
|
13
|
+
"sliding_dot",
|
|
14
|
+
"liquid_like"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { CarouselItemProps } from './CarouselItemProps';
|
|
4
|
+
import { RenderNode } from '../..';
|
|
5
|
+
|
|
6
|
+
type CarouselItemComponentProps = {
|
|
7
|
+
node: NodeData<CarouselItemProps['attributes']>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function CarouselItem({ node }: CarouselItemComponentProps) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="embla__slide" {...node.attributes}>
|
|
13
|
+
{node.children && <RenderNode node={node.children} />}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default React.memo(CarouselItem);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { CarouselProviderProps } from './CarouselProviderProps';
|
|
4
|
+
import { RenderNode } from '../..';
|
|
5
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
6
|
+
|
|
7
|
+
type CarouselProviderComponentProps = {
|
|
8
|
+
node: NodeData<CarouselProviderProps['attributes']>;
|
|
9
|
+
};
|
|
10
|
+
export const carouselContext = createContext<any>(undefined);
|
|
11
|
+
function CarouselProvider({ node }: CarouselProviderComponentProps) {
|
|
12
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
|
|
13
|
+
return (
|
|
14
|
+
<carouselContext.Provider value={emblaApi}>
|
|
15
|
+
<div className="carousel-provider">
|
|
16
|
+
<div className="embla">
|
|
17
|
+
<div className="embla__viewport" ref={emblaRef}>
|
|
18
|
+
{node.children && <RenderNode node={node.children} />}
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</carouselContext.Provider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default React.memo(CarouselProvider);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { ImageProps } from './ImageProps';
|
|
4
|
+
|
|
5
|
+
type ImageComponentProps = {
|
|
6
|
+
node: NodeData<ImageProps['attributes']>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function Image({ node }: ImageComponentProps) {
|
|
10
|
+
return (
|
|
11
|
+
<img
|
|
12
|
+
key={node.key}
|
|
13
|
+
className="primitive primitive-image"
|
|
14
|
+
src={node.attributes?.src}
|
|
15
|
+
width={node.attributes?.width}
|
|
16
|
+
height={node.attributes?.height}
|
|
17
|
+
style={{
|
|
18
|
+
width: node.attributes?.width,
|
|
19
|
+
height: node.attributes?.height,
|
|
20
|
+
borderRadius: node.attributes?.borderRadius,
|
|
21
|
+
objectFit:
|
|
22
|
+
node.attributes?.resizeMode === 'cover'
|
|
23
|
+
? 'cover'
|
|
24
|
+
: node.attributes?.resizeMode === 'contain'
|
|
25
|
+
? 'contain'
|
|
26
|
+
: node.attributes?.resizeMode === 'stretch'
|
|
27
|
+
? 'fill'
|
|
28
|
+
: undefined,
|
|
29
|
+
}}
|
|
30
|
+
alt=""
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default React.memo(Image);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface ImagePropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
src?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
resizeMode?: 'cover' | 'contain' | 'stretch' | 'center';
|
|
10
|
+
borderRadius?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "image",
|
|
6
|
+
"children": "never",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"src": "string",
|
|
9
|
+
"width": "number",
|
|
10
|
+
"height": "number",
|
|
11
|
+
"resizeMode": ["cover", "contain", "stretch", "center"],
|
|
12
|
+
"borderRadius": "number"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { OnboardProps } from './OnboardProps';
|
|
4
|
+
import Carousel from '../Carousel/Carousel';
|
|
5
|
+
|
|
6
|
+
type OnboardComponentProps = {
|
|
7
|
+
node: NodeData<OnboardProps['attributes']>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function Onboard({ node }: OnboardComponentProps) {
|
|
11
|
+
return <Carousel node={{ ...node, type: 'carousel' } as any} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default React.memo(Onboard);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { OnboardBoardTitleProps } from './OnboardBoardTitleProps';
|
|
4
|
+
import Text from '../Text/Text';
|
|
5
|
+
|
|
6
|
+
type OnboardBoardTitleComponentProps = {
|
|
7
|
+
node: NodeData<OnboardBoardTitleProps['attributes']>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function OnboardBoardTitle({ node }: OnboardBoardTitleComponentProps) {
|
|
11
|
+
return (
|
|
12
|
+
<Text
|
|
13
|
+
node={
|
|
14
|
+
{
|
|
15
|
+
...node,
|
|
16
|
+
type: 'text',
|
|
17
|
+
attributes: {
|
|
18
|
+
fontSize: 24,
|
|
19
|
+
fontWeight: '700',
|
|
20
|
+
...(node.attributes as any),
|
|
21
|
+
},
|
|
22
|
+
} as any
|
|
23
|
+
}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default React.memo(OnboardBoardTitle);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface OnboardBoardTitlePropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
color?: string;
|
|
7
|
+
fontSize?: number;
|
|
8
|
+
fontWeight?:
|
|
9
|
+
| 'normal'
|
|
10
|
+
| 'bold'
|
|
11
|
+
| '100'
|
|
12
|
+
| '200'
|
|
13
|
+
| '300'
|
|
14
|
+
| '400'
|
|
15
|
+
| '500'
|
|
16
|
+
| '600'
|
|
17
|
+
| '700'
|
|
18
|
+
| '800'
|
|
19
|
+
| '900';
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "OnboardBoardTitle",
|
|
6
|
+
"children": "node",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"color": "string",
|
|
9
|
+
"fontSize": "number",
|
|
10
|
+
"fontWeight": [
|
|
11
|
+
"normal",
|
|
12
|
+
"bold",
|
|
13
|
+
"100",
|
|
14
|
+
"200",
|
|
15
|
+
"300",
|
|
16
|
+
"400",
|
|
17
|
+
"500",
|
|
18
|
+
"600",
|
|
19
|
+
"700",
|
|
20
|
+
"800",
|
|
21
|
+
"900"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import type { NodeData } from '../../types/Node';
|
|
3
|
+
import type { OnboardButtonProps } from './OnboardButtonProps';
|
|
4
|
+
import { carouselContext } from '../CarouselProvider/CarouselProvider';
|
|
5
|
+
import { mainNodeContext } from '../../RenderMainNode';
|
|
6
|
+
|
|
7
|
+
type OnboardButtonComponentProps = {
|
|
8
|
+
node: NodeData<OnboardButtonProps['attributes']>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function OnboardButton({ node }: OnboardButtonComponentProps) {
|
|
12
|
+
const emblaApi = useContext(carouselContext);
|
|
13
|
+
const { localication, defaultLanguage } = useContext(mainNodeContext) ?? {};
|
|
14
|
+
|
|
15
|
+
const labelRaw = node.attributes?.labelKey ?? '';
|
|
16
|
+
const label =
|
|
17
|
+
(localication?.[defaultLanguage ?? 'en']?.[labelRaw] as string) ?? labelRaw;
|
|
18
|
+
|
|
19
|
+
const flex = node.attributes?.flex ?? 1;
|
|
20
|
+
const textColor = node.attributes?.button_text_color ?? '#FFFFFF';
|
|
21
|
+
const backgroundColor = node.attributes?.button_background_color ?? '#0066FF';
|
|
22
|
+
|
|
23
|
+
const handleClick = () => {
|
|
24
|
+
const events = (node.attributes as any)?.events || [];
|
|
25
|
+
for (const e of events) {
|
|
26
|
+
if (e.type === 'Permission') {
|
|
27
|
+
alert(`Permission requested: ${e.permission ?? 'unknown'}`);
|
|
28
|
+
} else if (e.type === 'Navigate') {
|
|
29
|
+
// no-op for web demo
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (typeof node.attributes?.targetIndex === 'number') {
|
|
33
|
+
emblaApi?.scrollTo(node.attributes.targetIndex);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<button
|
|
39
|
+
className="onboard__button"
|
|
40
|
+
onClick={handleClick}
|
|
41
|
+
style={{
|
|
42
|
+
flex,
|
|
43
|
+
color: textColor,
|
|
44
|
+
backgroundColor,
|
|
45
|
+
border: 'none',
|
|
46
|
+
borderRadius: 20,
|
|
47
|
+
height: '100%',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
cursor: 'pointer',
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{label}
|
|
55
|
+
</button>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default React.memo(OnboardButton);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* AUTO-GENERATED FILE - DO NOT EDIT */
|
|
2
|
+
|
|
3
|
+
export interface OnboardButtonPropsGenerated {
|
|
4
|
+
child: string;
|
|
5
|
+
attributes: {
|
|
6
|
+
labelKey?: string;
|
|
7
|
+
button_text_color?: string;
|
|
8
|
+
button_background_color?: string;
|
|
9
|
+
flex?: number;
|
|
10
|
+
targetIndex?: number;
|
|
11
|
+
events?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"allowUnknownAttributes": false,
|
|
4
|
+
"pattern": {
|
|
5
|
+
"type": "OnboardButton",
|
|
6
|
+
"children": "never",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"labelKey": "string",
|
|
9
|
+
"button_text_color": "string",
|
|
10
|
+
"button_background_color": "string",
|
|
11
|
+
"flex": "number",
|
|
12
|
+
"targetIndex": "number",
|
|
13
|
+
"events": "string"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|