@developer_tribe/react-builder 0.1.27 → 0.1.28

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 (73) hide show
  1. package/dist/RenderPage.d.ts +13 -13
  2. package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +18 -4
  3. package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +6 -1
  4. package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +4 -0
  5. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +23 -1
  6. package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +23 -0
  7. package/dist/build-components/Text/TextProps.generated.d.ts +23 -0
  8. package/dist/build-components/View/ViewProps.generated.d.ts +15 -3
  9. package/dist/build-components/index.d.ts +1 -0
  10. package/dist/build-components/patterns.generated.d.ts +389 -0
  11. package/dist/index.cjs.js +28 -1
  12. package/dist/index.d.ts +1 -2
  13. package/dist/index.esm.js +28 -1
  14. package/dist/size-matters/index.d.ts +6 -0
  15. package/dist/store.d.ts +25 -0
  16. package/dist/styles.css +1 -1
  17. package/dist/types/PreviewConfig.d.ts +2 -0
  18. package/dist/utils/getDevices.d.ts +1 -0
  19. package/dist/utils/patterns.d.ts +3 -2
  20. package/package.json +2 -1
  21. package/scripts/prebuild/build-components.js +2 -0
  22. package/scripts/prebuild/utils/createBuildComponentsIndex.js +5 -1
  23. package/scripts/prebuild/utils/createPatternsGenerated.js +23 -0
  24. package/scripts/prebuild/utils/index.js +1 -0
  25. package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +126 -1
  26. package/src/RenderPage.tsx +33 -29
  27. package/src/build-components/Button/Button.tsx +2 -2
  28. package/src/build-components/Carousel/Carousel.tsx +2 -2
  29. package/src/build-components/CarouselButtons/CarouselButtons.tsx +2 -2
  30. package/src/build-components/CarouselDots/CarouselDots.tsx +2 -2
  31. package/src/build-components/CarouselItem/CarouselItem.tsx +2 -2
  32. package/src/build-components/CarouselProvider/CarouselProvider.tsx +2 -2
  33. package/src/build-components/Image/Image.tsx +2 -3
  34. package/src/build-components/Onboard/Onboard.tsx +2 -2
  35. package/src/build-components/OnboardButton/OnboardButton.tsx +7 -4
  36. package/src/build-components/OnboardButtons/OnboardButtons.tsx +14 -9
  37. package/src/build-components/OnboardDot/OnboardDot.tsx +2 -2
  38. package/src/build-components/OnboardFooter/OnboardFooter.tsx +22 -12
  39. package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +29 -4
  40. package/src/build-components/OnboardFooter/pattern.json +4 -19
  41. package/src/build-components/OnboardImage/OnboardImage.tsx +2 -2
  42. package/src/build-components/OnboardItem/OnboardItem.tsx +20 -19
  43. package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +6 -1
  44. package/src/build-components/OnboardItem/pattern.json +12 -1
  45. package/src/build-components/OnboardProvider/OnboardProvider.tsx +15 -12
  46. package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +4 -0
  47. package/src/build-components/OnboardProvider/pattern.json +11 -1
  48. package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +3 -17
  49. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +29 -1
  50. package/src/build-components/OnboardSubtitle/pattern.json +3 -19
  51. package/src/build-components/OnboardTitle/OnboardTitle.tsx +4 -17
  52. package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +29 -0
  53. package/src/build-components/OnboardTitle/pattern.json +5 -19
  54. package/src/build-components/Text/Text.tsx +21 -9
  55. package/src/build-components/Text/TextProps.generated.ts +29 -0
  56. package/src/build-components/Text/pattern.json +1 -0
  57. package/src/build-components/View/View.tsx +3 -3
  58. package/src/build-components/View/ViewProps.generated.ts +15 -3
  59. package/src/build-components/View/pattern.json +15 -3
  60. package/src/build-components/index.ts +2 -0
  61. package/src/build-components/patterns.generated.ts +502 -0
  62. package/src/build-components/useNode.ts +1 -0
  63. package/src/index.ts +1 -2
  64. package/src/size-matters/index.ts +64 -0
  65. package/src/store.ts +56 -0
  66. package/src/styles/_reset.scss +30 -0
  67. package/src/styles/index.scss +2 -0
  68. package/src/types/PreviewConfig.ts +2 -2
  69. package/src/utils/getDevices.ts +4 -0
  70. package/src/utils/novaToJson.ts +34 -4
  71. package/src/utils/patterns.ts +14 -45
  72. package/dist/RenderMainNode.d.ts +0 -16
  73. package/src/RenderMainNode.tsx +0 -37
