Skip to content

Commit d7dedcf

Browse files
author
Guillaume Chau
committed
refactor: use vue-router and ui button groups for tabs
1 parent 8219002 commit d7dedcf

17 files changed

+223
-327
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"webpack-merge": "^4.1.2"
5757
},
5858
"dependencies": {
59-
"@vue/ui": "^0.4.7",
59+
"@vue/ui": "^0.5.0",
6060
"circular-json-es6": "^2.0.1",
6161
"lodash.debounce": "^4.0.8",
6262
"lodash.groupby": "^4.6.0",

src/devtools/App.vue

Lines changed: 105 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,64 @@
1010
<span class="message" :key="message">{{ message }}</span>
1111
</transition>
1212
</span>
13-
<a
14-
class="button components"
15-
:class="{ active: tab === 'components'}"
16-
v-tooltip="$t('App.components.tooltip')"
17-
@click="switchTab('components')"
18-
>
19-
<VueIcon icon="device_hub"/>
20-
<span class="pane-name">Components</span>
21-
</a>
22-
<a
23-
class="button vuex"
24-
:class="{ active: tab === 'vuex'}"
25-
v-tooltip="$t('App.vuex.tooltip')"
26-
@click="switchTab('vuex')"
27-
>
28-
<VueIcon icon="restore"/>
29-
<span class="pane-name">Vuex</span>
30-
</a>
31-
<a
32-
class="button events"
33-
:class="{ active: tab === 'events' }"
34-
v-tooltip="$t('App.events.tooltip')"
35-
@click="switchTab('events')"
36-
>
37-
<VueIcon icon="grain"/>
38-
<span class="pane-name">Events</span>
39-
<span class="event-count" v-if="newEventCount > 0">{{ newEventCount }}</span>
40-
</a>
41-
<a
42-
class="button refresh"
43-
v-tooltip="$t('App.refresh.tooltip')"
44-
@click="refresh"
45-
>
46-
<VueIcon ref="refresh" icon="refresh"/>
47-
<span class="pane-name">Refresh</span>
48-
</a>
49-
<span class="active-bar"></span>
13+
14+
<div class="actions">
15+
<VueGroup
16+
v-model="routeModel"
17+
class="primary inline"
18+
indicator
19+
>
20+
<VueGroupButton
21+
:class="{
22+
'icon-button': !$responsive.wide
23+
}"
24+
value="components"
25+
icon-left="device_hub"
26+
class="flat"
27+
v-tooltip="$t('App.components.tooltip')"
28+
>
29+
Components
30+
</VueGroupButton>
31+
<VueGroupButton
32+
:class="{
33+
'icon-button': !$responsive.wide
34+
}"
35+
value="vuex"
36+
icon-left="restore"
37+
class="flat"
38+
v-tooltip="$t('App.vuex.tooltip')"
39+
>
40+
Vuex
41+
</VueGroupButton>
42+
<VueGroupButton
43+
:class="{
44+
'icon-button': !$responsive.wide
45+
}"
46+
value="events"
47+
icon-left="grain"
48+
class="flat"
49+
v-tooltip="$t('App.events.tooltip')"
50+
>
51+
Events
52+
</VueGroupButton>
53+
</VueGroup>
54+
55+
<VueButton
56+
ref="refresh"
57+
:class="{
58+
'icon-button': !$responsive.wide
59+
}"
60+
icon-left="refresh"
61+
v-tooltip="$t('App.refresh.tooltip')"
62+
class="flat"
63+
@click="refresh"
64+
>
65+
Refresh
66+
</VueButton>
67+
</div>
5068
</div>
51-
<component :is="tab" class="container"></component>
69+
70+
<router-view class="container"/>
5271
</div>
5372
</template>
5473

