Skip to content

Commit 8987e4b

Browse files
committed
Integrated new canvas rendering logic with left panel
1 parent 34df49c commit 8987e4b

File tree

8 files changed

+179
-180
lines changed

8 files changed

+179
-180
lines changed

src/HTMLTypes.ts

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,94 @@
11
import { HTMLType } from './interfaces/InterfacesNew';
22

3+
import ImageIcon from '@material-ui/icons/Image';
4+
import ParagraphIcon from '@material-ui/icons/LocalParking';
5+
import FormIcon from '@material-ui/icons/Description';
6+
import HeaderIcon from '@material-ui/icons/TextFormat';
7+
import ButtonIcon from '@material-ui/icons/EditAttributes';
8+
import LinkIcon from '@material-ui/icons/Link';
9+
import ListIcon from '@material-ui/icons/List';
10+
311
const HTMLTypes: HTMLType[] = [
412
{
513
id: 1,
614
tag: 'img',
715
name: 'Image',
816
style: {},
917
placeHolderShort: '',
10-
placeHolderLong: ''
18+
placeHolderLong: '',
19+
icon: ImageIcon
1120
},
1221
{
1322
id: 2,
1423
tag: 'form',
1524
name: 'Form',
1625
style: {},
1726
placeHolderShort: '',
18-
placeHolderLong: ''
27+
placeHolderLong: '',
28+
icon: FormIcon
1929
},
2030
{
2131
id: 3,
2232
tag: 'li',
2333
name: 'List',
2434
style: { color: 'purple' },
2535
placeHolderShort: 'This is a list',
26-
placeHolderLong: ''
36+
placeHolderLong: '',
37+
icon: ListIcon
2738
},
2839
{
2940
id: 4,
3041
tag: 'button',
3142
name: 'Button',
3243
style: {},
3344
placeHolderShort: '',
34-
placeHolderLong: ''
35-
},
36-
{
37-
id: 5,
38-
tag: 'img',
39-
name: 'Image',
40-
style: {},
41-
placeHolderShort: '',
42-
placeHolderLong: ''
45+
placeHolderLong: '',
46+
icon: ButtonIcon
4347
},
4448
{
4549
id: 6,
4650
tag: 'a',
4751
name: 'Link',
4852
style: {},
4953
placeHolderShort: '',
50-
placeHolderLong: ''
51-
},
52-
{
53-
id: 7,
54-
tag: 'img',
55-
name: 'Image',
56-
style: {},
57-
placeHolderShort: '',
58-
placeHolderLong: ''
54+
placeHolderLong: '',
55+
icon: LinkIcon
5956
},
6057
{
6158
id: 8,
6259
tag: 'p',
6360
name: 'Paragraph',
6461
style: {},
6562
placeHolderShort: '',
66-
placeHolderLong: ''
63+
placeHolderLong: '',
64+
icon: ParagraphIcon
6765
},
6866
{
6967
id: 9,
7068
tag: 'h1',
7169
name: 'Header 1',
7270
style: {},
7371
placeHolderShort: '',
74-
placeHolderLong: ''
72+
placeHolderLong: '',
73+
icon: HeaderIcon
7574
},
7675
{
7776
id: 10,
7877
tag: 'h2',
7978
name: 'Header 2',
8079
style: {},
8180
placeHolderShort: '',
82-
placeHolderLong: ''
81+
placeHolderLong: '',
82+
icon: HeaderIcon
8383
},
8484
{
8585
id: 11,
8686
tag: 'div',
8787
name: 'Div',
8888
style: {},
8989
placeHolderShort: '',
90-
placeHolderLong: ''
90+
placeHolderLong: '',
91+
icon: HeaderIcon
9192
}
9293
];
9394

src/components/left/ComponentPanelItemNew.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import Grid from '@material-ui/core/Grid';
44
import { useDrag } from 'react-dnd';
55
import { ItemTypes } from '../../constants/ItemTypes';
66

7-
const ComponentPanelItem: React.FC<{name: String, id: Number, root: Boolean, focusClick: any}> = ({name, id, root, focusClick}) => {
7+
const ComponentPanelItem: React.FC<{
8+
name: String;
9+
id: Number;
10+
root: Boolean;
11+
focusClick: any;
12+
}> = ({ name, id, root, focusClick }) => {
813
// useDrag hook allows components in left panel to be drag source
914
const [{ isDragging }, drag] = useDrag({
1015
item: {
1116
type: ItemTypes.INSTANCE,
1217
newInstance: true,
1318
instanceType: 'Component',
14-
instanceId: 2
15-
// category,
19+
instanceId: id
1620
},
1721
canDrag: !root,
1822
collect: (monitor: any) => ({
@@ -31,15 +35,17 @@ const ComponentPanelItem: React.FC<{name: String, id: Number, root: Boolean, foc
3135
// minWidth: '340px',
3236
height: '80px',
3337
marginBottom: '15px',
34-
border: root ? '2px dotted rgba(255,255,255, 0.45)' : '2px solid rgba(255,255,255, 1)',
35-
borderRadius: root ? '' : '8px',
38+
border: root
39+
? '2px dotted rgba(255,255,255, 0.45)'
40+
: '2px solid rgba(255,255,255, 1)',
41+
borderRadius: root ? '' : '8px'
3642
}}
3743
>
38-
39-
<div className="compPanelItem" onClick={focusClick}>
40-
<h3>{id} {name}</h3>
44+
<div className="compPanelItem" onClick={focusClick}>
45+
<h3>
46+
{id} {name}
47+
</h3>
4148
</div>
42-
4349
</Grid>
4450
);
4551
};

0 commit comments

Comments
 (0)