forked from gaearon/react-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuery.js
More file actions
117 lines (100 loc) · 2.3 KB
/
Query.js
File metadata and controls
117 lines (100 loc) · 2.3 KB
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
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';
import type {Map} from 'immutable';
var React = require('react');
class Query extends React.Component {
props: {
data: Map,
oddRow: boolean,
onSelect: () => void,
};
render(): ReactElement {
var data = this.props.data;
var containerStyle = styles.container;
if (this.props.isSelected) {
containerStyle = styles.containerSelected;
} else if (this.props.oddRow) {
containerStyle = styles.containeroOddRow;
}
var status = data.get('status');
var statusStyle = {
...styles.status,
backgroundColor: statusColors[status] || statusColors.error,
};
const start = data.get('start');
const end = data.get('end');
return (
<tr onClick={this.props.onSelect} style={containerStyle}>
<td style={styles.tdFirst}>
<span style={statusStyle} title={status} />
</td>
<td style={styles.tdName}>
{data.get('name')}
</td>
<td style={styles.td}>
{Math.round(start) / 1000}s
</td>
<td style={styles.td}>
{Math.round(end - start)}ms
</td>
</tr>
);
}
}
var statusColors = {
pending: 'orange',
success: 'green',
failure: 'red',
error: '#aaa',
};
var baseContainer = {
cursor: 'pointer',
fontSize: 11,
height: 21,
lineHeight: '21px',
fontFamily: "'Lucida Grande', sans-serif",
};
var baseTD = {
whiteSpace: 'nowrap',
'padding': '1px 4px',
'lineHeight': '17px',
'borderLeft': '1px solid #e1e1e1',
};
var styles = {
container: baseContainer,
containerSelected: {
...baseContainer,
backgroundColor: '#3879d9',
color: 'white',
},
containeroOddRow: {
...baseContainer,
backgroundColor: '#f5f5f5',
},
td: baseTD,
tdFirst: {
...baseTD,
borderLeft: '',
},
tdName: {
...baseTD,
width: '100%',
},
status: {
display: 'inline-block',
width: 11,
height: 11,
borderRadius: 6,
backgroundColor: '#aaa',
},
};
module.exports = Query;