-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathItemTemplate.jsx
104 lines (98 loc) · 3.47 KB
/
ItemTemplate.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React, { Component } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser, faComment, faCog } from '@fortawesome/free-solid-svg-icons'
import { OrgDiagram } from '../Diagrams';
import { PageFitMode, Enabled, Colors } from 'basicprimitives';
class Sample extends Component {
constructor(props) {
super(props);
this.onButtonClick = this.onButtonClick.bind(this);
}
onButtonClick(itemConfig, name) {
alert(`User clicked button ${name} for node: ${itemConfig.title}. `);
}
render() {
const config = {
pageFitMode: PageFitMode.FitToPage,
cursorItem: 0,
highlightItem: 0,
hasSelectorCheckbox: Enabled.True,
hasButtons: Enabled.True,
buttonsPanelSize: 40,
templates: [{
name: "contactTemplate",
itemSize: { width: 220, height: 120 },
minimizedItemSize: { width: 3, height: 3 },
highlightPadding: { left: 2, top: 2, right: 2, bottom: 2 },
onItemRender: ({ context: itemConfig }) => {
const itemTitleColor = itemConfig.itemTitleColor != null ? itemConfig.itemTitleColor : Colors.RoyalBlue;
return <div className="ContactTemplate">
<div className="ContactTitleBackground" style={{ backgroundColor: itemTitleColor }}>
<div className="ContactTitle">{itemConfig.title}</div>
</div>
<div className="ContactPhotoFrame">
<img className="ContactPhoto" src={itemConfig.image} alt={itemConfig.title} />
</div>
<div className="ContactPhone">{itemConfig.phone}</div>
<div className="ContactEmail">{itemConfig.email}</div>
<div className="ContactDescription">{itemConfig.description}</div>
</div>;
},
onButtonsRender: (({ context: itemConfig }) => {
return <>
<button key="1" className="StyledButton"
onClick={() => { this.onButtonClick(itemConfig, 'User'); }}>
<FontAwesomeIcon icon={faUser} />
</button>
<button key="2" className="StyledButton"
onClick={() => { this.onButtonClick(itemConfig, 'Comment'); }}>
<FontAwesomeIcon icon={faComment} />
</button>
<button key="3" className="StyledButton"
onClick={() => { this.onButtonClick(itemConfig, 'Cog'); }}>
<FontAwesomeIcon icon={faCog} />
</button>
</>
})
}],
items: [
{
id: 0,
parent: null,
title: "James Smith",
description: "VP, Public Sector",
image: "./photos/a.png",
phone: "(123) 456-78-90",
email: "[email protected]",
templateName: "contactTemplate",
itemTitleColor: "red",
groupTitle: "Group 2"
},
{
id: 1,
parent: 0,
title: "Ted Lucas",
description: "VP, Human Resources",
image: "./photos/b.png",
groupTitle: "Group 1"
},
{
id: 2,
parent: 0,
title: "Fritz Stuger",
phone: "(123) 654-78-90",
email: "[email protected]",
description: "Business Solutions, US",
image: "./photos/c.png",
templateName: "contactTemplate",
groupTitle: "Group 3"
}
]
};
return <div className="placeholder">
<OrgDiagram centerOnCursor={true} config={config}
/>
</div >
}
}
export default Sample;