diff --git a/app/src/components/bottom/BottomPanel.tsx b/app/src/components/bottom/BottomPanel.tsx index c46acee04..fa19a22ea 100644 --- a/app/src/components/bottom/BottomPanel.tsx +++ b/app/src/components/bottom/BottomPanel.tsx @@ -1,7 +1,6 @@ import React, { useContext } from 'react'; import { stateContext } from '../../context/context'; import BottomTabs from './BottomTabs'; -// import BottomTabs from './BottomTabs'; import { Resizable } from 're-resizable'; // const IPC = require('electron').ipcRenderer; diff --git a/app/src/components/bottom/BottomTabs.tsx b/app/src/components/bottom/BottomTabs.tsx index 23f4f6554..65ce0a652 100644 --- a/app/src/components/bottom/BottomTabs.tsx +++ b/app/src/components/bottom/BottomTabs.tsx @@ -71,9 +71,7 @@ const BottomTabs = () => { {tab === 0 && } - {tab === 1 && ( - - )} + {tab === 1 && } ); }; diff --git a/app/src/components/bottom/CodePreview.tsx b/app/src/components/bottom/CodePreview.tsx index 74bd2e180..a5cc0cdc5 100644 --- a/app/src/components/bottom/CodePreview.tsx +++ b/app/src/components/bottom/CodePreview.tsx @@ -20,7 +20,7 @@ import { Component } from '../../interfaces/Interfaces'; // } // })); -const optionColor = '#252526'; +// const optionColor = '#252526'; const CodePreview = ({ theme, setTheme }) => { const [state, dispatch] = useContext(stateContext); diff --git a/app/src/components/left/ComponentPanel.tsx b/app/src/components/left/ComponentPanel.tsx index 2e5fd986c..52aeadd84 100644 --- a/app/src/components/left/ComponentPanel.tsx +++ b/app/src/components/left/ComponentPanel.tsx @@ -162,6 +162,7 @@ const ComponentPanel = (): JSX.Element => { {state.components .filter(comp => state.rootComponents.includes(comp.id)) .map(comp => { + //console.log('root comp', comp.name) return ( { {state.components .filter(comp => !state.rootComponents.includes(comp.id)) .map(comp => { + //console.log('all root comps', state.rootComponents); + //console.log('all reusable comps', state.components); return ( { ); }; -export const useStyles = makeStyles({ +const useStyles = makeStyles({ inputField: { marginTop: '15px' }, @@ -274,7 +277,7 @@ export const useStyles = makeStyles({ button: { fontSize: '1rem', height: '40px', - marginTop: '10px', + maginTop: '10px', width: '100%', // border: '1px solid rgba(70,131,83)', backgroundColor: 'rgba(1,212,109,0.1)' diff --git a/app/src/components/left/HTMLPanel.tsx b/app/src/components/left/HTMLPanel.tsx index 27ef06d50..60f3f05ea 100644 --- a/app/src/components/left/HTMLPanel.tsx +++ b/app/src/components/left/HTMLPanel.tsx @@ -14,7 +14,8 @@ const HTMLPanel = (): JSX.Element => { const [errorMsg, setErrorMsg] = useState(''); const [errorStatus, setErrorStatus] = useState(false); - const buttonClasses = "MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary"; + const buttonClasses = + 'MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-button-12 MuiButton-textPrimary'; const handleTagChange = (e: React.ChangeEvent) => { resetError(); @@ -125,9 +126,11 @@ const HTMLPanel = (): JSX.Element => { value={tag} onChange={handleTagChange} className={classes.input} + style={{ marginBottom: '10px' }} /> {errorStatus && {errorMsg}} +

