-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcustom-renderer.js
53 lines (49 loc) · 1.37 KB
/
custom-renderer.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
44
45
46
47
48
49
50
51
52
53
import React from 'react'
import { TagCloud } from 'react-tagcloud'
const data = [
{ value: 'jQuery', count: 25 },
{ value: 'MongoDB', count: 18 },
{ value: 'JavaScript', count: 38 },
{ value: 'React', count: 30 },
{ value: 'Nodejs', count: 28 },
{ value: 'Express.js', count: 25 },
{ value: 'HTML5', count: 33 },
{ value: 'CSS3', count: 20 },
{ value: 'Webpack', count: 22 },
{ value: 'Babel.js', count: 7 },
{ value: 'ECMAScript', count: 25 },
{ value: 'Jest', count: 15 },
{ value: 'Mocha', count: 17 },
{ value: 'React Native', count: 27 },
{ value: 'Angular.js', count: 30 },
{ value: 'TypeScript', count: 15 },
{ value: 'Flow', count: 30 },
{ value: 'NPM', count: 11 },
]
/* CSS:
@keyframes blinker {
50% { opacity: 0.0; }
}
*/
// custom renderer is function which has tag, computed font size and
// color as arguments, and returns react component which represents tag
const customRenderer = (tag, size, color) => (
<span
key={tag.value}
style={{
animation: 'blinker 3s linear infinite',
animationDelay: `${Math.random() * 2}s`,
fontSize: `${size / 2}em`,
border: `2px solid ${color}`,
margin: '3px',
padding: '3px',
display: 'inline-block',
color: 'white',
}}
>
{tag.value}
</span>
)
export default () => (
<TagCloud tags={data} minSize={1} maxSize={5} renderer={customRenderer} />
)