/
Utils.js
43 lines (36 loc) · 917 Bytes
/
Utils.js
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
import React from 'react'
import namor from 'namor'
import './index.css'
const range = len => {
const arr = []
for (let i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
const newLabelTree = () => {
return {
name: namor.generate({ words: 1, numbers: 0 }),
description: namor.generate({ words: 3, numbers: 0 }),
group: namor.generate({ words: 1, numbers: 5 })
}
}
const newLabel = () => {
return {
name: namor.generate({ words: 1, numbers: 0 }),
description: namor.generate({ words: 3, numbers: 0 }),
leafId: Math.floor(Math.random() * 30)
}
}
export function makeData(len = 10) {
return range(len).map(d => {
return {
...newLabelTree(),
children: range(10).map(newLabel) // []
}
})
}
export const Tips = () =>
<div style={{ textAlign: 'center' }}>
<em>Tip: Right click on a Tree or Label in order to add or edit elements.</em>
</div>