- + @@ -210,10 +219,11 @@ const useStyles = makeStyles({ overflowX: 'hidden', textOverflow: 'ellipsis', border: '1px solid rgba(51,235,145,0.75)', - backgroundColor: 'rgba(255,255,255,0.15)' + backgroundColor: 'rgba(255,255,255,0.15)', + marginLeft: '10px' }, inputLabel: { - fontSize: '14px', + fontSize: '16px', zIndex: 20, color: '#fff', marginTop: '-10px' diff --git a/app/src/components/right/ProjectManager.tsx b/app/src/components/right/ProjectManager.tsx index 595b4ad98..6daefafe5 100644 --- a/app/src/components/right/ProjectManager.tsx +++ b/app/src/components/right/ProjectManager.tsx @@ -21,6 +21,9 @@ import LoginButton from './LoginButton'; import SaveProjectButton from './SaveProjectButton'; import DeleteProjects from './DeleteProjects'; +// import { useStyles } from '../left/ComponentPanel'; +import { styleContext } from '../../containers/AppContainer'; + const ProjectManager = () => { // state to keep track of whether a modal should display const [modal, setModal] = useState(null); @@ -28,6 +31,9 @@ const ProjectManager = () => { const classes = useStyles(); + const { style, setStyle } = useContext(styleContext); + // console.log('style: ', style); + // Allows users to toggle project between "next.js" and "Classic React" // When a user changes the project type, the code of all components is rerendered const handleProjectChange = event => { @@ -156,62 +162,76 @@ const ProjectManager = () => { }; return ( - //
-
- {state.name && state.isLoggedIn ? ( -

- Your current project is {state.name} -

- ) : null} - {!state.name && state.isLoggedIn ? ( -

- Select "Save project as" to create and save a project -

- ) : null} - -
- - - -
- {state.isLoggedIn ? : ''} - {state.isLoggedIn ? : ''} - {state.isLoggedIn ? : ''} - {/*
*/} +
- - -
-
- - {/*
*/} - {modal} + +
+ {state.name && state.isLoggedIn ? ( +

+ Your current project is {state.name} +

+ ) : null} + {!state.name && state.isLoggedIn ? ( +

+ Select "Save project as" to create and save a project +

+ ) : null} + +
+ + + +
+ {state.isLoggedIn ? : ''} + {state.isLoggedIn ? : ''} + {state.isLoggedIn ? : ''} + {/*
*/} + + + +
+
+ + {/*
*/} + {modal} +
); }; diff --git a/app/src/containers/AppContainer.tsx b/app/src/containers/AppContainer.tsx index 62592b637..ccf8e0a0e 100644 --- a/app/src/containers/AppContainer.tsx +++ b/app/src/containers/AppContainer.tsx @@ -1,32 +1,29 @@ -import React, { useState } from 'react'; +import React, { useState, useContext, createContext } from 'react'; import { MuiThemeProvider } from '@material-ui/core/styles'; -import Button from '@material-ui/core/Button'; +// import Button from '@material-ui/core/Button'; import LeftContainer from './LeftContainer'; import MainContainer from './MainContainer'; import RightContainer from './RightContainer'; -import { theme1, theme2 } from '../public/styles/theme'; +import { theme1 } from '../public/styles/theme'; import { makeStyles } from '@material-ui/core/styles'; -import { useStyles } from '../components/left/ComponentPanel'; + +export const styleContext = createContext({}); +// console.log('styleContext: ', styleContext); const AppContainer = () => { const [theme, setTheme] = useState(theme1); - const classes = useStyles(); - const [style, setStyle] = useState({}); + const initialStyle = useContext(styleContext); + const [style, setStyle] = useState(initialStyle); return ( // Mui theme provider provides themed styling to all MUI components in app -
- - - + + + + +
); diff --git a/app/src/containers/LeftContainer.tsx b/app/src/containers/LeftContainer.tsx index 2460b5e38..839e7b4be 100644 --- a/app/src/containers/LeftContainer.tsx +++ b/app/src/containers/LeftContainer.tsx @@ -8,7 +8,7 @@ import HTMLPanel from '../components/left/HTMLPanel'; // Left-hand portion of the app, where component options are displayed const LeftContainer = ({ style }): JSX.Element => { return ( -
+
diff --git a/app/src/containers/MainContainer.tsx b/app/src/containers/MainContainer.tsx index e8302357b..0b2c99500 100644 --- a/app/src/containers/MainContainer.tsx +++ b/app/src/containers/MainContainer.tsx @@ -2,21 +2,15 @@ import React, { Component } from 'react'; import BottomPanel from '../components/bottom/BottomPanel'; import CanvasContainer from '../components/main/CanvasContainer'; -import { Resizable } from "re-resizable"; - -class MainContainer extends Component { - render() { - return ( -
-
- -
- {/* */} - - {/* */} +const MainContainer = ({ style }) => { + return ( +
+
+ +
+
- ); - } -} + ); +}; export default MainContainer; diff --git a/app/src/containers/RightContainer.tsx b/app/src/containers/RightContainer.tsx index 6b4497006..6900247d7 100644 --- a/app/src/containers/RightContainer.tsx +++ b/app/src/containers/RightContainer.tsx @@ -1,4 +1,10 @@ -import React, { useState, useContext, useEffect, useMemo, Component } from 'react'; +import React, { + useState, + useContext, + useEffect, + useMemo, + Component +} from 'react'; import { makeStyles } from '@material-ui/core/styles'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; @@ -16,7 +22,7 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import ErrorMessages from '../constants/ErrorMessages'; // need to pass in props to use the useHistory feature of react router -const RightContainer = (props): JSX.Element => { +const RightContainer = ({ style }): JSX.Element => { const classes = useStyles(); const [state, dispatch] = useContext(stateContext); const [displayMode, setDisplayMode] = useState(''); @@ -135,14 +141,14 @@ const RightContainer = (props): JSX.Element => { state.canvasFocus.componentId ]); - const isPage = (configTarget) : boolean => { + const isPage = (configTarget): boolean => { const { components, rootComponents } = state; return components .filter(component => rootComponents.includes(component.id)) .some(el => el.id === configTarget.id); - } + }; - const isIndex = (): boolean => configTarget.id === 1; + const isIndex = (): boolean => configTarget.id === 1; const isChildOfPage = (): boolean => { // TODO: refactor @@ -157,9 +163,7 @@ const RightContainer = (props): JSX.Element => { }); }); return isChild; - } - - + }; // dispatch to 'UPDATE CSS' called when save button is clicked, // passing in style object constructed from all changed input values @@ -186,38 +190,37 @@ const RightContainer = (props): JSX.Element => { dispatch({ type: 'DELETE CHILD', payload: {} }); }; - const handlePageDelete = (id) => () => { - // TODO: return modal - isIndex() - ? handleDialogError('index') - : dispatch({ type: 'DELETE PAGE', payload: { id }}); - } - + const handlePageDelete = id => () => { + // TODO: return modal + isIndex() + ? handleDialogError('index') + : dispatch({ type: 'DELETE PAGE', payload: { id } }); + }; + const handleDeleteReusableComponent = () => { isChildOfPage() - ? handleDialogError('component') - : dispatch({ type: 'DELETE REUSABLE COMPONENT', payload: {} }); - } + ? handleDialogError('component') + : dispatch({ type: 'DELETE REUSABLE COMPONENT', payload: {} }); + }; const isReusable = (configTarget): boolean => { return state.components - .filter(comp => !state.rootComponents - .includes(comp.id)) + .filter(comp => !state.rootComponents.includes(comp.id)) .some(el => el.id == configTarget.id); - } + }; - const handleDialogError = (err) => { + const handleDialogError = err => { if (err === 'index') setDeleteIndexError(true); else setDeleteComponentError(true); - } + }; const handleCloseDialogError = () => { setDeleteIndexError(false); setDeleteComponentError(false); - } + }; return ( -
+
@@ -416,13 +419,13 @@ const RightContainer = (props): JSX.Element => { DELETE INSTANCE
- ) : (isPage(configTarget) ? ( -
+ ) : isPage(configTarget) ? ( +
@@ -432,11 +435,10 @@ const RightContainer = (props): JSX.Element => { color="secondary" className={classes.button} onClick={handleDeleteReusableComponent} - > + > DELETE REUSABLE COMPONENT
- ) )}
@@ -447,10 +449,12 @@ const RightContainer = (props): JSX.Element => { aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - {ErrorMessages.deleteIndexTitle} + + {ErrorMessages.deleteIndexTitle} + - {ErrorMessages.deleteIndexMessage} + {ErrorMessages.deleteIndexMessage} @@ -465,10 +469,12 @@ const RightContainer = (props): JSX.Element => { aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - {ErrorMessages.deleteComponentTitle} + + {ErrorMessages.deleteComponentTitle} + - {ErrorMessages.deleteComponentMessage} + {ErrorMessages.deleteComponentMessage} diff --git a/app/src/public/styles/style.css b/app/src/public/styles/style.css index fe2c202e2..1368a40c1 100644 --- a/app/src/public/styles/style.css +++ b/app/src/public/styles/style.css @@ -59,6 +59,12 @@ header { height: 100vh; } +.mode-change-button { + display: flex; + align-content: center; + padding-top: 50px; +} + .progress-bar { flex-grow: 1; } diff --git a/app/src/public/styles/theme.ts b/app/src/public/styles/theme.ts index 544beaf12..7474d7109 100644 --- a/app/src/public/styles/theme.ts +++ b/app/src/public/styles/theme.ts @@ -11,19 +11,17 @@ export const theme1 = createMuiTheme({ primary: { // light: '#00e676', main: '#01d46d' // less blinding green + //main:'#00FFFF' // teal color // dark: '#14a37f', // contrastText: '#fff' - }, - secondary: { - main: '#ff5722' } } }); -export const theme2 = createMuiTheme({ - // overrides: { - // MuiContainer: {} - // } -}); +// export const theme2 = createMuiTheme({ +// // overrides: { +// // MuiContainer: {} +// // } +// }); // export default theme; diff --git a/app/src/tree/TreeChart.tsx b/app/src/tree/TreeChart.tsx index f79c861fa..01c8ea59c 100644 --- a/app/src/tree/TreeChart.tsx +++ b/app/src/tree/TreeChart.tsx @@ -1,6 +1,6 @@ -import React, { useRef, useEffect, useContext } from "react"; -import { select, hierarchy, tree, linkHorizontal } from "d3"; -import useResizeObserver from "./useResizeObserver"; +import React, { useRef, useEffect, useContext } from 'react'; +import { select, hierarchy, tree, linkHorizontal } from 'd3'; +import useResizeObserver from './useResizeObserver'; import { stateContext } from '../context/context'; function usePrevious(value) { @@ -37,9 +37,9 @@ function TreeChart({ data }) { dimensions || wrapperRef.current.getBoundingClientRect(); // transform hierarchical data const root = hierarchy(data[canvasId - 1]); - const treeLayout = tree().size([height, width-125]); - - // Returns a new link generator with horizontal display. + const treeLayout = tree().size([height, width - 125]); + + // Returns a new link generator with horizontal display. // To visualize links in a tree diagram rooted on the left edge of the display const linkGenerator = linkHorizontal() .x(link => link.y) @@ -99,8 +99,8 @@ function TreeChart({ data }) { .attr('font-size', 18) .style('fill', textAndBorderColor) .text(node => node.data.name) - .attr("opacity", 1) - .attr("transform", `translate(${xPosition}, 0)`); + .attr('opacity', 1) + .attr('transform', `translate(${xPosition}, 0)`); }, [data, dimensions, previouslyRenderedData, canvasId]); const treeStyles = { @@ -119,7 +119,7 @@ function TreeChart({ data }) { justifyContent: 'center' }; return ( - //
+ //