@developer_tribe/react-builder 1.0.1 → 1.0.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/dist/DeviceMockFrame.d.ts +2 -1
- package/dist/RenderPage.d.ts +4 -3
- package/dist/attributes-editor/Field.d.ts +16 -0
- package/dist/attributes-editor/FieldInfoTooltip.d.ts +7 -0
- package/dist/attributes-editor/LayoutPreviewPicker.d.ts +12 -0
- package/dist/attributes-editor/SpecialCategorySection.d.ts +19 -0
- package/dist/attributes-editor/types.d.ts +14 -0
- package/dist/background.jpg +0 -0
- package/dist/build-components/Button/Button.d.ts +1 -1
- package/dist/build-components/Button/ButtonProps.generated.d.ts +26 -1
- package/dist/build-components/Carousel/CarouselProps.generated.d.ts +27 -1
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.generated.d.ts +25 -0
- package/dist/build-components/CarouselDots/CarouselDotsProps.generated.d.ts +25 -0
- package/dist/build-components/CarouselItem/CarouselItemProps.generated.d.ts +27 -1
- package/dist/build-components/CarouselProvider/CarouselProviderProps.generated.d.ts +27 -1
- package/dist/build-components/Image/ImageProps.generated.d.ts +25 -3
- package/dist/build-components/Onboard/OnboardProps.generated.d.ts +27 -1
- package/dist/build-components/OnboardButton/OnboardButtonProps.generated.d.ts +25 -0
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.generated.d.ts +25 -0
- package/dist/build-components/OnboardDot/OnboardDot.d.ts +1 -1
- package/dist/build-components/OnboardDot/OnboardDotProps.generated.d.ts +22 -0
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +4 -5
- package/dist/build-components/OnboardImage/OnboardImageProps.generated.d.ts +25 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.generated.d.ts +24 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.generated.d.ts +25 -4
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +4 -5
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +4 -5
- package/dist/build-components/Text/TextProps.generated.d.ts +4 -5
- package/dist/build-components/View/ViewProps.generated.d.ts +3 -4
- package/dist/build-components/patterns.generated.d.ts +4855 -132
- package/dist/components/Breadcrumb.d.ts +3 -1
- package/dist/components/Checkbox.d.ts +17 -0
- package/dist/components/DeviceButton.d.ts +8 -0
- package/dist/components/DeviceNavigationBar.d.ts +10 -0
- package/dist/components/DeviceStatusBar.d.ts +9 -0
- package/dist/components/EditorHeader.d.ts +3 -8
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +5 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/mockOS/components/MockLaunchScreenComponent.d.ts +6 -0
- package/dist/mockOS/components/MockOSRouter.d.ts +8 -0
- package/dist/mockOS/components/PermissionModal.d.ts +9 -0
- package/dist/mockOS/context/MockOSContext.d.ts +36 -0
- package/dist/mockOS/hooks/useMockNavigation.d.ts +3 -0
- package/dist/mockOS/hooks/useMockPermission.d.ts +3 -0
- package/dist/mockOS/index.d.ts +9 -0
- package/dist/mockOS/managers/mockPermissionManager.d.ts +10 -0
- package/dist/mockOS/managers/navigationManager.d.ts +17 -0
- package/dist/modals/AddComponentModal.d.ts +8 -0
- package/dist/modals/ColorModal.d.ts +9 -0
- package/dist/modals/DeviceSelectorModal.d.ts +9 -0
- package/dist/modals/LocalicationModal.d.ts +8 -0
- package/dist/modals/Modal.d.ts +12 -0
- package/dist/modals/index.d.ts +5 -0
- package/dist/pages/ProjectPage.d.ts +1 -1
- package/dist/store.d.ts +0 -2
- package/dist/styles.css +1 -1
- package/dist/utils/patterns.d.ts +24 -0
- package/package.json +2 -1
- package/scripts/prebuild/utils/createGeneratedProps.js +11 -3
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +45 -6
- package/scripts/prebuild/utils/validatePatternJson.js +13 -5
- package/src/AttributesEditor.tsx +433 -312
- package/src/DeviceMockFrame.tsx +21 -37
- package/src/RenderPage.tsx +5 -4
- package/src/assets/images/android.svg +42 -42
- package/src/assets/images/apple.svg +15 -15
- package/src/attributes-editor/Field.tsx +662 -0
- package/src/attributes-editor/FieldInfoTooltip.tsx +49 -0
- package/src/attributes-editor/LayoutPreviewPicker.tsx +199 -0
- package/src/attributes-editor/SpecialCategorySection.tsx +284 -0
- package/src/attributes-editor/types.ts +30 -0
- package/src/build-components/Button/Button.tsx +10 -2
- package/src/build-components/Button/ButtonProps.generated.ts +37 -1
- package/src/build-components/Button/pattern.json +31 -2
- package/src/build-components/Carousel/Carousel.tsx +15 -2
- package/src/build-components/Carousel/CarouselProps.generated.ts +39 -1
- package/src/build-components/Carousel/pattern.json +10 -0
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +6 -2
- package/src/build-components/CarouselButtons/CarouselButtonsProps.generated.ts +36 -0
- package/src/build-components/CarouselButtons/pattern.json +22 -0
- package/src/build-components/CarouselDots/CarouselDots.tsx +40 -8
- package/src/build-components/CarouselDots/CarouselDotsProps.generated.ts +36 -0
- package/src/build-components/CarouselDots/pattern.json +15 -0
- package/src/build-components/CarouselItem/CarouselItem.tsx +5 -2
- package/src/build-components/CarouselItem/CarouselItemProps.generated.ts +39 -1
- package/src/build-components/CarouselItem/pattern.json +7 -0
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +10 -2
- package/src/build-components/CarouselProvider/CarouselProviderProps.generated.ts +39 -1
- package/src/build-components/CarouselProvider/pattern.json +7 -0
- package/src/build-components/Image/Image.tsx +8 -2
- package/src/build-components/Image/ImageProps.generated.ts +36 -3
- package/src/build-components/Image/pattern.json +46 -3
- package/src/build-components/Onboard/Onboard.tsx +6 -1
- package/src/build-components/Onboard/OnboardProps.generated.ts +39 -1
- package/src/build-components/Onboard/pattern.json +11 -0
- package/src/build-components/OnboardButton/OnboardButton.tsx +46 -5
- package/src/build-components/OnboardButton/OnboardButtonProps.generated.ts +36 -0
- package/src/build-components/OnboardButton/pattern.json +71 -5
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +20 -10
- package/src/build-components/OnboardButtons/OnboardButtonsProps.generated.ts +36 -0
- package/src/build-components/OnboardButtons/pattern.json +70 -4
- package/src/build-components/OnboardDot/OnboardDot.tsx +104 -4
- package/src/build-components/OnboardDot/OnboardDotProps.generated.ts +22 -0
- package/src/build-components/OnboardDot/pattern.json +54 -1
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +9 -3
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +4 -5
- package/src/build-components/OnboardFooter/pattern.json +58 -2
- package/src/build-components/OnboardImage/OnboardImage.tsx +27 -5
- package/src/build-components/OnboardImage/OnboardImageProps.generated.ts +36 -3
- package/src/build-components/OnboardImage/pattern.json +21 -0
- package/src/build-components/OnboardItem/OnboardItem.tsx +6 -1
- package/src/build-components/OnboardItem/OnboardItemProps.generated.ts +35 -3
- package/src/build-components/OnboardItem/pattern.json +38 -2
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +20 -8
- package/src/build-components/OnboardProvider/OnboardProviderProps.generated.ts +37 -4
- package/src/build-components/OnboardProvider/pattern.json +51 -4
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +4 -5
- package/src/build-components/OnboardSubtitle/pattern.json +6 -0
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +4 -5
- package/src/build-components/OnboardTitle/pattern.json +6 -0
- package/src/build-components/Text/Text.tsx +7 -3
- package/src/build-components/Text/TextProps.generated.ts +4 -5
- package/src/build-components/Text/pattern.json +38 -2
- package/src/build-components/View/View.tsx +9 -6
- package/src/build-components/View/ViewProps.generated.ts +3 -4
- package/src/build-components/View/pattern.json +227 -19
- package/src/build-components/patterns.generated.ts +4905 -139
- package/src/components/AttributesEditorPanel.tsx +7 -61
- package/src/components/Breadcrumb.tsx +37 -5
- package/src/components/Builder.tsx +180 -77
- package/src/components/Checkbox.tsx +81 -0
- package/src/components/DeviceButton.tsx +39 -0
- package/src/components/DeviceNavigationBar.tsx +201 -0
- package/src/components/DeviceStatusBar.tsx +85 -0
- package/src/components/EditorHeader.tsx +26 -74
- package/src/mockOS/components/MockLaunchScreenComponent.tsx +43 -0
- package/src/mockOS/components/MockOSRouter.tsx +115 -0
- package/src/mockOS/components/PermissionModal.tsx +270 -0
- package/src/mockOS/context/MockOSContext.tsx +179 -0
- package/src/mockOS/hooks/useMockNavigation.ts +11 -0
- package/src/mockOS/hooks/useMockPermission.ts +11 -0
- package/src/mockOS/index.ts +26 -0
- package/src/mockOS/managers/mockPermissionManager.ts +54 -0
- package/src/mockOS/managers/navigationManager.ts +91 -0
- package/src/modals/AddComponentModal.tsx +313 -0
- package/src/modals/ColorModal.tsx +268 -0
- package/src/modals/DeviceSelectorModal.tsx +57 -0
- package/src/modals/LocalicationModal.tsx +54 -0
- package/src/modals/Modal.tsx +57 -0
- package/src/modals/index.ts +5 -0
- package/src/pages/ProjectPage.tsx +19 -21
- package/src/pages/tabs/DebugTab.tsx +50 -9
- package/src/pages/tabs/PreviewTab.tsx +52 -40
- package/src/size-matters/index.ts +21 -5
- package/src/store.ts +0 -4
- package/src/styles/{global.scss → base/_global.scss} +92 -39
- package/src/styles/components/_attributes-editor.scss +261 -0
- package/src/styles/{editor.scss → components/_editor-shell.scss} +72 -57
- package/src/styles/components/_mockos-router.scss +140 -0
- package/src/styles/components/_ui-components.scss +183 -0
- package/src/styles/foundation/_colors.scss +8 -0
- package/src/styles/{_mixins.scss → foundation/_mixins.scss} +5 -4
- package/src/styles/{_reset.scss → foundation/_reset.scss} +5 -2
- package/src/styles/foundation/_sizes.scss +37 -0
- package/src/styles/foundation/_typography.scss +4 -0
- package/src/styles/foundation/_variables.scss +3 -0
- package/src/styles/index.scss +22 -136
- package/src/styles/layout/_builder.scss +68 -0
- package/src/styles/layout/_pages.scss +3 -0
- package/src/styles/modals/_add-component.scss +122 -0
- package/src/styles/modals/_color-modal.scss +130 -0
- package/src/styles/modals/_device-selector.scss +18 -0
- package/src/styles/modals/_localication-modal.scss +68 -0
- package/src/styles/modals/_modal-shell.scss +46 -0
- package/src/styles/utilities/_carousel.scss +125 -0
- package/src/types/images.d.ts +8 -0
- package/src/utils/extractTextStyle.ts +4 -2
- package/src/utils/extractViewStyle.ts +51 -7
- package/src/utils/patterns.ts +33 -0
- package/dist/build-components/OnboardDot/OnboardExpandingDotProps.generated.d.ts +0 -10
- package/src/build-components/OnboardDot/OnboardExpandingDotProps.generated.ts +0 -20
- package/src/styles/_variables.scss +0 -27
- package/src/styles/builder.scss +0 -60
- package/src/styles/components.scss +0 -88
- package/src/styles/pages.scss +0 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Device } from '../types/Device';
|
|
3
|
+
import { useMockOSContext } from '../mockOS';
|
|
4
|
+
|
|
5
|
+
type DeviceNavigationBarProps = {
|
|
6
|
+
height: number;
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
platform?: Device['platform'];
|
|
9
|
+
navigationBarType?: Device['navigationBarType'];
|
|
10
|
+
isDark: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const basePillStyle: React.CSSProperties = {
|
|
14
|
+
height: 5,
|
|
15
|
+
borderRadius: 999,
|
|
16
|
+
width: 120,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const tabItems = ['Today', 'Search', 'Profile'];
|
|
20
|
+
|
|
21
|
+
export function DeviceNavigationBar({
|
|
22
|
+
height,
|
|
23
|
+
backgroundColor,
|
|
24
|
+
platform = 'android',
|
|
25
|
+
navigationBarType = 'gesture',
|
|
26
|
+
isDark,
|
|
27
|
+
}: DeviceNavigationBarProps) {
|
|
28
|
+
const context = useMockOSContext();
|
|
29
|
+
|
|
30
|
+
if (!height) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const barColor = isDark ? 'rgba(255, 255, 255, 0.85)' : 'rgba(0, 0, 0, 0.7)';
|
|
35
|
+
const mutedColor = isDark
|
|
36
|
+
? 'rgba(255, 255, 255, 0.55)'
|
|
37
|
+
: 'rgba(0, 0, 0, 0.4)';
|
|
38
|
+
|
|
39
|
+
function handleBackButton() {
|
|
40
|
+
console.log('handleBackButton', context);
|
|
41
|
+
if (context) {
|
|
42
|
+
const canGoBack = context.goBack();
|
|
43
|
+
// If can't go back, go to launchscreen
|
|
44
|
+
if (!canGoBack) {
|
|
45
|
+
context.navigation('launchscreen');
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
alert('Navigation: Back\n(Mock OS context not available)');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handleHomeButton() {
|
|
53
|
+
if (context) {
|
|
54
|
+
context.navigation('launchscreen');
|
|
55
|
+
} else {
|
|
56
|
+
alert('Navigation: Home\n(Mock OS context not available)');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const containerStyle: React.CSSProperties = {
|
|
61
|
+
height,
|
|
62
|
+
backgroundColor,
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
padding: '0 16px',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (platform === 'ios') {
|
|
70
|
+
switch (navigationBarType) {
|
|
71
|
+
case 'homeIndicator':
|
|
72
|
+
return (
|
|
73
|
+
<div className="device-navigation-bar" style={containerStyle}>
|
|
74
|
+
<div
|
|
75
|
+
style={{
|
|
76
|
+
...basePillStyle,
|
|
77
|
+
backgroundColor: barColor,
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
case 'tabBar':
|
|
83
|
+
return (
|
|
84
|
+
<div className="device-navigation-bar" style={containerStyle}>
|
|
85
|
+
<div
|
|
86
|
+
style={{
|
|
87
|
+
display: 'flex',
|
|
88
|
+
width: '100%',
|
|
89
|
+
maxWidth: 280,
|
|
90
|
+
justifyContent: 'space-between',
|
|
91
|
+
fontSize: 11,
|
|
92
|
+
textTransform: 'uppercase',
|
|
93
|
+
letterSpacing: 0.4,
|
|
94
|
+
gap: 20,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{tabItems.map((item) => (
|
|
98
|
+
<div
|
|
99
|
+
key={item}
|
|
100
|
+
style={{
|
|
101
|
+
display: 'flex',
|
|
102
|
+
flexDirection: 'column',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
gap: 4,
|
|
105
|
+
color: item === 'Today' ? barColor : mutedColor,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<div
|
|
109
|
+
style={{
|
|
110
|
+
width: 20,
|
|
111
|
+
height: 20,
|
|
112
|
+
borderRadius: 6,
|
|
113
|
+
backgroundColor: item === 'Today' ? barColor : mutedColor,
|
|
114
|
+
opacity: 0.9,
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
<span>{item}</span>
|
|
118
|
+
</div>
|
|
119
|
+
))}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
default:
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Android styles
|
|
129
|
+
if (navigationBarType === 'threeButtons') {
|
|
130
|
+
const buttonStyle: React.CSSProperties = {
|
|
131
|
+
position: 'relative',
|
|
132
|
+
width: 40,
|
|
133
|
+
height: 40,
|
|
134
|
+
display: 'flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
fontSize: 18,
|
|
138
|
+
color: barColor,
|
|
139
|
+
cursor: 'pointer',
|
|
140
|
+
userSelect: 'none',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div className="device-navigation-bar" style={containerStyle}>
|
|
145
|
+
<div
|
|
146
|
+
style={{
|
|
147
|
+
display: 'flex',
|
|
148
|
+
gap: 64,
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<div
|
|
152
|
+
style={{ ...buttonStyle, fontSize: 24 }}
|
|
153
|
+
onClick={handleBackButton}
|
|
154
|
+
role="button"
|
|
155
|
+
aria-label="Back"
|
|
156
|
+
>
|
|
157
|
+
◁
|
|
158
|
+
</div>
|
|
159
|
+
<div
|
|
160
|
+
style={{ ...buttonStyle, fontSize: 32, top: -3 }}
|
|
161
|
+
onClick={handleHomeButton}
|
|
162
|
+
role="button"
|
|
163
|
+
aria-label="Home"
|
|
164
|
+
>
|
|
165
|
+
⌂
|
|
166
|
+
</div>
|
|
167
|
+
<div
|
|
168
|
+
style={{
|
|
169
|
+
...buttonStyle,
|
|
170
|
+
fontSize: 20,
|
|
171
|
+
fontWeight: 1000,
|
|
172
|
+
}}
|
|
173
|
+
onClick={handleHomeButton}
|
|
174
|
+
role="button"
|
|
175
|
+
aria-label="Recent Apps"
|
|
176
|
+
>
|
|
177
|
+
▢
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (navigationBarType === 'gesture') {
|
|
185
|
+
return (
|
|
186
|
+
<div className="device-navigation-bar" style={containerStyle}>
|
|
187
|
+
<div
|
|
188
|
+
style={{
|
|
189
|
+
...basePillStyle,
|
|
190
|
+
width: 90,
|
|
191
|
+
backgroundColor: barColor,
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default DeviceNavigationBar;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Device } from '../types/Device';
|
|
3
|
+
|
|
4
|
+
type DeviceStatusBarProps = {
|
|
5
|
+
height: number;
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
platform?: Device['platform'];
|
|
8
|
+
isDark: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const formatTime = () =>
|
|
12
|
+
new Date().toLocaleTimeString([], {
|
|
13
|
+
hour: '2-digit',
|
|
14
|
+
minute: '2-digit',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const iosIndicators = ['5G', 'Wi-Fi', '92%'];
|
|
18
|
+
const androidIndicators = ['Alarm', 'Wi-Fi', '84%'];
|
|
19
|
+
|
|
20
|
+
export function DeviceStatusBar({
|
|
21
|
+
height,
|
|
22
|
+
backgroundColor,
|
|
23
|
+
platform = 'android',
|
|
24
|
+
isDark,
|
|
25
|
+
}: DeviceStatusBarProps) {
|
|
26
|
+
const [time, setTime] = useState(() => formatTime());
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const intervalId = setInterval(() => setTime(formatTime()), 60_000);
|
|
30
|
+
return () => clearInterval(intervalId);
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
const textColor = isDark ? 'rgb(255, 255, 255)' : 'rgb(0, 0, 0)';
|
|
34
|
+
const iconStyle: React.CSSProperties = {
|
|
35
|
+
fontSize: 10,
|
|
36
|
+
letterSpacing: 0.5,
|
|
37
|
+
textTransform: 'uppercase',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const containerStyle: React.CSSProperties = {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
right: 0,
|
|
45
|
+
height,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
color: textColor,
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
fontSize: 12,
|
|
51
|
+
fontWeight: 500,
|
|
52
|
+
padding: '0 12px',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (platform === 'ios') {
|
|
56
|
+
return (
|
|
57
|
+
<div className="device-status-bar" style={containerStyle}>
|
|
58
|
+
<span style={{ fontWeight: 600 }}>{time}</span>
|
|
59
|
+
<div style={{ flex: 1 }} />
|
|
60
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
61
|
+
{iosIndicators.map((indicator) => (
|
|
62
|
+
<span key={indicator} style={iconStyle}>
|
|
63
|
+
{indicator}
|
|
64
|
+
</span>
|
|
65
|
+
))}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className="device-status-bar" style={containerStyle}>
|
|
73
|
+
<span style={{ flex: 1 }}>{time}</span>
|
|
74
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
75
|
+
{androidIndicators.map((indicator) => (
|
|
76
|
+
<span key={indicator} style={iconStyle}>
|
|
77
|
+
{indicator}
|
|
78
|
+
</span>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default DeviceStatusBar;
|
|
@@ -1,41 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useState } from 'react';
|
|
2
2
|
import { Device, getDevices, Node, copyNode } from '..';
|
|
3
3
|
import { useRenderStore } from '../store';
|
|
4
|
-
import { Breadcrumb, BreadcrumbItem } from './Breadcrumb';
|
|
5
4
|
import { useLogRender } from '../utils/useLogRender';
|
|
5
|
+
import { DeviceButton } from './DeviceButton';
|
|
6
|
+
import { DeviceSelectorModal } from '../modals/DeviceSelectorModal';
|
|
6
7
|
|
|
7
8
|
const devices = getDevices();
|
|
8
|
-
|
|
9
9
|
interface EditorHeaderProps {
|
|
10
10
|
onSaveProject?: () => void;
|
|
11
|
+
onRestoreProject?: () => void;
|
|
11
12
|
current?: Node;
|
|
12
13
|
editorData?: Node;
|
|
13
14
|
setEditorData?: (data: Node) => void;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
interface DeviceButtonProps {
|
|
17
|
-
device: Device;
|
|
18
|
-
selectedDevice: Device | null;
|
|
19
|
-
setSelectedDevice: (device: Device) => void;
|
|
20
|
-
}
|
|
21
|
-
export function DeviceButton({
|
|
22
|
-
device,
|
|
23
|
-
selectedDevice,
|
|
24
|
-
setSelectedDevice,
|
|
25
|
-
}: DeviceButtonProps) {
|
|
26
|
-
return (
|
|
27
|
-
<button
|
|
28
|
-
className={`editor-device-button ${selectedDevice === device ? 'editor-device-button--selected' : ''}`}
|
|
29
|
-
onClick={() => setSelectedDevice(device)}
|
|
30
|
-
>
|
|
31
|
-
{device.name} <br />
|
|
32
|
-
{device.width}x{device.height}
|
|
33
|
-
</button>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
17
|
export function EditorHeader({
|
|
38
18
|
onSaveProject,
|
|
19
|
+
onRestoreProject,
|
|
39
20
|
current,
|
|
40
21
|
editorData,
|
|
41
22
|
setEditorData,
|
|
@@ -43,7 +24,7 @@ export function EditorHeader({
|
|
|
43
24
|
useLogRender('EditorHeader');
|
|
44
25
|
const [isDevicesModalOpen, setIsDevicesModalOpen] = useState(false);
|
|
45
26
|
const copiedNode = useRenderStore((s) => s.copiedNode);
|
|
46
|
-
const { device, setDevice } = useRenderStore((s) => ({
|
|
27
|
+
const { device: selectedDevice, setDevice } = useRenderStore((s) => ({
|
|
47
28
|
device: s.device,
|
|
48
29
|
setDevice: s.setDevice,
|
|
49
30
|
}));
|
|
@@ -85,7 +66,6 @@ export function EditorHeader({
|
|
|
85
66
|
useRenderStore.setState({
|
|
86
67
|
copiedNode: null,
|
|
87
68
|
});
|
|
88
|
-
useRenderStore.getState().forceRender();
|
|
89
69
|
setEditorData(updated);
|
|
90
70
|
};
|
|
91
71
|
return (
|
|
@@ -95,12 +75,12 @@ export function EditorHeader({
|
|
|
95
75
|
aria-label="Editor utility header"
|
|
96
76
|
>
|
|
97
77
|
<div className="editor-header__devices">
|
|
98
|
-
{devices.slice(0, 5).map((
|
|
78
|
+
{devices.slice(0, 5).map((deviceOption: Device) => (
|
|
99
79
|
<DeviceButton
|
|
100
|
-
key={
|
|
101
|
-
selectedDevice={
|
|
102
|
-
|
|
103
|
-
device={
|
|
80
|
+
key={deviceOption.name}
|
|
81
|
+
selectedDevice={selectedDevice}
|
|
82
|
+
onSelect={setDevice}
|
|
83
|
+
device={deviceOption}
|
|
104
84
|
/>
|
|
105
85
|
))}
|
|
106
86
|
<button
|
|
@@ -119,13 +99,15 @@ export function EditorHeader({
|
|
|
119
99
|
>
|
|
120
100
|
Save
|
|
121
101
|
</button>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
102
|
+
{onRestoreProject && (
|
|
103
|
+
<button
|
|
104
|
+
className="editor-button editor-save-previewconfig-button"
|
|
105
|
+
aria-label="Restore project data"
|
|
106
|
+
onClick={() => onRestoreProject()}
|
|
107
|
+
>
|
|
108
|
+
Restore
|
|
109
|
+
</button>
|
|
110
|
+
)}
|
|
129
111
|
<button
|
|
130
112
|
className="editor-button"
|
|
131
113
|
aria-label="Copy node"
|
|
@@ -144,42 +126,12 @@ export function EditorHeader({
|
|
|
144
126
|
)}
|
|
145
127
|
</div>
|
|
146
128
|
{isDevicesModalOpen && (
|
|
147
|
-
<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
<div
|
|
154
|
-
className="editor-modal__overlay"
|
|
155
|
-
onClick={() => setIsDevicesModalOpen(false)}
|
|
156
|
-
/>
|
|
157
|
-
<div className="editor-modal__content">
|
|
158
|
-
<div className="editor-modal__header">
|
|
159
|
-
<h3 id="device-selector-title">Select a device</h3>
|
|
160
|
-
<button
|
|
161
|
-
className="editor-button"
|
|
162
|
-
aria-label="Close device selector"
|
|
163
|
-
onClick={() => setIsDevicesModalOpen(false)}
|
|
164
|
-
>
|
|
165
|
-
Close
|
|
166
|
-
</button>
|
|
167
|
-
</div>
|
|
168
|
-
<div className="editor-device-grid" role="list">
|
|
169
|
-
{devices.map((device: Device) => (
|
|
170
|
-
<DeviceButton
|
|
171
|
-
key={device.name}
|
|
172
|
-
selectedDevice={device}
|
|
173
|
-
setSelectedDevice={(d: Device) => {
|
|
174
|
-
setDevice(d);
|
|
175
|
-
setIsDevicesModalOpen(false);
|
|
176
|
-
}}
|
|
177
|
-
device={device}
|
|
178
|
-
/>
|
|
179
|
-
))}
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
129
|
+
<DeviceSelectorModal
|
|
130
|
+
devices={devices}
|
|
131
|
+
selectedDevice={selectedDevice}
|
|
132
|
+
onSelect={setDevice}
|
|
133
|
+
onClose={() => setIsDevicesModalOpen(false)}
|
|
134
|
+
/>
|
|
183
135
|
)}
|
|
184
136
|
</div>
|
|
185
137
|
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface MockLaunchScreenComponentProps {
|
|
4
|
+
appName: string;
|
|
5
|
+
onAppClick: () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function MockLaunchScreenComponent({
|
|
9
|
+
appName,
|
|
10
|
+
onAppClick,
|
|
11
|
+
}: MockLaunchScreenComponentProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="mockos-screen mockos-screen--launchscreen">
|
|
14
|
+
<div className="mockos-launcher">
|
|
15
|
+
<div className="mockos-launcher__grid">
|
|
16
|
+
<button
|
|
17
|
+
className="mockos-launcher__app"
|
|
18
|
+
onClick={onAppClick}
|
|
19
|
+
type="button"
|
|
20
|
+
>
|
|
21
|
+
<div className="mockos-launcher__app-icon">
|
|
22
|
+
<svg
|
|
23
|
+
viewBox="0 0 60 60"
|
|
24
|
+
fill="none"
|
|
25
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
+
>
|
|
27
|
+
<rect width="60" height="60" rx="13" fill="#007AFF" />
|
|
28
|
+
<path
|
|
29
|
+
d="M30 15C21.716 15 15 21.716 15 30s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15zm0 27c-6.617 0-12-5.383-12-12s5.383-12 12-12 12 5.383 12 12-5.383 12-12 12z"
|
|
30
|
+
fill="white"
|
|
31
|
+
/>
|
|
32
|
+
<circle cx="30" cy="30" r="5" fill="white" />
|
|
33
|
+
</svg>
|
|
34
|
+
</div>
|
|
35
|
+
<div className="mockos-launcher__app-name">{appName}</div>
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default MockLaunchScreenComponent;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { useMockOSContext } from '../context/MockOSContext';
|
|
3
|
+
import { MockLaunchScreenComponent } from './MockLaunchScreenComponent';
|
|
4
|
+
// Note: We might use react-router or similar library in the future for more complex routing
|
|
5
|
+
|
|
6
|
+
interface MockOSRouterProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
childrenBelongTo?: 'launchscreen' | 'home' | 'onboard' | 'subscription';
|
|
9
|
+
appName?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function HomeComponent() {
|
|
13
|
+
return (
|
|
14
|
+
<div className="mockos-screen mockos-screen--home">
|
|
15
|
+
<div className="mockos-screen__heading">Home</div>
|
|
16
|
+
<div className="mockos-screen__text">Welcome to the home screen</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function OnboardComponent() {
|
|
22
|
+
return (
|
|
23
|
+
<div className="mockos-screen mockos-screen--onboard">
|
|
24
|
+
<div className="mockos-screen__heading">Onboarding</div>
|
|
25
|
+
<div className="mockos-screen__text">Welcome! Let's get you started.</div>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function SubscriptionComponent() {
|
|
31
|
+
return (
|
|
32
|
+
<div className="mockos-screen mockos-screen--subscription">
|
|
33
|
+
<div className="mockos-screen__heading">Subscription</div>
|
|
34
|
+
<div className="mockos-screen__text">Choose your plan</div>
|
|
35
|
+
<div className="mockos-screen__plan mockos-screen__plan--premium">
|
|
36
|
+
Premium - $9.99/month
|
|
37
|
+
</div>
|
|
38
|
+
<div className="mockos-screen__plan mockos-screen__plan--basic">
|
|
39
|
+
Basic - Free
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function ScreenRenderer({
|
|
46
|
+
currentRoute,
|
|
47
|
+
children,
|
|
48
|
+
childrenBelongTo,
|
|
49
|
+
appName,
|
|
50
|
+
onLaunchApp,
|
|
51
|
+
}: {
|
|
52
|
+
currentRoute: string;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
childrenBelongTo?: string;
|
|
55
|
+
appName: string;
|
|
56
|
+
onLaunchApp: () => void;
|
|
57
|
+
}) {
|
|
58
|
+
// If children provided and current route matches childrenBelongTo, render children
|
|
59
|
+
if (children && childrenBelongTo && currentRoute === childrenBelongTo) {
|
|
60
|
+
return <>{children}</>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Otherwise render default screens based on route
|
|
64
|
+
switch (currentRoute) {
|
|
65
|
+
case 'launchscreen':
|
|
66
|
+
return (
|
|
67
|
+
<MockLaunchScreenComponent appName={appName} onAppClick={onLaunchApp} />
|
|
68
|
+
);
|
|
69
|
+
case 'home':
|
|
70
|
+
return <HomeComponent />;
|
|
71
|
+
case 'onboard':
|
|
72
|
+
return <OnboardComponent />;
|
|
73
|
+
case 'subscription':
|
|
74
|
+
return <SubscriptionComponent />;
|
|
75
|
+
default:
|
|
76
|
+
return (
|
|
77
|
+
<MockLaunchScreenComponent appName={appName} onAppClick={onLaunchApp} />
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function MockOSRouter({
|
|
83
|
+
children,
|
|
84
|
+
childrenBelongTo,
|
|
85
|
+
appName = 'My App',
|
|
86
|
+
}: MockOSRouterProps) {
|
|
87
|
+
const context = useMockOSContext();
|
|
88
|
+
|
|
89
|
+
if (!context) {
|
|
90
|
+
throw new Error('MockOSRouter must be used within MockOSProvider');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const { currentRoute, navigation } = context;
|
|
94
|
+
|
|
95
|
+
function handleLaunchApp() {
|
|
96
|
+
// Navigate to the route specified in childrenBelongTo or default to 'onboard'
|
|
97
|
+
const targetRoute = childrenBelongTo || 'onboard';
|
|
98
|
+
navigation(targetRoute);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div className="mockos-router">
|
|
103
|
+
<ScreenRenderer
|
|
104
|
+
currentRoute={currentRoute}
|
|
105
|
+
childrenBelongTo={childrenBelongTo}
|
|
106
|
+
appName={appName}
|
|
107
|
+
onLaunchApp={handleLaunchApp}
|
|
108
|
+
>
|
|
109
|
+
{children}
|
|
110
|
+
</ScreenRenderer>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default MockOSRouter;
|