@@ -1,7 +1,8 @@
1
- import React, { useContext } from 'react';
1
+ import React from 'react';
2
2
  import type { OnboardFooterComponentProps } from './OnboardFooterProps.generated';
3
- import { mainNodeContext } from '../../RenderMainNode';
4
- import useDefaults from '../useNode';
3
+ import useNode from '../useNode';
4
+ import { useRenderStore } from '../../store';
5
+ import { parseSize } from '../../size-matters';
5
6
 
6
7
  type Segment =
7
8
  | { type: 'text'; value: string }
@@ -84,9 +85,11 @@ function buildSegments(
84
85
  }
85
86
 
86
87
  function OnboardFooter({ node }: OnboardFooterComponentProps) {
87
- node = useDefaults(node);
88
- const { localication, defaultLanguage, setWarning } =
89
- useContext(mainNodeContext) ?? {};
88
+ node = useNode(node);
89
+ const { defaultLanguage, localication } = useRenderStore((s) => ({
90
+ defaultLanguage: s.defaultLanguage,
91
+ localication: s.localication,
92
+ }));
90
93
  const t = (key?: string) =>
91
94
  key ? (localication?.[defaultLanguage ?? 'en']?.[key] ?? key) : '';
92
95
 
@@ -125,8 +128,17 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
125
128
  cursor: color ? 'pointer' : undefined,
126
129
  });
127
130
 
