@developer_tribe/react-builder 1.0.2 → 1.0.3
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/AttributesEditor.d.ts +3 -1
- package/dist/RenderPage.d.ts +2 -1
- package/dist/attributes-editor/Field.d.ts +2 -1
- package/dist/attributes-editor/SpecialCategorySection.d.ts +2 -1
- package/dist/build-components/BackgroundImage/BackgroundImage.d.ts +5 -0
- package/dist/build-components/BackgroundImage/BackgroundImageProps.generated.d.ts +44 -0
- package/dist/build-components/Button/ButtonProps.generated.d.ts +7 -0
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +7 -0
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +7 -0
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +7 -0
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +7 -0
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +7 -0
- package/dist/build-components/Image/ImageProps.generated.d.ts +7 -0
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +7 -1
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +7 -0
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +7 -0
- package/dist/build-components/Text/TextProps.generated.d.ts +7 -0
- package/dist/build-components/View/ViewProps.generated.d.ts +7 -0
- package/dist/build-components/index.d.ts +2 -1
- package/dist/build-components/patterns.generated.d.ts +1444 -15
- package/dist/components/AttributesEditorPanel.d.ts +3 -4
- package/dist/components/Builder.d.ts +2 -1
- package/dist/components/BuilderButton.d.ts +9 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/modals/ColorModal.d.ts +3 -1
- package/dist/pages/ProjectPage.d.ts +3 -3
- package/dist/pages/tabs/BuilderPanel.d.ts +8 -0
- package/dist/pages/tabs/{DebugTab.d.ts → SideTool.d.ts} +2 -2
- package/dist/store.d.ts +7 -1
- package/dist/styles.css +1 -1
- package/dist/types/Project.d.ts +11 -0
- package/dist/utils/analyseNode.d.ts +1 -0
- package/dist/utils/extractTextStyle.d.ts +8 -1
- package/dist/utils/extractViewStyle.d.ts +8 -1
- package/dist/utils/parseColor.d.ts +7 -0
- package/package.json +1 -1
- package/src/AttributesEditor.tsx +76 -14
- package/src/RenderPage.tsx +82 -4
- package/src/attributes-editor/Field.tsx +12 -5
- package/src/attributes-editor/SpecialCategorySection.tsx +2 -1
- package/src/build-components/BackgroundImage/BackgroundImage.tsx +87 -0
- package/src/build-components/BackgroundImage/BackgroundImageProps.generated.ts +60 -0
- package/src/build-components/BackgroundImage/pattern.json +45 -0
- package/src/build-components/Button/Button.tsx +31 -4
- package/src/build-components/Button/ButtonProps.generated.ts +7 -0
- package/src/build-components/Carousel/Carousel.tsx +27 -3
- package/src/build-components/Carousel/CarouselProps.generated.ts +7 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +19 -4
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +7 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +13 -4
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +7 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +20 -4
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +7 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +14 -3
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +7 -0
- package/src/build-components/Image/Image.tsx +29 -4
- package/src/build-components/Image/ImageProps.generated.ts +7 -0
- package/src/build-components/Onboard/Onboard.tsx +2 -2
- package/src/build-components/Onboard/OnboardProps.generated.ts +7 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +11 -4
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +7 -0
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +17 -5
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +7 -0
- package/src/build-components/OnboardDot/OnboardDot.tsx +15 -6
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +7 -0
- package/src/build-components/OnboardDot/pattern.json +1 -1
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +15 -5
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +7 -0
- package/src/build-components/OnboardImage/OnboardImage.tsx +28 -6
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +7 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +14 -3
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +7 -0
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +34 -12
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +7 -1
- package/src/build-components/OnboardProvider/pattern.json +0 -8
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +7 -0
- package/src/build-components/OnboardSubtitle/pattern.json +1 -1
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +7 -0
- package/src/build-components/OnboardTitle/pattern.json +1 -1
- package/src/build-components/RenderNode.generated.tsx +3 -0
- package/src/build-components/Text/Text.tsx +33 -9
- package/src/build-components/Text/TextProps.generated.ts +7 -0
- package/src/build-components/View/View.tsx +27 -3
- package/src/build-components/View/ViewProps.generated.ts +7 -0
- package/src/build-components/View/pattern.json +59 -1
- package/src/build-components/index.ts +5 -0
- package/src/build-components/patterns.generated.ts +1452 -15
- package/src/components/AttributesEditorPanel.tsx +13 -6
- package/src/components/Builder.tsx +140 -40
- package/src/components/BuilderButton.tsx +127 -0
- package/src/index.ts +2 -2
- package/src/mockOS/components/MockOSRouter.tsx +11 -3
- package/src/modals/ColorModal.tsx +212 -55
- package/src/pages/ProjectPage.tsx +293 -55
- package/src/pages/tabs/{BuilderTab.tsx → BuilderPanel.tsx} +13 -9
- package/src/pages/tabs/SideTool.tsx +259 -0
- package/src/size-matters/index.ts +6 -0
- package/src/store.ts +13 -1
- package/src/styles/base/_global.scss +158 -7
- package/src/styles/components/_attributes-editor.scss +12 -0
- package/src/styles/components/_editor-shell.scss +23 -0
- package/src/styles/foundation/_sizes.scss +1 -1
- package/src/styles/layout/_builder.scss +66 -10
- package/src/styles/modals/_color-modal.scss +29 -0
- package/src/types/Project.ts +14 -0
- package/src/utils/analyseNode.ts +98 -0
- package/src/utils/extractTextStyle.ts +24 -8
- package/src/utils/extractViewStyle.ts +27 -3
- package/src/utils/parseColor.ts +43 -0
- package/dist/pages/tabs/BuilderTab.d.ts +0 -9
- package/dist/pages/tabs/PreviewTab.d.ts +0 -3
- package/src/pages/tabs/DebugTab.tsx +0 -64
- package/src/pages/tabs/PreviewTab.tsx +0 -206
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { other } from './other';
|
|
13
13
|
|
|
14
14
|
// Builder components
|
|
15
|
+
import BackgroundImage from './BackgroundImage/BackgroundImage';
|
|
15
16
|
import Button from './Button/Button';
|
|
16
17
|
import Carousel from './Carousel/Carousel';
|
|
17
18
|
import CarouselButtons from './CarouselButtons/CarouselButtons';
|
|
@@ -51,6 +52,8 @@ function RenderNode({ node }: { node: Node }) {
|
|
|
51
52
|
|
|
52
53
|
const simpleNode = node as NodeData;
|
|
53
54
|
switch (simpleNode?.type) {
|
|
55
|
+
case 'background-image':
|
|
56
|
+
return <BackgroundImage node={simpleNode} />;
|
|
54
57
|
case 'button':
|
|
55
58
|
return <Button node={simpleNode} />;
|
|
56
59
|
case 'carousel':
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { TextComponentProps } from './TextProps.generated';
|
|
3
3
|
import useNode from '../useNode';
|
|
4
4
|
import { useRenderStore } from '../../store';
|
|
@@ -9,18 +9,42 @@ import { useLogRender } from '../../utils/useLogRender';
|
|
|
9
9
|
function Text({ node }: TextComponentProps) {
|
|
10
10
|
useLogRender('Text');
|
|
11
11
|
node = useNode(node);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const attributeName = (node as any)?.sourceType ?? node.type ?? 'text';
|
|
14
|
+
const attributeKey = node.key ?? generatedId;
|
|
15
|
+
const { appConfig, projectColors, previewMode, current } = useRenderStore(
|
|
16
|
+
(s) => ({
|
|
17
|
+
appConfig: s.appConfig,
|
|
18
|
+
projectColors: s.projectColors,
|
|
19
|
+
previewMode: s.previewMode,
|
|
20
|
+
current: s.current,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
16
23
|
const { defaultLanguage, localication } = appConfig;
|
|
17
24
|
const keyOrText: string = node.children as string;
|
|
18
|
-
const textStyle = extractTextStyle(node);
|
|
19
|
-
const viewStyle = useMemo(
|
|
20
|
-
|
|
25
|
+
const textStyle = extractTextStyle(node, { appConfig, projectColors });
|
|
26
|
+
const viewStyle = useMemo(
|
|
27
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
28
|
+
[node, appConfig, projectColors],
|
|
29
|
+
);
|
|
30
|
+
const isSelected =
|
|
31
|
+
previewMode &&
|
|
32
|
+
!!current &&
|
|
33
|
+
(current as any)?.key &&
|
|
34
|
+
(node as any)?.key &&
|
|
35
|
+
(current as any).key === (node as any).key;
|
|
36
|
+
const style = {
|
|
37
|
+
...viewStyle,
|
|
38
|
+
...textStyle,
|
|
39
|
+
...(isSelected ? { outline: '2px solid #2684FF' } : {}),
|
|
40
|
+
};
|
|
21
41
|
|
|
22
42
|
return (
|
|
23
|
-
<p
|
|
43
|
+
<p
|
|
44
|
+
attribute-name={attributeName}
|
|
45
|
+
attribute-key={attributeKey}
|
|
46
|
+
style={style}
|
|
47
|
+
>
|
|
24
48
|
{localication?.[defaultLanguage ?? 'en']?.[keyOrText] ?? keyOrText}
|
|
25
49
|
</p>
|
|
26
50
|
);
|
|
@@ -16,6 +16,7 @@ export type JustifyContentOptionType =
|
|
|
16
16
|
| 'space-between'
|
|
17
17
|
| 'space-around'
|
|
18
18
|
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
19
20
|
export type FontWeightOptionType =
|
|
20
21
|
| 'normal'
|
|
21
22
|
| 'bold'
|
|
@@ -55,6 +56,12 @@ export interface TextPropsGenerated {
|
|
|
55
56
|
borderRadius?: string;
|
|
56
57
|
width?: string;
|
|
57
58
|
height?: string;
|
|
59
|
+
position?: PositionOptionType;
|
|
60
|
+
top?: string;
|
|
61
|
+
bottom?: string;
|
|
62
|
+
left?: string;
|
|
63
|
+
right?: string;
|
|
64
|
+
zIndex?: number;
|
|
58
65
|
color?: string;
|
|
59
66
|
fontSize?: string;
|
|
60
67
|
fontWeight?: FontWeightOptionType;
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useId, useMemo } from 'react';
|
|
2
2
|
import type { ViewComponentProps } from './ViewProps.generated';
|
|
3
3
|
import RenderNode from '../RenderNode.generated';
|
|
4
4
|
import { Node } from '../../types/Node';
|
|
5
5
|
import useNode from '../useNode';
|
|
6
|
+
import { useRenderStore } from '../../store';
|
|
6
7
|
import { extractViewStyle } from '../../utils/extractViewStyle';
|
|
7
8
|
import { useLogRender } from '../../utils/useLogRender';
|
|
8
9
|
|
|
9
10
|
export function View({ node }: ViewComponentProps) {
|
|
10
11
|
useLogRender('View');
|
|
11
12
|
node = useNode(node);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const generatedId = useId();
|
|
14
|
+
const attributeName = (node as any)?.sourceType ?? node.type ?? 'view';
|
|
15
|
+
const attributeKey = node.key ?? generatedId;
|
|
16
|
+
const { previewMode, current, appConfig, projectColors } = useRenderStore(
|
|
17
|
+
(s) => ({
|
|
18
|
+
previewMode: s.previewMode,
|
|
19
|
+
current: s.current,
|
|
20
|
+
appConfig: s.appConfig,
|
|
21
|
+
projectColors: s.projectColors,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
const baseStyle = useMemo(
|
|
25
|
+
() => extractViewStyle(node, { appConfig, projectColors }),
|
|
26
|
+
[node, appConfig, projectColors],
|
|
27
|
+
);
|
|
28
|
+
const isSelected =
|
|
29
|
+
previewMode &&
|
|
30
|
+
!!current &&
|
|
31
|
+
(current as any)?.key &&
|
|
32
|
+
(node as any)?.key &&
|
|
33
|
+
(current as any).key === (node as any).key;
|
|
34
|
+
const viewStyle = isSelected
|
|
35
|
+
? { ...baseStyle, outline: '2px solid #2684FF' }
|
|
36
|
+
: baseStyle;
|
|
14
37
|
return (
|
|
15
38
|
<div
|
|
39
|
+
attribute-name={attributeName}
|
|
16
40
|
attribute-key={attributeKey}
|
|
17
41
|
style={viewStyle}
|
|
18
42
|
className="scroll-container"
|
|
@@ -16,6 +16,7 @@ export type JustifyContentOptionType =
|
|
|
16
16
|
| 'space-between'
|
|
17
17
|
| 'space-around'
|
|
18
18
|
| 'space-evenly';
|
|
19
|
+
export type PositionOptionType = 'relative' | 'absolute';
|
|
19
20
|
|
|
20
21
|
export interface ViewPropsGenerated {
|
|
21
22
|
child: string;
|
|
@@ -42,6 +43,12 @@ export interface ViewPropsGenerated {
|
|
|
42
43
|
borderRadius?: string;
|
|
43
44
|
width?: string;
|
|
44
45
|
height?: string;
|
|
46
|
+
position?: PositionOptionType;
|
|
47
|
+
top?: string;
|
|
48
|
+
bottom?: string;
|
|
49
|
+
left?: string;
|
|
50
|
+
right?: string;
|
|
51
|
+
zIndex?: number;
|
|
45
52
|
};
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -33,7 +33,13 @@
|
|
|
33
33
|
"backgroundColor": "color",
|
|
34
34
|
"borderRadius": "size",
|
|
35
35
|
"width": "size",
|
|
36
|
-
"height": "size"
|
|
36
|
+
"height": "size",
|
|
37
|
+
"position": ["relative", "absolute"],
|
|
38
|
+
"top": "size",
|
|
39
|
+
"bottom": "size",
|
|
40
|
+
"left": "size",
|
|
41
|
+
"right": "size",
|
|
42
|
+
"zIndex": "number"
|
|
37
43
|
},
|
|
38
44
|
"defaults": {
|
|
39
45
|
"flexDirection": "column"
|
|
@@ -61,6 +67,12 @@
|
|
|
61
67
|
"description": "Fixed dimensions.",
|
|
62
68
|
"category": "container",
|
|
63
69
|
"sort": 3
|
|
70
|
+
},
|
|
71
|
+
"offset": {
|
|
72
|
+
"label": "Offset",
|
|
73
|
+
"description": "Absolute positioning offsets.",
|
|
74
|
+
"category": "container",
|
|
75
|
+
"sort": 4
|
|
64
76
|
}
|
|
65
77
|
},
|
|
66
78
|
"attributes": {
|
|
@@ -242,6 +254,52 @@
|
|
|
242
254
|
"specialCategory": "size",
|
|
243
255
|
"sort": 1,
|
|
244
256
|
"preferedScale": "vs"
|
|
257
|
+
},
|
|
258
|
+
"position": {
|
|
259
|
+
"label": "Position",
|
|
260
|
+
"description": "Sets layout positioning mode.",
|
|
261
|
+
"category": "container",
|
|
262
|
+
"specialCategory": null,
|
|
263
|
+
"sort": 2
|
|
264
|
+
},
|
|
265
|
+
"top": {
|
|
266
|
+
"label": "Top",
|
|
267
|
+
"description": "Offset from the top edge.",
|
|
268
|
+
"category": "container",
|
|
269
|
+
"specialCategory": "offset",
|
|
270
|
+
"sort": 22,
|
|
271
|
+
"preferedScale": "vs"
|
|
272
|
+
},
|
|
273
|
+
"bottom": {
|
|
274
|
+
"label": "Bottom",
|
|
275
|
+
"description": "Offset from the bottom edge.",
|
|
276
|
+
"category": "container",
|
|
277
|
+
"specialCategory": "offset",
|
|
278
|
+
"sort": 23,
|
|
279
|
+
"preferedScale": "vs"
|
|
280
|
+
},
|
|
281
|
+
"left": {
|
|
282
|
+
"label": "Left",
|
|
283
|
+
"description": "Offset from the left edge.",
|
|
284
|
+
"category": "container",
|
|
285
|
+
"specialCategory": "offset",
|
|
286
|
+
"sort": 24,
|
|
287
|
+
"preferedScale": "s"
|
|
288
|
+
},
|
|
289
|
+
"right": {
|
|
290
|
+
"label": "Right",
|
|
291
|
+
"description": "Offset from the right edge.",
|
|
292
|
+
"category": "container",
|
|
293
|
+
"specialCategory": "offset",
|
|
294
|
+
"sort": 25,
|
|
295
|
+
"preferedScale": "s"
|
|
296
|
+
},
|
|
297
|
+
"zIndex": {
|
|
298
|
+
"label": "Z-Index",
|
|
299
|
+
"description": "Controls stacking order.",
|
|
300
|
+
"category": "container",
|
|
301
|
+
"specialCategory": null,
|
|
302
|
+
"sort": 26
|
|
245
303
|
}
|
|
246
304
|
}
|
|
247
305
|
}
|
|
@@ -5,6 +5,7 @@ export { default as RenderNode } from './RenderNode.generated';
|
|
|
5
5
|
export { patterns } from './patterns.generated';
|
|
6
6
|
|
|
7
7
|
export const allcomponentNames = [
|
|
8
|
+
'background-image',
|
|
8
9
|
'button',
|
|
9
10
|
'carousel',
|
|
10
11
|
'carouselButtons',
|
|
@@ -26,6 +27,10 @@ export const allcomponentNames = [
|
|
|
26
27
|
'view',
|
|
27
28
|
] as const;
|
|
28
29
|
|
|
30
|
+
export type {
|
|
31
|
+
BackgroundImagePropsGenerated,
|
|
32
|
+
BackgroundImageComponentProps,
|
|
33
|
+
} from './BackgroundImage/BackgroundImageProps.generated';
|
|
29
34
|
export type {
|
|
30
35
|
ButtonPropsGenerated,
|
|
31
36
|
ButtonComponentProps,
|