@developer_tribe/react-builder 0.1.16 → 0.1.17

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.
@@ -56,6 +56,23 @@ function Field({
56
56
  />
57
57
  );
58
58
  }
59
+ if (type === 'string[]') {
60
+ const textValue = Array.isArray(value) ? value.join('\n') : '';
61
+ return (
62
+ <textarea
63
+ rows={4}
64
+ value={textValue}
65
+ onChange={(e) => {
66
+ const lines = e.target.value
67
+ .split('\n')
68
+ .map((s) => s.trim())
69
+ .filter((s) => s.length > 0);
70
+ onChange(lines.length > 0 ? lines : undefined);
71
+ }}
72
+ className="input"
73
+ />
74
+ );
75
+ }
59
76
  return (
60
77
  <input
61
78
  type="text"
@@ -25,17 +25,23 @@ export function RenderPage({
25
25
  localication,
26
26
  defaultLanguage,
27
27
  }: RenderPageProps) {
28
+ const screenPreviewHeight = 800;
29
+ // The calculation is correct for maintaining the aspect ratio of the target screen size.
30
+ // It scales the width proportionally to a fixed preview height.
31
+ // width = (previewHeight * targetWidth) / targetHeight
32
+ const height = screenPreviewHeight;
33
+ const width = (height * screenSize.width) / screenSize.height;
28
34
  return (
29
35
  <div className="stage-wrapper" style={{ overflow: 'auto' }}>
30
36
  <div
31
37
  className="stage"
32
38
  style={{
33
- width: screenSize.width,
34
- height: screenSize.height,
35
- minWidth: screenSize.width,
36
- maxWidth: screenSize.width,
37
- minHeight: screenSize.height,
38
- maxHeight: screenSize.height,
39
+ width: width,
40
+ height: height,
41
+ minWidth: width,
42
+ maxWidth: width,
43
+ minHeight: height,
44
+ maxHeight: height,
39
45
  overflow: 'hidden',
40
46
  position: 'relative',
41
47
  padding: 4,
@@ -1,8 +1,64 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import type { OnboardFooterComponentProps } from './OnboardFooterProps.generated';
3
+ import { mainNodeContext } from '../../RenderMainNode';
3
4
 
4
5
  function OnboardFooter({ node }: OnboardFooterComponentProps) {
5
- return String(node?.type ?? 'OnboardFooter');
6
+ const { localication, defaultLanguage } = useContext(mainNodeContext) ?? {};
7
+ const t = (key?: string) =>
8
+ key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
9
+
10
+ const text = t(node?.attributes?.textLocalizationKey);
11
+ const style: React.CSSProperties = {
12
+ display: 'flex',
13
+ flexDirection: (node?.attributes?.flexDirection as any) ?? 'column',
14
+ gap: typeof node?.attributes?.gap === 'number' ? node.attributes.gap : 0,
15
+ padding:
16
+ typeof node?.attributes?.padding === 'number'
17
+ ? node.attributes.padding
18
+ : undefined,
19
+ margin:
20
+ typeof node?.attributes?.margin === 'number'
21
+ ? node.attributes.margin
22
+ : undefined,
23
+ backgroundColor: node?.attributes?.backgroundColor,
24
+ borderRadius:
25
+ typeof node?.attributes?.borderRadius === 'number'
26
+ ? node.attributes.borderRadius
27
+ : undefined,
28
+ width:
29
+ typeof node?.attributes?.width === 'number'
30
+ ? node.attributes.width
31
+ : undefined,
32
+ height:
33
+ typeof node?.attributes?.height === 'number'
34
+ ? node.attributes.height
35
+ : undefined,
36
+ alignItems: node?.attributes?.alignItems as any,
37
+ justifyContent: node?.attributes?.justifyContent as any,
38
+ };
39
+
40
+ const linkStyle = (color?: string): React.CSSProperties => ({
41
+ color,
42
+ cursor: color ? 'pointer' : undefined,
43
+ });
44
+
45
+ return (
46
+ <div className="primitive primitive-footer" style={style}>
47
+ {!!text && <p style={{ color: node?.attributes?.textColor }}>{text}</p>}
48
+ <div style={{ display: 'flex', gap: 8 }}>
49
+ {node?.attributes?.linkedWordFirstLocalizationKey && (
50
+ <span style={linkStyle(node?.attributes?.linkedWordFirstColor)}>
51
+ {t(node?.attributes?.linkedWordFirstLocalizationKey)}
52
+ </span>
53
+ )}
54
+ {node?.attributes?.linkedWordSecondLocalizationKey && (
55
+ <span style={linkStyle(node?.attributes?.linkedWordSecondColor)}>
56
+ {t(node?.attributes?.linkedWordSecondLocalizationKey)}
57
+ </span>
58
+ )}
59
+ </div>
60
+ </div>
61
+ );
6
62
  }
7
63
 
8
64
  export default React.memo(OnboardFooter);
@@ -22,6 +22,14 @@ export interface OnboardFooterPropsGenerated {
22
22
  borderRadius?: number;
23
23
  width?: number;
24
24
  height?: number;
25
+ textLocalizationKey?: string;
26
+ textColor?: string;
27
+ linkedWordFirstLocalizationKey?: string;
28
+ linkedWordFirstColor?: string;
29
+ linkedWordFirstPage?: string;
30
+ linkedWordSecondLocalizationKey?: string;
31
+ linkedWordSecondColor?: string;
32
+ linkedWordSecondPage?: string;
25
33
  };
26
34
  }
27
35
 
@@ -22,7 +22,15 @@
22
22
  "backgroundColor": "string",
23
23
  "borderRadius": "number",
24
24
  "width": "number",
25
- "height": "number"
25
+ "height": "number",
26
+ "textLocalizationKey": "string",
27
+ "textColor": "string",
28
+ "linkedWordFirstLocalizationKey": "string",
29
+ "linkedWordFirstColor": "string",
30
+ "linkedWordFirstPage": "string",
31
+ "linkedWordSecondLocalizationKey": "string",
32
+ "linkedWordSecondColor": "string",
33
+ "linkedWordSecondPage": "string"
26
34
  }
27
35
  }
28
36
  }
@@ -112,3 +112,17 @@
112
112
  .embla__dot--selected:after {
113
113
  box-shadow: inset 0 0 0 0.2rem var(--text-body);
114
114
  }
115
+ .carousel-provider {
116
+ height: 100%;
117
+ }
118
+ .embla {
119
+ height: 100%;
120
+ }
121
+ .embla__viewport {
122
+ height: 100%;
123
+ display: flex;
124
+ flex-direction: column;
125
+ }
126
+ .embla__container {
127
+ flex: 1;
128
+ }
@@ -229,25 +229,56 @@ function mapFooterFromGeneralComponents(generalComponents: any[]): Node | null {
229
229
  const footer = generalComponents.find((gc) => gc?.layout === 'footer-layout');
230
230
  if (!footer) return null;
231
231
  const texts = (footer?.attributes?.texts || []) as any[];
232
- const children: Node[] = [];
232
+ const linkedWords: { text_key?: string; color?: string; page?: string }[] =
233
+ [];
234
+ let baseTextKey: string | undefined;
235
+ let baseTextColor: string | undefined;
233
236
 
234
237
  for (const t of texts) {
235
238
  if (t?.layout === 'Text') {
236
239
  const textKey = t?.attributes?.text_localization_key || '';
237
240
  const color = t?.attributes?.text_color || undefined;
238
- children.push({
239
- type: 'text',
240
- attributes: color ? { color } : undefined,
241
- children: textKey,
242
- });
241
+ if (!baseTextKey) baseTextKey = textKey;
242
+ if (!baseTextColor && typeof color === 'string') baseTextColor = color;
243
+
244
+ // Extract linked words if present
245
+ const lws = (t?.attributes?.linkedwords || []) as any[];
246
+ for (const w of lws) {
247
+ if (w?.layout === 'LinkedWords') {
248
+ const text_key = w?.attributes?.linked_word_localization_key as
249
+ | string
250
+ | undefined;
251
+ const lwColor = w?.attributes?.linked_word_color as
252
+ | string
253
+ | undefined;
254
+ const page = w?.attributes?.page as string | undefined;
255
+ linkedWords.push({ text_key, color: lwColor, page });
256
+ }
257
+ }
243
258
  }
244
259
  }
245
260
 
246
- if (children.length === 0) return null;
261
+ const attributes: Record<string, unknown> = { gap: 8 };
262
+ if (baseTextKey) attributes.textLocalizationKey = baseTextKey;
263
+ if (baseTextColor) attributes.textColor = baseTextColor;
264
+ const first = linkedWords[0];
265
+ const second = linkedWords[1];
266
+ if (first) {
267
+ if (first.text_key)
268
+ attributes.linkedWordFirstLocalizationKey = first.text_key;
269
+ if (first.color) attributes.linkedWordFirstColor = first.color;
270
+ if (first.page) attributes.linkedWordFirstPage = first.page;
271
+ }
272
+ if (second) {
273
+ if (second.text_key)
274
+ attributes.linkedWordSecondLocalizationKey = second.text_key;
275
+ if (second.color) attributes.linkedWordSecondColor = second.color;
276
+ if (second.page) attributes.linkedWordSecondPage = second.page;
277
+ }
247
278
 
248
279
  return {
249
280
  type: 'OnboardFooter',
250
- attributes: { gap: 8 },
251
- children,
281
+ attributes,
282
+ children: undefined as unknown as Node,
252
283
  } as NodeData;
253
284
  }