131
+ const paddingHorizontal = parseSize(node?.attributes?.paddingHorizontal);
132
+ console.log('----', node?.attributes);
128
133
  return (
129
- <div className="primitive primitive-footer" style={style}>
134
+ <div
135
+ style={{
136
+ ...style,
137
+ paddingLeft: paddingHorizontal,
138
+ paddingRight: paddingHorizontal,
139
+ textAlign: 'center',
140
+ }}
141
+ >
130
142
  {!!text &&
131
143
  (() => {
132
144
  const firstText = t(node?.attributes?.linkedWordFirstLocalizationKey);
@@ -146,17 +158,15 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
146
158
  },
147
159
  ]);
148
160
 
149
- const textColor = node?.attributes?.textColor;
161
+ const textColor = node?.attributes?.color;
150
162
 
151
163
  const handleClick = (page?: string) => {
152
164
  if (!page) return;
153
- // Demo environment: surface intent via warning banner if available
154
- if (setWarning) setWarning(`Navigate to page: ${page}`);
155
165
  };
156
166
 
157
167
  return (
158
168
  <>
159
- <p style={{ color: textColor }}>
169
+ <p style={{ color: textColor, alignItems: 'center' }}>
160
170
  {segments.map((seg, i) =>
161
171
  seg.type === 'text' ? (
162
172
  <span key={i}>{seg.value}</span>
@@ -172,7 +182,7 @@ function OnboardFooter({ node }: OnboardFooterComponentProps) {
172
182
  )}
173
183
  </p>
174
184
  {matchCount === 0 && (
175
- <div style={{ display: 'flex', gap: 8 }}>
185
+ <div>
176
186
  {node?.attributes?.linkedWordFirstLocalizationKey && (
177
187
  <span
178
188
  style={linkStyle(node?.attributes?.linkedWordFirstColor)}
@@ -5,6 +5,20 @@ import type { NodeData } from '../../types/Node';
5
5
  export interface OnboardFooterPropsGenerated {
6
6
  child: string;
7
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';
8
22
  scrollable?: boolean;
9
23
  flexDirection?: 'row' | 'column';
10
24
  alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
@@ -15,15 +29,26 @@ export interface OnboardFooterPropsGenerated {
15
29
  | 'space-between'
16
30
  | 'space-around'
17
31
  | 'space-evenly';
18
- gap?: number;
32
+ gap?: string;
19
33
  padding?: number;
20
- margin?: number;
34
+ paddingHorizontal?: string;
35
+ paddingVertical?: string;
36
+ paddingTop?: string;
37
+ paddingBottom?: string;
38
+ paddingLeft?: string;
39
+ paddingRight?: string;
40
+ margin?: string;
41
+ marginHorizontal?: string;
42
+ marginVertical?: string;
43
+ marginTop?: string;
44
+ marginBottom?: string;
45
+ marginLeft?: string;
46
+ marginRight?: string;
21
47
  backgroundColor?: string;
22
- borderRadius?: number;
48
+ borderRadius?: string;
23
49
  width?: number;
24
50
  height?: number;
25
51
  textLocalizationKey?: string;
26
- textColor?: string;
27
52
  linkedWordFirstLocalizationKey?: string;
28
53
  linkedWordFirstColor?: string;
29
54
  linkedWordFirstPage?: string;
@@ -4,27 +4,9 @@
4
4
  "pattern": {
5
5
  "type": "OnboardFooter",
6
6
  "children": "node",
7
+ "extends": "Text",
7
8
  "attributes": {
8
- "scrollable": "boolean",
9
- "flexDirection": ["row", "column"],
10
- "alignItems": ["flex-start", "center", "flex-end", "stretch", "baseline"],
11
- "justifyContent": [
12
- "flex-start",
13
- "center",
14
- "flex-end",
15
- "space-between",
16
- "space-around",
17
- "space-evenly"
18
- ],
19
- "gap": "number",
20
- "padding": "number",
21
- "margin": "number",
22
- "backgroundColor": "string",
23
- "borderRadius": "number",
24
- "width": "number",
25
- "height": "number",
26
9
  "textLocalizationKey": "string",
27
- "textColor": "string",
28
10
  "linkedWordFirstLocalizationKey": "string",
29
11
  "linkedWordFirstColor": "string",
30
12
  "linkedWordFirstPage": "string",
@@ -32,5 +14,8 @@
32
14
  "linkedWordSecondColor": "string",
33
15
  "linkedWordSecondPage": "string"
34
16
  }
17
+ },
18
+ "defaults": {
19
+ "paddingHorizontal": "24@s"
35
20
  }
36
21
  }
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { OnboardImageComponentProps } from './OnboardImageProps.generated';
3
3
  import Image from '../Image/Image';
4
- import useDefaults from '../useNode';
4
+ import useNode from '../useNode';
5
5
 
6
6
  function OnboardImage({ node }: OnboardImageComponentProps) {
7
- node = useDefaults(node);
7
+ node = useNode(node);
8
8
  return <Image node={{ ...node, type: 'image' } as any} />;
9
9
  }
10
10
 
@@ -1,26 +1,27 @@
1
- import React, { useMemo } from 'react';
2
- import type { NodeData } from '../../types/Node';
1
+ import React from 'react';
3
2
  import type { OnboardItemComponentProps } from './OnboardItemProps.generated';
4
- import CarouselItem from '../CarouselItem/CarouselItem';
5
- import { isNodeArray } from '../../utils/analyseNode';
6
- import useDefaults from '../useNode';
3
+ import useNode from '../useNode';
4
+ import { RenderNode } from '../..';
5
+ import { parseSize } from '../../size-matters';
7
6
 
8
7
  function OnboardItem({ node }: OnboardItemComponentProps) {
9
- node = useDefaults(node);
10
- const children = useMemo(() => {
11
- return (
12
- (
13
- (isNodeArray(node.children)
14
- ? node.children
15
- : [node.children]) as NodeData[]
16
- )
17
- //NOTE: İstisna!! Onboard button carousel dışında olacak
18
- .filter((s) => (s as NodeData)?.type != 'OnboardButtons')
19
- );
20
- }, [node.children]) as NodeData[];
21
-
8
+ node = useNode(node);
9
+ const flexDirection = node.attributes?.flexDirection;
10
+ const display = node.attributes?.display;
11
+ const paddingHorizontal = parseSize(node.attributes?.paddingHorizontal);
22
12
  return (
23
- <CarouselItem node={{ ...node, type: 'carouselItem', children } as any} />
13
+ <div
14
+ className="embla__slide"
15
+ style={{
16
+ gap: parseSize(node.attributes?.gap),
17
+ flexDirection,
18
+ display,
19
+ paddingRight: paddingHorizontal,
20
+ paddingLeft: paddingHorizontal,
21
+ }}
22
+ >
23
+ {node.children && <RenderNode node={node.children} />}
24
+ </div>
24
25
  );
25
26
  }
26
27
 
@@ -4,7 +4,12 @@ import type { NodeData } from '../../types/Node';
4
4
 
5
5
  export interface OnboardItemPropsGenerated {
6
6
  child: string;
7
- attributes: {};
7
+ attributes: {
8
+ display?: 'flex' | 'block';
9
+ gap?: string;
10
+ flexDirection?: 'row' | 'column';
11
+ paddingHorizontal?: string;
12
+ };
8
13
  }
9
14
 
10
15
  export interface OnboardItemComponentProps {
@@ -4,6 +4,17 @@
4
4
  "pattern": {
5
5
  "type": "OnboardItem",
6
6
  "children": "node",
7
- "attributes": {}
7
+ "attributes": {
8
+ "display": ["flex", "block"],
9
+ "gap": "string",
10
+ "flexDirection": ["row", "column"],
11
+ "paddingHorizontal": "string"
12
+ }
13
+ },
14
+ "defaults": {
15
+ "gap": "16@vs",
16
+ "display": "flex",
17
+ "flexDirection": "column",
18
+ "paddingHorizontal": "24@s"
8
19
  }
9
20
  }
@@ -7,18 +7,17 @@ import React, {
7
7
  } from 'react';
8
8
  import type { NodeData } from '../../types/Node';
9
9
  import type { OnboardProviderComponentProps } from './OnboardProviderProps.generated';
10
- import { mainNodeContext } from '../../RenderMainNode';
11
10
  import useEmblaCarousel from 'embla-carousel-react';
12
11
  import RenderNode from '../RenderNode.generated';
13
- import { renderPageContext } from '../../RenderPage';
14
- import useDefaults from '../useNode';
12
+ import { useRenderStore } from '../../store';
13
+ import useNode from '../useNode';
15
14
 
16
15
  export const onboardContext = createContext<any>(undefined);
17
16
  function OnboardProvider({ node }: OnboardProviderComponentProps) {
18
- node = useDefaults(node);
19
- const { device } = useContext(renderPageContext) ?? {};
17
+ node = useNode(node);
18
+ console.log('node', node);
19
+ const device = useRenderStore((s) => s.device);
20
20
  const [emblaRef, emblaApi] = useEmblaCarousel(node.attributes as any);
21
- const { theme, setWarning } = useContext(mainNodeContext) ?? {};
22
21
  const [selectedIndex, setSelectedIndex] = useState(0);
23
22
 
24
23
  const children = useMemo(() => {
@@ -45,21 +44,25 @@ function OnboardProvider({ node }: OnboardProviderComponentProps) {
45
44
  });
46
45
  }, [emblaApi]);
47
46
 
48
- useEffect(() => {
47
+ /* useEffect(() => {
49
48
  if (theme !== (node.attributes as any)?.theme) {
50
49
  setWarning?.('Wrong theme');
51
50
  }
52
- }, [theme]);
51
+ }, [theme]);*/
53
52
 
54
53
  return (
55
54
  <onboardContext.Provider value={{ emblaApi, selectedIndex }}>
56
55
  <div
57
56
  className="carousel-provider"
58
57
  style={{
59
- paddingTop: device?.insets?.[0],
60
- paddingRight: device?.insets?.[1],
61
- paddingBottom: device?.insets?.[2],
62
- paddingLeft: device?.insets?.[3],
58
+ paddingTop:
59
+ device?.insets?.[0] + (node.attributes as any)?.paddingTop,
60
+ paddingRight:
61
+ device?.insets?.[1] + (node.attributes as any)?.paddingRight,
62
+ paddingBottom:
63
+ device?.insets?.[2] + (node.attributes as any)?.paddingBottom,
64
+ paddingLeft:
65
+ device?.insets?.[3] + (node.attributes as any)?.paddingLeft,
63
66
  }}
64
67
  >
65
68
  <div className="embla">
@@ -7,6 +7,10 @@ export interface OnboardProviderPropsGenerated {
7
7
  attributes: {
8
8
  theme?: string;
9
9
  use_safe_area_inset?: boolean;
10
+ paddingTop?: number;
11
+ paddingRight?: number;
12
+ paddingBottom?: number;
13
+ paddingLeft?: number;
10
14
  };
11
15
  }
12
16
 
@@ -6,7 +6,17 @@
6
6
  "children": "node",
7
7
  "attributes": {
8
8
  "theme": "string",
9
- "use_safe_area_inset": "boolean"
9
+ "use_safe_area_inset": "boolean",
10
+ "paddingTop": "number",
11
+ "paddingRight": "number",
12
+ "paddingBottom": "number",
13
+ "paddingLeft": "number"
10
14
  }
15
+ },
16
+ "defaults": {
17
+ "paddingTop": 0,
18
+ "paddingRight": 0,
19
+ "paddingBottom": 8,
20
+ "paddingLeft": 0
11
21
  }
12
22
  }
@@ -1,25 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { OnboardSubtitleComponentProps } from './OnboardSubtitleProps.generated';
3
3
  import Text from '../Text/Text';
4
- import useDefaults from '../useNode';
4
+ import useNode from '../useNode';
5
5
 
6
6
  function OnboardSubtitle({ node }: OnboardSubtitleComponentProps) {
7
- node = useDefaults(node);
8
- return (
9
- <Text
10
- node={
11
- {
12
- ...node,
13
- type: 'text',
14
- attributes: {
15
- fontSize: 14,
16
- fontWeight: '600',
17
- ...(node.attributes as any),
18
- },
19
- } as any
20
- }
21
- />
22
- );
7
+ node = useNode(node);
8
+ return <Text node={node} />;
23
9
  }
24
10
 
25
11
  export default React.memo(OnboardSubtitle);
@@ -7,7 +7,6 @@ export interface OnboardSubtitlePropsGenerated {
7
7
  attributes: {
8
8
  color?: string;
9
9
  fontSize?: number;
10
- textAlign?: 'left' | 'center' | 'right' | 'justify';
11
10
  fontWeight?:
12
11
  | 'normal'
13
12
  | 'bold'
@@ -20,6 +19,35 @@ export interface OnboardSubtitlePropsGenerated {
20
19
  | '700'
21
20
  | '800'
22
21
  | '900';
22
+ scrollable?: boolean;
23
+ flexDirection?: 'row' | 'column';
24
+ alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
25
+ justifyContent?:
26
+ | 'flex-start'
27
+ | 'center'
28
+ | 'flex-end'
29
+ | 'space-between'
30
+ | 'space-around'
31
+ | 'space-evenly';
32
+ gap?: string;
33
+ padding?: number;
34
+ paddingHorizontal?: string;
35
+ paddingVertical?: string;
36
+ paddingTop?: string;
37
+ paddingBottom?: string;
38
+ paddingLeft?: string;
39
+ paddingRight?: string;
40
+ margin?: string;
41
+ marginHorizontal?: string;
42
+ marginVertical?: string;
43
+ marginTop?: string;
44
+ marginBottom?: string;
45
+ marginLeft?: string;
46
+ marginRight?: string;
47
+ backgroundColor?: string;
48
+ borderRadius?: string;
49
+ width?: number;
50
+ height?: number;
23
51
  };
24
52
  }
25
53
 
@@ -4,27 +4,11 @@
4
4
  "pattern": {
5
5
  "type": "OnboardSubtitle",
6
6
  "children": "node",
7
- "attributes": {
8
- "color": "string",
9
- "fontSize": "number",
10
- "textAlign": ["left", "center", "right", "justify"],
11
- "fontWeight": [
12
- "normal",
13
- "bold",
14
- "100",
15
- "200",
16
- "300",
17
- "400",
18
- "500",
19
- "600",
20
- "700",
21
- "800",
22
- "900"
23
- ]
24
- }
7
+ "extends": "Text",
8
+ "attributes": {}
25
9
  },
26
10
  "defaults": {
27
- "fontSize": 14,
11
+ "fontSize": "14@fs",
28
12
  "fontWeight": "600"
29
13
  }
30
14
  }
@@ -1,25 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { OnboardTitleComponentProps } from './OnboardTitleProps.generated';
3
3
  import Text from '../Text/Text';
4
- import useDefaults from '../useNode';
4
+ import useNode from '../useNode';
5
5
 
6
6
  function OnboardTitle({ node }: OnboardTitleComponentProps) {
7
- node = useDefaults(node);
8
- return (
9
- <Text
10
- node={
11
- {
12
- ...node,
13
- type: 'text',
14
- attributes: {
15
- fontSize: 24,
16
- fontWeight: '700',
17
- ...(node.attributes as any),
18
- },
19
- } as any
20
- }
21
- />
22
- );
7
+ node = useNode(node);
8
+ console.log('node', node);
9
+ return <Text node={node} />;
23
10
  }
24
11
 
25
12
  export default React.memo(OnboardTitle);
@@ -19,6 +19,35 @@ export interface OnboardTitlePropsGenerated {
19
19
  | '700'
20
20
  | '800'
21
21
  | '900';
22
+ scrollable?: boolean;
23
+ flexDirection?: 'row' | 'column';
24
+ alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
25
+ justifyContent?:
26
+ | 'flex-start'
27
+ | 'center'
28
+ | 'flex-end'
29
+ | 'space-between'
30
+ | 'space-around'
31
+ | 'space-evenly';
32
+ gap?: string;
33
+ padding?: number;
34
+ paddingHorizontal?: string;
35
+ paddingVertical?: string;
36
+ paddingTop?: string;
37
+ paddingBottom?: string;
38
+ paddingLeft?: string;
39
+ paddingRight?: string;
40
+ margin?: string;
41
+ marginHorizontal?: string;
42
+ marginVertical?: string;
43
+ marginTop?: string;
44
+ marginBottom?: string;
45
+ marginLeft?: string;
46
+ marginRight?: string;
47
+ backgroundColor?: string;
48
+ borderRadius?: string;
49
+ width?: number;
50
+ height?: number;
22
51
  };
23
52
  }
24
53
 
@@ -4,26 +4,12 @@
4
4
  "pattern": {
5
5
  "type": "OnboardTitle",
6
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
- }
7
+ "extends": "Text",
8
+ "attributes": {}
24
9
  },
25
10
  "defaults": {
26
- "fontSize": 24,
27
- "fontWeight": "700"
11
+ "fontSize": "24@fs",
12
+ "fontWeight": "700",
13
+ "textAlign": "center"
28
14
  }
29
15
  }
@@ -1,17 +1,29 @@
1
- import React, { useContext } from 'react';
1
+ import React from 'react';
2
2
  import type { TextComponentProps } from './TextProps.generated';
3
- import { mainNodeContext } from '../../RenderMainNode';
4
- import useDefaults from '../useNode';
3
+ import useNode from '../useNode';
4
+ import { useRenderStore } from '../../store';
5
+ import { fs, parseSize } from '../../size-matters';
5
6
 
6
7
  function Text({ node }: TextComponentProps) {
7
- node = useDefaults(node);
8
- const { localication, defaultLanguage } = useContext(mainNodeContext) ?? {};
8
+ node = useNode(node);
9
+ const { screenStyle, theme } = useRenderStore((s) => ({
10
+ screenStyle: s.screenStyle,
11
+ theme: s.theme,
12
+ }));
13
+ const color =
14
+ theme === 'light' ? screenStyle.light.color : screenStyle.dark.color;
15
+ const { defaultLanguage, localication } = useRenderStore((s) => ({
16
+ defaultLanguage: s.defaultLanguage,
17
+ localication: s.localication,
18
+ }));
9
19
  const keyOrText: string = node.children as string;
20
+ const style = (node.attributes as React.CSSProperties) ?? {};
21
+ const fontSize = node.attributes?.fontSize
22
+ ? parseSize(node.attributes.fontSize)
23
+ : fs(14);
24
+
10
25
  return (
11
- <p
12
- style={node.attributes as React.CSSProperties}
13
- className="primitive primitive-text"
14
- >
26
+ <p style={{ ...style, fontSize, color: style.color ?? color }}>
15
27
  {localication?.[defaultLanguage ?? 'en']?.[keyOrText] ?? keyOrText}
16
28
  </p>
17
29
  );
@@ -5,6 +5,35 @@ import type { NodeData } from '../../types/Node';
5
5
  export interface TextPropsGenerated {
6
6
  child: string;
7
7
  attributes: {
8
+ scrollable?: boolean;
9
+ flexDirection?: 'row' | 'column';
10
+ alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
11
+ justifyContent?:
12
+ | 'flex-start'
13
+ | 'center'
14
+ | 'flex-end'
15
+ | 'space-between'
16
+ | 'space-around'
17
+ | 'space-evenly';
18
+ gap?: string;
19
+ padding?: number;
20
+ paddingHorizontal?: string;
21
+ paddingVertical?: string;
22
+ paddingTop?: string;
23
+ paddingBottom?: string;
24
+ paddingLeft?: string;
25
+ paddingRight?: string;
26
+ margin?: string;
27
+ marginHorizontal?: string;
28
+ marginVertical?: string;
29
+ marginTop?: string;
30
+ marginBottom?: string;
31
+ marginLeft?: string;
32
+ marginRight?: string;
33
+ backgroundColor?: string;
34
+ borderRadius?: string;
35
+ width?: number;
36
+ height?: number;
8
37
  color?: string;
9
38
  fontSize?: number;
10
39
  fontWeight?:
@@ -4,6 +4,7 @@
4
4
  "pattern": {
5
5
  "type": "text",
6
6
  "children": "string",
7
+ "extends": "View",
7
8
  "attributes": {
8
9
  "color": "string",
9
10
  "fontSize": "number",
@@ -5,7 +5,7 @@ import type {
5
5
  } from './ViewProps.generated';
6
6
  import RenderNode from '../RenderNode.generated';
7
7
  import { Node } from '../../types/Node';
8
- import useDefaults from '../useNode';
8
+ import useNode from '../useNode';
9
9
 
10
10
  function mapAttributesToStyle(
11
11
  attributes: ViewPropsGenerated['attributes'],
@@ -49,11 +49,11 @@ function mapAttributesToStyle(
49
49
  }
50
50
 
51
51
  export function View({ node }: ViewComponentProps) {
52
- node = useDefaults(node);
52
+ node = useNode(node);
53
53
  return (
54
54
  <div
55
55
  style={mapAttributesToStyle(node.attributes ?? {})}
56
- className="primitive primitive-view"
56
+ className="scroll-container"
57
57
  >
58
58
  <RenderNode node={node.children as Node} />
59
59
  </div>