-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathZoomWithItemTemplate.jsx
188 lines (178 loc) · 8.24 KB
/
ZoomWithItemTemplate.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import React, { Component } from 'react';
import { OrgDiagram } from '../Diagrams';
import { PageFitMode, Colors } from 'basicprimitives';
class Sample extends Component {
constructor(props) {
super(props);
this.setTemplate = this.setTemplate.bind(this);
this.scales = {
"xs": {
caption: "Extra Small",
defaultTemplateName: "xs",
normalLevelShift: 10,
normalItemsInterval: 12
},
"sm": {
caption: "Small",
defaultTemplateName: "sm",
normalLevelShift: 10,
normalItemsInterval: 12,
},
"md": {
caption: "Medium",
defaultTemplateName: "md",
normalLevelShift: 12,
normalItemsInterval: 12
},
"lg": {
caption: "Large",
defaultTemplateName: "lg",
normalLevelShift: 14,
normalItemsInterval: 16,
},
"xl": {
caption: "Extra Large",
defaultTemplateName: "xl",
normalLevelShift: 16,
normalItemsInterval: 20
}
}
this.state = {
scale: "md"
}
}
setTemplate(key) {
this.setState({
scale: key
})
}
render() {
const { scale } = this.state;
const {
defaultTemplateName,
normalLevelShift,
normalItemsInterval
} = this.scales[scale];
const config = {
pageFitMode: PageFitMode.None,
cousinsIntervalMultiplier: 1,
highlightItem: 0,
cursorItem: 0,
defaultTemplateName,
normalLevelShift,
normalItemsInterval,
templates: [{
name: "xl",
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="xlTemplate">
<div className="xlTitleBackground" style={{ backgroundColor: itemTitleColor }}>
<div className="xlTitle">{itemConfig.title}</div>
</div>
<div className="xlPhotoFrame">
<img className="xlPhoto" src={itemConfig.image} alt={itemConfig.title} />
</div>
<div className="xlPhone">{itemConfig.phone}</div>
<div className="xlEmail">{itemConfig.email}</div>
<div className="xlDescription">{itemConfig.description}</div>
</div>;
}
},
{
name: "lg",
itemSize: { width: 160, height: 86 },
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="lgTemplate">
<div className="lgTitleBackground" style={{ backgroundColor: itemTitleColor }}>
<div className="lgTitle">{itemConfig.title}</div>
</div>
<div className="lgPhotoFrame">
<img className="lgPhoto" src={itemConfig.image} alt={itemConfig.title} />
</div>
<div className="lgEmail">{itemConfig.email}</div>
<div className="lgDescription">{itemConfig.description}</div>
</div>;
}
},
{
name: "md",
itemSize: { width: 130, height: 45 },
minimizedItemSize: { width: 3, height: 3 },
highlightPadding: { left: 2, top: 2, right: 2, bottom: 2 },
onItemRender: ({ context: itemConfig }) => {
return <div className="mdTemplate">
<div className="mdTitle">{itemConfig.title}</div>
<div className="mdPhotoFrame">
<img className="mdPhoto" src={itemConfig.image} alt={itemConfig.title} />
</div>
<div className="mdDescription">{itemConfig.description}</div>
</div>;
}
},
{
name: "sm",
itemSize: { width: 100, height: 34 },
minimizedItemSize: { width: 3, height: 3 },
highlightPadding: { left: 2, top: 2, right: 2, bottom: 2 },
onItemRender: ({ context: itemConfig }) => {
return <div className="smTemplate">
<div className="smTitle">{itemConfig.title}</div>
<div className="smDescription">{itemConfig.description}</div>
</div>;
}
},
{
name: "xs",
itemSize: { width: 80, height: 16 },
minimizedItemSize: { width: 3, height: 3 },
highlightPadding: { left: 2, top: 2, right: 2, bottom: 2 },
onItemRender: ({ context: itemConfig }) => {
return <div className="xsTemplate">
<div className="xsTitle">{itemConfig.title}</div>
</div>;
}
}
],
items: [
{ id: 0, parent: null, isVisible: true, description: "Chief Executive Officer (CEO)", email: "[email protected]", image: "./photos/q.png", itemTitleColor: "#4169e1", phone: "(352) 206-7599", title: "David Dalton" },
{ id: 1, parent: 0, isVisible: true, description: "Co-Presidents, Platform Products & Services Division", email: "[email protected]", image: "./photos/w.png", itemTitleColor: "#4b0082", phone: "(505) 791-1689", title: "Jeanna White" },
{ id: 2, parent: 0, isVisible: true, description: "Sr. VP, Server & Tools Division", email: "[email protected]", image: "./photos/e.png", itemTitleColor: "#4b0082", phone: "(262) 215-7998", title: "James Holt" },
{ id: 3, parent: 0, isVisible: true, description: "VP, Server & Tools Marketing and Solutions", email: "[email protected]", image: "./photos/r.png", itemTitleColor: "#4b0082", phone: "(904) 547-5342", title: "Thomas Williams" },
{ id: 4, parent: 0, isVisible: true, description: "VP, Software & Enterprise Management Division", email: "[email protected]", image: "./photos/g.png", itemTitleColor: "#4b0082", phone: "(918) 257-4218", title: "Sara Kemp" },
{ id: 5, parent: 1, isVisible: true, description: "Sr. VP, Software Server System", email: "[email protected]", image: "./photos/x.png", itemTitleColor: "#4b0082", phone: "(434) 406-2189", title: "George Duong" },
{ id: 6, parent: 1, isVisible: true, description: "VP, Developer Division", email: "[email protected]", image: "./photos/n.png", itemTitleColor: "#4b0082", phone: "(515) 324-4969", title: "Ashley Rue" },
{ id: 7, parent: 2, isVisible: true, description: "VP, Enterprise Access and Security Products Division (EASP)", email: "[email protected]", image: "./photos/i.png", itemTitleColor: "#4b0082", phone: "(412) 265-2782", title: "Bonnie Wedel" },
{ id: 8, parent: 2, isVisible: true, description: "GM, Core File Solutions", email: "[email protected]", image: "./photos/p.png", itemTitleColor: "#4b0082", phone: "(630) 887-1188", title: "Melissa Houser" },
{ id: 9, parent: 3, isVisible: true, description: "GM, Software Server Solutions Group", email: "[email protected]", image: "./photos/a.png", itemTitleColor: "#4b0082", phone: "530-322-6413", title: "Abbie Lawson" },
{ id: 10, parent: 3, isVisible: true, description: "GM, Connected Systems Division", email: "[email protected]", image: "./photos/s.png", itemTitleColor: "#4b0082", phone: "(626) 831-0555", title: "Ernest Putnam" },
{ id: 11, parent: 4, isVisible: true, description: "CFO, Platforms Products & Services", email: "[email protected]", image: "./photos/h.png", itemTitleColor: "#4b0082", phone: "(419) 578-6479", title: "Celestina Crum" },
{ id: 12, parent: 4, isVisible: true, description: "GM, Pricing", email: "[email protected]", image: "./photos/j.png", itemTitleColor: "#4b0082", phone: "(530) 934-4295", title: "Cindy Turner" }
]
};
return <>
<p>Select template size:
{Object.keys(this.scales).map(key => {
const { caption } = this.scales[key];
return <label key={key}><input
onChange={() => this.setTemplate(key)}
name="scale"
type="radio"
checked={scale === key ? 'checked' : ''}
value="{key}"
/>{caption}</label>
}
)}
</p>
<div className="placeholder">
<OrgDiagram centerOnCursor={true} config={config} />
</div>
</>
}
}
export default Sample;