Skip to content

Commit bf2495f

Browse files
committed
components in canvas aligned to center
1 parent 1b863bc commit bf2495f

File tree

9 files changed

+47
-28
lines changed

9 files changed

+47
-28
lines changed

app/src/components/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const App = (): JSX.Element => {
8383
}, 15000);
8484
}
8585
}, [state]);
86+
// uncomment below to log state
87+
// console.log('STATE!!!!: ', state);
8688
return (
8789
<div className="app">
8890
<DndProvider backend={HTML5Backend}>

app/src/components/main/Canvas.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function Canvas(props): JSX.Element {
1717

1818
useEffect(()=> {
1919
if (newComp) {
20-
//find updated comp
20+
// find updated comp
2121
const copy = state.components.find(comp => comp.name === copiedComp.name)
2222
// make a array of copied children from the copied component
2323
if (copy.children.length){
@@ -181,6 +181,11 @@ function Canvas(props): JSX.Element {
181181
backgroundColor: isOver ? '#FAFED1' : '#FBFBFB',
182182
border: '1px solid #FBFBF2',
183183
borderStyle: isOver ? 'dotted' : 'solid',
184+
userSelect: 'none',
185+
aspectRatio: 'auto 774 / 1200',
186+
boxSizing: 'border-box',
187+
// width: '100vw',
188+
// height: '100vh'
184189
};
185190

186191
const darkCanvasStyle = {
@@ -197,8 +202,9 @@ function Canvas(props): JSX.Element {
197202
// const canvasStyle = combineStyles(defaultCanvasStyle, currentComponent.style);
198203
const canvasStyle = combineStyles(defaultCanvasStyle, currentComponent.style);
199204
const darkCombinedCanvasStyle = combineStyles(darkCanvasStyle, currentComponent.style);
205+
// console.log('CURRENTCOMPONENT children: ', currentComponent.children, 'CURRCOMPONENT STYLE: ', currentComponent.style);
200206
return (
201-
<div ref={drop} style={props.isThemeLight ? canvasStyle : darkCombinedCanvasStyle} onClick={onClickHandler}>
207+
<div className={'componentContainer'} ref={drop} style={props.isThemeLight ? canvasStyle : darkCombinedCanvasStyle} onClick={onClickHandler}>
202208
{renderChildren(currentComponent.children)}
203209
</div>
204210
);

app/src/components/main/DirectChildComponent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function DirectChildComponent({ childId, type, typeId, style, name }: ChildEleme
6767
ref={drag}
6868
>
6969
<strong>{name}</strong>
70-
{` (${childId})`}
7170
</div>
7271
);
7372
}

app/src/components/main/DirectChildHTML.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ function DirectChildHTML({
7070

7171
return (
7272
<div onClick={onClickHandler} style={combinedStyle} ref={drag} id={`canv${childId}`}>
73-
<strong style={ {color: isThemeLight ? 'black' : 'white'} }>{HTMLType.placeHolderShort}</strong>
74-
{/* {` (${childId})`} */}
75-
<span style={ {color: isThemeLight ? 'black' : 'white'} }>{` ( ${childId} )`}</span>
76-
<Annotation
77-
id={childId}
78-
name={name}
79-
annotations={annotations}
80-
/>
73+
<strong style={ {color: isThemeLight ? 'black' : 'white'} }>{HTMLType.placeHolderShort}</strong>
74+
<Annotation
75+
id={childId}
76+
name={name}
77+
annotations={annotations}
78+
/>
8179
</div>
8280
);
8381
}

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,16 @@ function DirectChildHTMLNestable({
149149

150150
return (
151151
<div onClick={onClickHandler} style={combinedStyle} ref={ref} id={`canv${childId}`}>
152-
<strong style={ {color: isThemeLight ? 'black' : 'white'} }>{HTMLType.placeHolderShort}</strong>
153-
{/* {` ( ${childId} )`} */}
154-
<span style={ {color: isThemeLight ? 'black' : 'white'} }>{` ( ${childId} )`}</span>
155-
<strong style={{ color: "#0099E6" }}>{attributes && attributes.compLink ? ` ${attributes.compLink}` : ''}</strong>
156-
{routeButton}
157-
<Annotation
158-
id={childId}
159-
name={name}
160-
annotations={annotations}
161-
/>
152+
<span>
153+
<strong style={ {color: isThemeLight ? 'black' : 'white'} }>{HTMLType.placeHolderShort}</strong>
154+
<strong style={{ color: "#0099E6" }}>{attributes && attributes.compLink ? ` ${attributes.compLink}` : ''}</strong>
155+
{routeButton}
156+
<Annotation
157+
id={childId}
158+
name={name}
159+
annotations={annotations}
160+
/>
161+
</span>
162162
{renderChildren(children)}
163163
</div>
164164
);

app/src/helperFunctions/renderChildren.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const renderChildren = (children: ChildElement[]) => {
2020
// A DirectChildComponent is an instance of a top level component
2121
// This component will render IndirectChild components (div/components rendered inside a child component)
2222
// Removed style from prop drills so that styling isn't applied to canvas items.
23-
// Also added keys & removed an unnecessary div around DirChildNestables that were causing errors.
23+
// Also added keys & removed an unnecessary div around DirChildNestables that was causing errors.
2424
if (type === 'Component') {
2525
return (
2626
<DirectChildComponent
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
import { autoUpdater } from "electron";
2+
13
const globalDefaultStyle: Object = {
2-
padding: '10px',
4+
display: 'flex',
5+
flexDirection: 'column',
6+
justifyContent: 'space-between',
7+
boxSizing: 'border-box',
8+
padding: '10px 20px 10px 20px',
39
margin: '10px',
410
borderRadius: '5px',
5-
border: '1px Solid grey',
11+
border: '10px Solid grey',
612
fontFamily: 'Helvetica Neue',
7-
textAlign: 'left'
13+
maxWidth: 'fit-content',
14+
minWidth: '250px',
815
};
916

1017
export default globalDefaultStyle;

app/src/public/styles/style.css

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ h1 {
281281
//////////////////////////////////////////////////
282282
RIGHT COLUMN
283283
/////////////////////////////////////////////////
284+
// RIGHT NOW, I'M NOT SURE WHAT RIGHT COL IS REFERING TO
284285
*/
285-
286286
#rightContainer {
287287
overflow-y: scroll;
288288
overflow-x: hidden;
@@ -530,11 +530,11 @@ a.nav_link:hover {
530530

531531
/* Additional styling for ReacType X */
532532
.componentDefault {
533-
width: 100%;
533+
width: auto;
534534
border: 2px solid gray;
535535
min-height: 150px;
536536
padding: 10px;
537-
background-color: lightgray;
537+
background-color: rgb(213, 80, 164);
538538
opacity: 0.75;
539539
}
540540
.inputName {
@@ -600,4 +600,11 @@ a.nav_link:hover {
600600
display: flex;
601601
flex-direction: column;
602602
align-items: center;
603+
}
604+
605+
/* My Changes to canvas instances container */
606+
.componentContainer {
607+
display: flex;
608+
flex-direction: column;
609+
align-items: center;
603610
}
File renamed without changes.

0 commit comments

Comments
 (0)