@@ -63,6 +82,7 @@ import { mapState } from 'vuex'
6382
6483
export default {
6584
name: 'app',
85+
6686
mixins: [
6787
Keyboard({
6888
onKeyDown ({ key, code, modifiers }) {
@@ -75,81 +95,81 @@ export default {
7595
break
7696
case 'ctrl':
7797
if (code === 'Digit1') {
78-
this.switchTab('components')
98+
this.$router.push({ name: 'components' })
7999
return false
80100
} else if (code === 'Digit2') {
81-
this.switchTab('vuex')
101+
this.$router.push({ name: 'vuex' })
82102
return false
83103
} else if (code === 'Digit3') {
84-
this.switchTab('events')
104+
this.$router.push({ name: 'events' })
85105
return false
86106
}
87107
}
88108
}
89109
})
90110
],
111+
91112
components: {
92113
components: ComponentsTab,
93114
vuex: VuexTab,
94115
events: EventsTab
95116
},
117+
96118
computed: {
97119
...mapState({
98120
message: state => state.message,
99-
tab: state => state.tab,
100121
newEventCount: state => state.events.newEventCount,
101122
view: state => state.view
102123
}),
124+
103125
specialTokens () {
104126
return SPECIAL_TOKENS
127+
},
128+
129+
routeModel: {
130+
get () { return this.$route.name },
131+
set (value) {
132+
this.$router.push({ name: value })
133+
}
105134
}
106135
},
107-
methods: {
108-
switchTab (tab) {
136+
137+
watch: {
138+
'$route.name' (tab) {
109139
bridge.send('switch-tab', tab)
110-
this.$store.commit('SWITCH_TAB', tab)
111140
if (tab === 'events') {
112141
this.$store.commit('events/RESET_NEW_EVENT_COUNT')
113142
}
114-
},
143+
}
144+
},
145+
146+
methods: {
115147
refresh () {
116-
const refreshIcon = this.$refs.refresh.$el
148+
const refreshIcon = this.$refs.refresh.$el.querySelector('.vue-ui-icon')
117149
refreshIcon.style.animation = 'none'
118150
119151
bridge.send('refresh')
120152
bridge.once('flush', () => {
121153
refreshIcon.style.animation = 'rotate 1s'
122154
})
123155
},
156+
124157
switchView (mediaQueryEvent) {
125158
this.$store.commit(
126159
'SWITCH_VIEW',
127160
mediaQueryEvent.matches ? 'vertical' : 'horizontal'
128161
)
129-
},
130-
updateActiveBar () {
131-
const activeButton = this.$el.querySelector('.button.active')
132-
const activeBar = this.$el.querySelector('.active-bar')
133-
activeBar.style.left = activeButton.offsetLeft + 'px'
134-
activeBar.style.width = activeButton.offsetWidth + 'px'
135162
}
136163
},
164+
137165
mounted () {
138166
this.mediaQuery = window.matchMedia('(min-width: 685px)')
139167
this.switchView(this.mediaQuery)
140168
this.mediaQuery.addListener(this.switchView)
141-
142-
this.updateActiveBar()
143-
window.addEventListener('resize', this.updateActiveBar)
144169
},
170+
145171
destroyed () {
146-
window.removeEventListener('resize', this.updateActiveBar)
147172
this.mediaQuery.removeListener(this.switchView)
148-
},
149-
watch: {
150-
tab () {
151-
this.$nextTick(this.updateActiveBar)
152-
}
153173
}
154174
}
155175
</script>
@@ -167,7 +187,7 @@ export default {
167187
background-color $background-color
168188
display flex
169189
flex-direction column
170-
.dark &
190+
.vue-ui-dark-mode &
171191
background-color $dark-background-color
172192
173193
.header
@@ -177,7 +197,7 @@ export default {
177197
box-shadow 0 0 8px rgba(0, 0, 0, 0.15)
178198
font-size 14px
179199
position relative
180-
.dark &
200+
.vue-ui-dark-mode &
181201
border-bottom 1px solid $dark-border-color
182202
183203
.logo
@@ -192,62 +212,32 @@ export default {
192212
@media (min-width: $wide - 300px)
193213
display block
194214
195-
196215
.message
197216
color $active-color
198217
transition all .3s ease
199218
position absolute
200219
201-
.button
202-
padding 10px
220+
.actions
221+
flex auto 1 1
203222
display flex
204-
align-items center
205-
cursor pointer
206-
position relative
207-
border-bottom-color transparent
208-
background-color $background-color
209-
color #888
210-
transition color .35s ease
211-
.dark &
212-
background-color $dark-background-color
213-
214-
.vue-ui-icon
215-
width 20px
216-
height @width
217-
margin-right 5px
218-
>>> svg
219-
fill @color
220-
transition fill .35s ease
221-
222-
&:hover
223-
color #555
224-
.vue-ui-icon >>> svg
225-
fill @color
226-
227-
&.active
228-
color $active-color
229-
.vue-ui-icon >>> svg
230-
fill @color
231-
232-
&:first-of-type
233-
margin-left auto
234-
235-
.pane-name
236-
display none
237-
238-
@media (min-width: $wide)
239-
padding-right 20px
240-
padding-left 20px
241-
.pane-name
242-
display block
223+
justify-content flex-end
243224
225+
.vue-ui-button
226+
height 38px
227+
@media (max-width: $wide)
228+
width 38px
229+
/deep/
230+
.button-icon.left
231+
margin-right 0 !important
232+
.default-slot
233+
display none
244234
@media (min-height: $tall)
245-
padding-top 20px
246-
padding-bottom 20px
235+
height 48px
236+
@media (max-width: $wide)
237+
width @height
247238
248-
.container
249-
overflow hidden
250-
flex 1
239+
.vue-ui-group /deep/ > .indicator
240+
padding-bottom 0 !important
251241
252242
$event-count-bubble-size = 18px
253243
@@ -263,14 +253,10 @@ $event-count-bubble-size = 18px
263253
position absolute
264254
right 0
265255
top 12px
266-
.dark &
256+
.vue-ui-dark-mode &
267257
background-color $dark-background-color
268258
269-
.active-bar
270-
position absolute
271-
bottom 0
272-
width 0px
273-
height 3px
274-
background-color $active-color
275-
transition all .32s cubic-bezier(0,.9,.6,1)
259+
.container
260+
overflow hidden
261+
flex 1
276262
</style>

src/devtools/components/ActionHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
height 35px
1818
@media (min-height: $tall)
1919
height 50px
20-
.dark &
20+
.vue-ui-dark-mode &
2121
border-bottom 1px solid $dark-border-color
2222
2323
.title

src/devtools/components/DataField.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,16 @@ export default {
469469
background-color #ffcc00
470470
&.observable
471471
background-color #ff9999
472-
.dark &
472+
.vue-ui-dark-mode &
473473
color: #242424
474474
475475
.key
476476
color #881391
477-
.dark &
477+
.vue-ui-dark-mode &
478478
color: #e36eec
479479
&.abstract
480480
color $blueishGrey
481-
.dark &
481+
.vue-ui-dark-mode &
482482
color lighten($blueishGrey, 20%)
483483
.value
484484
display inline-block
@@ -488,7 +488,7 @@ export default {
488488
&.string
489489
>>> span
490490
color $black
491-
.dark &
491+
.vue-ui-dark-mode &
492492
color $red
493493
&.null
494494
color #999
@@ -515,13 +515,13 @@ export default {
515515
font-family Menlo, monospace
516516
.platform-windows &
517517
font-family Consolas, Lucida Console, Courier New, monospace
518-
.dark &
518+
.vue-ui-dark-mode &
519519
color $purple
520520
&.type-component-definition
521521
color $green
522522
>>> span
523523
color $darkerGrey
524-
.dark &
524+
.vue-ui-dark-mode &
525525
color #bdc6cf
526526
&.string, &.native
527527
color #e33e3a

0 commit comments

Comments
 (0)