12
12
@mouseenter =" enter"
13
13
@mouseleave =" leave"
14
14
:class =" { selected: selected }"
15
- :style =" { paddingLeft: depth * 15 + 'px' }" >
15
+ :style =" { paddingLeft: depth * 15 + 'px' }"
16
+ >
17
+ <!-- Component tag -->
16
18
<span class =" content" >
17
19
<!-- arrow wrapper for better hit box -->
18
20
<span class =" arrow-wrapper"
21
23
<span class =" arrow right" :class =" { rotated: expanded }" >
22
24
</span >
23
25
</span >
24
- <span class =" angle-bracket" >< ; </span ><span class =" item-name" >{{ displayName }}</span ><span class =" angle-bracket" >> ; </span >
26
+
27
+ <span class =" angle-bracket" >< ; </span >
28
+
29
+ <span class =" item-name" >{{ displayName }}</span >
30
+
31
+ <span v-if =" componentHasKey" class =" attr" >
32
+ <span class =" attr-title" > key</span >=<span class =" attr-value" >{{instance.renderKey}}</span >
33
+ </span >
34
+
35
+ <span class =" angle-bracket" >> ; </span >
25
36
</span >
26
37
<span
27
38
v-if =" instance.consoleId"
48
59
>
49
60
inactive
50
61
</span >
62
+
51
63
<span class =" spacer" ></span >
64
+
52
65
<VueIcon
53
66
class =" icon-button"
54
67
icon =" visibility"
55
68
v-tooltip =" 'Scroll into view'"
56
69
@click =" scrollToInstance"
57
70
/>
58
71
</div >
72
+
59
73
<div v-if =" expanded" >
60
74
<component-instance
61
75
v-for =" child in sortedChildren"
69
83
70
84
<script >
71
85
import { mapState } from ' vuex'
72
- import { classify , scrollIntoView } from ' ../../../util'
86
+ import { classify , scrollIntoView , UNDEFINED } from ' ../../../util'
73
87
74
88
export default {
75
89
name: ' ComponentInstance' ,
90
+
76
91
props: {
77
92
instance: Object ,
78
93
depth: Number
79
94
},
95
+
80
96
created () {
81
97
// expand root by default
82
98
if (this .depth === 0 ) {
83
99
this .expand ()
84
100
}
85
101
},
102
+
86
103
computed: {
87
104
... mapState (' components' , [
88
105
' classifyComponents'
89
106
]),
107
+
90
108
scrollToExpanded () {
91
109
return this .$store .state .components .scrollToExpanded
92
110
},
111
+
93
112
expanded () {
94
113
return !! this .$store .state .components .expansionMap [this .instance .id ]
95
114
},
115
+
96
116
selected () {
97
117
return this .instance .id === this .$store .state .components .inspectedInstance .id
98
118
},
119
+
99
120
sortedChildren () {
100
121
return this .instance .children .slice ().sort ((a , b ) => {
101
122
return a .top === b .top
102
123
? a .id - b .id
103
124
: a .top - b .top
104
125
})
105
126
},
127
+
106
128
displayName () {
107
129
return this .classifyComponents ? classify (this .instance .name ) : this .instance .name
130
+ },
131
+
132
+ componentHasKey () {
133
+ return !! this .instance .renderKey && this .instance .renderKey !== UNDEFINED
108
134
}
109
135
},
136
+
110
137
watch: {
111
138
scrollToExpanded: {
112
139
handler (value , oldValue ) {
@@ -117,35 +144,44 @@ export default {
117
144
immediate: true
118
145
}
119
146
},
147
+
120
148
methods: {
121
149
toggle (event ) {
122
150
this .toggleWithValue (! this .expanded , event .altKey )
123
151
},
152
+
124
153
expand () {
125
154
this .toggleWithValue (true )
126
155
},
156
+
127
157
collapse () {
128
158
this .toggleWithValue (false )
129
159
},
160
+
130
161
toggleWithValue (val , recursive = false ) {
131
162
this .$store .dispatch (' components/toggleInstance' , {
132
163
instance: this .instance ,
133
164
expanded: val,
134
165
recursive
135
166
})
136
167
},
168
+
137
169
select () {
138
170
bridge .send (' select-instance' , this .instance .id )
139
171
},
172
+
140
173
enter () {
141
174
bridge .send (' enter-instance' , this .instance .id )
142
175
},
176
+
143
177
leave () {
144
178
bridge .send (' leave-instance' , this .instance .id )
145
179
},
180
+
146
181
scrollToInstance () {
147
182
bridge .send (' scroll-to-instance' , this .instance .id )
148
183
},
184
+
149
185
scrollIntoView (center = true ) {
150
186
this .$nextTick (() => {
151
187
scrollIntoView (this .$globalRefs .leftScroll , this .$refs .self , center)
@@ -233,16 +269,29 @@ export default {
233
269
color $component-color
234
270
margin 0 1px
235
271
272
+ .attr
273
+ opacity .5
274
+ font-size 12px
275
+
276
+ .attr-title
277
+ color purple
278
+
236
279
.spacer
237
- flex 100% 1 1
238
- width 0
280
+ flex auto 1 1
239
281
240
282
.icon-button
241
- font-size 16px
283
+ width 16px
284
+ height 16px
242
285
243
286
.self :not (:hover ) &
244
287
visibility hidden
245
288
246
289
.self.selected & >>> svg
247
290
fill $white
291
+
292
+ .self.selected
293
+ .attr
294
+ opacity 1
295
+ .attr-title
296
+ color lighten ($purple , 70% )
248
297
</style >
0 commit comments