diff --git a/packages/editor/src/components/ComponentForm/ComponentForm.tsx b/packages/editor/src/components/ComponentForm/ComponentForm.tsx index b7ff3e10..b608e6ed 100644 --- a/packages/editor/src/components/ComponentForm/ComponentForm.tsx +++ b/packages/editor/src/components/ComponentForm/ComponentForm.tsx @@ -1,4 +1,4 @@ -import { FormControl, FormLabel, Input } from '@chakra-ui/react'; +import { FormControl, FormLabel, Input, Box } from '@chakra-ui/react'; import { Application } from '@meta-ui/core'; import React from 'react'; import { eventBus } from '../../eventBus'; @@ -31,10 +31,10 @@ export const ComponentForm: React.FC = props => { }); return ( -
+
Component Form
ID: {selectedComponent?.id}
{fields}
-
+ ); }; diff --git a/packages/editor/src/components/ComponentsList/ComponentList.tsx b/packages/editor/src/components/ComponentsList/ComponentList.tsx index df8b51b9..dd46e15b 100644 --- a/packages/editor/src/components/ComponentsList/ComponentList.tsx +++ b/packages/editor/src/components/ComponentsList/ComponentList.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement } from 'react'; +import React from 'react'; import { Tabs, TabList, @@ -21,7 +21,7 @@ export const ComponentList: React.FC = () => { {Array.from(registry.components.keys()).map(version => ( - + {Array.from(registry.components.get(version)!.values()).map(c => { const onDragStart = (e: any) => { @@ -38,11 +38,12 @@ export const ComponentList: React.FC = () => { background="gray.100" width="60px" height="60px" + borderRadius="md" align="center" justify="center" transition="ease 0.2s" _hover={{ - transform: 'scale(1.1)', + transform: 'scale(1.05)', background: 'gray.200', }} p={2} diff --git a/packages/editor/src/components/Editor.tsx b/packages/editor/src/components/Editor.tsx index a57fae28..5d4e1439 100644 --- a/packages/editor/src/components/Editor.tsx +++ b/packages/editor/src/components/Editor.tsx @@ -1,9 +1,9 @@ import { useMemo, useState } from 'react'; import { GridCallbacks } from '@meta-ui/runtime'; -import { Box } from '@chakra-ui/react'; +import { Box, Tabs, TabList, Tab, TabPanels, TabPanel } from '@chakra-ui/react'; import { css } from '@emotion/react'; import { last } from 'lodash'; -import { App } from '../metaUI'; +import { App, stateStore } from '../metaUI'; import { StructureTree } from './StructureTree'; import { CreateComponentOperation, @@ -12,28 +12,34 @@ import { import { eventBus } from '../eventBus'; import { ComponentForm } from './ComponentForm'; import { ComponentList } from './ComponentsList'; +import { EditorHeader } from './EditorHeader'; +import { PreviewModal } from './PreviewModal'; import { useAppModel } from '../operations/useAppModel'; import { KeyboardEventWrapper } from './KeyboardEventWrapper'; let count = 0; export const Editor = () => { const [selectedComponentId, setSelectedComponentId] = useState(''); + const [scale, setScale] = useState(100); + const [preview, setPreview] = useState(false); const { app } = useAppModel(); const Wrapper: React.FC<{ id: string }> = useMemo(() => { return props => { const style = css` height: 100%; - box-shadow: 0 0 ${props.id === selectedComponentId ? 1 : 0}px red; `; const onClick = (e: React.MouseEvent) => { e.stopPropagation(); setSelectedComponentId(() => props.id); }; return ( -
+ {props.children} -
+ ); }; }, [selectedComponentId]); @@ -72,27 +78,86 @@ export const Editor = () => { return ( - - - setSelectedComponentId(id)} /> - - - Drag Component to canvas! - - - - - - - + + setPreview(true)} + /> + + + + + UI Tree + State + + + + setSelectedComponentId(id)} + /> + + +
{JSON.stringify(stateStore, null, 2)}
+
+
+
+
+ + + + + + + + + Inspect + Insert + + + + + + + + + + +
+ {preview && ( + setPreview(false)}> + + + + + )}
); }; diff --git a/packages/editor/src/components/EditorHeader/EditorHeader.tsx b/packages/editor/src/components/EditorHeader/EditorHeader.tsx new file mode 100644 index 00000000..49554b52 --- /dev/null +++ b/packages/editor/src/components/EditorHeader/EditorHeader.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { Flex, Button, Box } from '@chakra-ui/react'; + +export const EditorHeader: React.FC<{ + scale: number; + setScale: (v: number) => void; + onPreview: () => void; +}> = ({ scale, setScale, onPreview }) => { + return ( + + + + + + {scale}% + + + + + + + + ); +}; diff --git a/packages/editor/src/components/EditorHeader/index.ts b/packages/editor/src/components/EditorHeader/index.ts new file mode 100644 index 00000000..55ce4a22 --- /dev/null +++ b/packages/editor/src/components/EditorHeader/index.ts @@ -0,0 +1 @@ +export * from './EditorHeader'; diff --git a/packages/editor/src/components/PreviewModal/PreviewModal.tsx b/packages/editor/src/components/PreviewModal/PreviewModal.tsx new file mode 100644 index 00000000..271221c6 --- /dev/null +++ b/packages/editor/src/components/PreviewModal/PreviewModal.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { + Modal, + ModalOverlay, + ModalHeader, + ModalContent, + ModalCloseButton, + ModalBody, +} from '@chakra-ui/react'; + +export const PreviewModal: React.FC<{ onClose: () => void }> = ({ + onClose, + children, +}) => { + return ( + + + + Preview App + + {children} + + + ); +}; diff --git a/packages/editor/src/components/PreviewModal/index.ts b/packages/editor/src/components/PreviewModal/index.ts new file mode 100644 index 00000000..1ae2f497 --- /dev/null +++ b/packages/editor/src/components/PreviewModal/index.ts @@ -0,0 +1 @@ +export * from './PreviewModal';