Skip to content

Commit 6013f5d

Browse files
committed
latest work
1 parent 53665e1 commit 6013f5d

File tree

7 files changed

+381
-66
lines changed

7 files changed

+381
-66
lines changed

src/components/left/ComponentPanelItemNew.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
import React from 'react';
22
import Grid from '@material-ui/core/Grid';
3-
3+
import { makeStyles } from '@material-ui/core/styles';
44
import { useDrag } from 'react-dnd';
55
import { ItemTypes } from '../../constants/ItemTypes';
66

7+
const useStyles = makeStyles({
8+
activeFocus: {
9+
backgroundColor: 'rgba(1,212,109,0.3)'
10+
},
11+
focusMark: {
12+
backgroundColor: '#01d46d',
13+
position: 'absolute',
14+
width: '12px',
15+
height: '12px',
16+
borderRadius: '12px',
17+
left: '-35px',
18+
top: '30px'
19+
}
20+
})
21+
722
const ComponentPanelItem: React.FC<{
8-
name: String;
9-
id: Number;
10-
root: Boolean;
23+
name: string;
24+
id: number;
25+
root: boolean;
1126
focusClick: any;
12-
}> = ({ name, id, root, focusClick }) => {
27+
isFocus: boolean
28+
}> = ({ name, id, root, focusClick, isFocus }) => {
29+
const classes = useStyles();
1330
// useDrag hook allows components in left panel to be drag source
1431
const [{ isDragging }, drag] = useDrag({
1532
item: {
@@ -33,17 +50,18 @@ const ComponentPanelItem: React.FC<{
3350
// this is experimental for version: BLADERUNNER THEME
3451
backgroundColor: 'transparent',
3552
// minWidth: '340px',
36-
height: '80px',
53+
height: '75px',
3754
marginBottom: '15px',
3855
border: root
3956
? '2px dotted rgba(255,255,255, 0.45)'
40-
: '2px solid rgba(255,255,255, 1)',
41-
borderRadius: root ? '' : '8px'
57+
: '2px solid rgba(255,255,255, 0.75)',
58+
borderRadius: '8px'
4259
}}
43-
>
60+
>
4461
<div className="compPanelItem" onClick={focusClick}>
62+
{isFocus && <div className={classes.focusMark}></div>}
4563
<h3>
46-
{id} {name}
64+
{name}
4765
</h3>
4866
</div>
4967
</Grid>

src/components/left/ComponentPanelNew.tsx

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,34 @@ import { makeStyles } from '@material-ui/core/styles';
1414

1515
const useStyles = makeStyles({
1616
inputField: {
17-
marginRight: '10px',
18-
borderColor: 'white'
17+
marginRight: '15px',
18+
// width: '245px'
1919
},
2020
inputWrapper: {
21-
height: '120px',
21+
height: '110px',
2222
textAlign: 'center',
2323
display: 'flex',
24-
justifyContent: 'space-evenly'
24+
justifyContent: 'flex-end'
2525
},
2626
panelWrapper: {
2727
marginTop: '35px',
2828
width: '100%'
2929
},
3030
panelWrapperList: {
31-
height: '850px',
32-
overflowY: 'scroll'
31+
height: '675px',
32+
overflowY: 'auto',
33+
marginLeft: '-15px'
3334
},
3435
input: {
3536
color: '#fff',
36-
marginBottom: '10px',
3737
borderRadius: '5px',
3838
paddingLeft: '15px',
39-
paddingTop: '5px',
40-
paddingBottom: '5px',
4139
paddingRight: '10px',
4240
whiteSpace: 'nowrap',
4341
overflowX: 'hidden',
4442
textOverflow: 'ellipsis',
45-
border: '1px solid #33eb91'
43+
border: '1px solid rgba(51,235,145,0.75)',
44+
backgroundColor: 'rgba(255,255,255,0.15)'
4645
},
4746
inputLabel: {
4847
fontSize: '14px',
@@ -52,7 +51,9 @@ const useStyles = makeStyles({
5251
},
5352
btnGroup: {
5453
display: 'flex',
55-
flexDirection: 'column'
54+
flexDirection: 'column',
55+
paddingTop: '10px',
56+
marginRight: '10px'
5657
},
5758
button: {
5859
fontSize: '1rem'
@@ -62,41 +63,15 @@ const useStyles = makeStyles({
6263
fontSize: '0.85rem'
6364
},
6465
compPanelItem: {
66+
color: 'red',
6567
'&:hover': {
6668
cursor: 'pointer',
6769
backgroundColor: 'red'
6870
}
69-
}
71+
},
72+
7073
});
7174

72-
const initialState: any = {
73-
components: [
74-
{
75-
id: 1,
76-
name: 'index',
77-
style: {},
78-
nextChildId: 1,
79-
children: []
80-
},
81-
{
82-
id: 2,
83-
name: 'Article',
84-
style: {},
85-
nextChildId: 1,
86-
children: []
87-
},
88-
{
89-
id: 3,
90-
name: 'Section',
91-
style: {},
92-
nextChildId: 1,
93-
children: []
94-
}
95-
],
96-
rootComponents: [1],
97-
canvasFocus: { componentId: 1, childId: null },
98-
nextComponentId: 4
99-
};
10075

10176
const ComponentPanel = (): JSX.Element => {
10277
const classes = useStyles();
@@ -173,20 +148,25 @@ const ComponentPanel = (): JSX.Element => {
173148
resetError();
174149
};
175150

176-
// const reportFocus = (targetId: Number) => {
177-
// const focusTarget = state.components.filter(comp => {
178-
// return comp.id === targetId;
179-
// });
180-
// console.log('FOCUSING ON COMPONENT: ');
181-
// console.log(focusTarget[0]);
182-
// };
151+
const isFocus = (targetId: Number) => {
152+
return state.canvasFocus.componentId === targetId ? true : false;
153+
}
154+
155+
const setFocus = (targetId: Number) => {
156+
const focusTarget = state.components.filter(comp => {
157+
return comp.id === targetId;
158+
});
159+
//placeholder for switching focus
160+
console.log('FOCUSING ON COMPONENT: ');
161+
console.log(focusTarget[0]);
162+
};
183163

184164
return (
185165
<div className={classes.panelWrapper}>
186166
<div className={classes.inputWrapper}>
187167
<TextField
188168
color={'primary'}
189-
label="COMPONENT NAME"
169+
label="Component Name"
190170
variant="outlined"
191171
className={classes.inputField}
192172
InputProps={{ className: classes.input }}
@@ -202,9 +182,9 @@ const ComponentPanel = (): JSX.Element => {
202182
color="primary"
203183
onClick={handleNameSubmit}
204184
>
205-
CREATE
185+
ADD
206186
</Button>
207-
<FormControlLabel
187+
{/* <FormControlLabel
208188
control={
209189
<Switch
210190
checked={isRoot}
@@ -214,19 +194,19 @@ const ComponentPanel = (): JSX.Element => {
214194
}
215195
className={classes.rootToggle}
216196
label="ROOT"
217-
/>
197+
/> */}
218198
</div>
219199
</div>
220200
<div className={classes.panelWrapperList}>
221201
<Grid container direction="row" justify="center" alignItems="center">
222202
{state.components.map(comp => (
223203
<ComponentPanelItem
224-
className={classes.compPanelItem}
204+
isFocus={isFocus(comp.id)}
225205
key={`comp-${comp.id}`}
226206
name={comp.name}
227207
id={comp.id}
228208
root={state.rootComponents.includes(comp.id)}
229-
focusClick={() => reportFocus(comp.id)}
209+
focusClick={() => setFocus(comp.id)}
230210
/>
231211
))}
232212
</Grid>

src/components/left/HTMLPanelNew.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const HTMLPanel = (): JSX.Element => {
3939
// this is experimental for version: BLADERUNNER THEME
4040
backgroundColor: 'transparent',
4141
// minWidth: '340px',
42-
minHeight: '80px',
42+
minHeight: '60px',
4343
marginBottom: '15px',
4444
border: '2px dotted rgba(255,255,255, 0.45)',
4545
borderRadius: '8px'

src/containers/AppContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Tutorial from '../components/main/Tutorial';
66
import LeftContainer from './LeftContainer';
77
import LeftContainerNew from './LeftContainerNew';
88
import MainContainer from './MainContainer';
9-
import RightContainer from './RightContainer';
9+
import RightContainer from './RightContainerNew';
1010
import theme from '../theme';
1111
import {
1212
ComponentInt,

0 commit comments

Comments
 (0)