Skip to content

Commit 14e05a2

Browse files
znckAkryum
authored andcommitted
feat: Add settings tab (vuejs#713)
* feat: Add settings tab * fix: Persist theme * fix: fixes
1 parent dd5b2cb commit 14e05a2

File tree

7 files changed

+100
-6
lines changed

7 files changed

+100
-6
lines changed

src/devtools/App.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@
7979
>
8080
Events
8181
</VueGroupButton>
82+
<VueGroupButton
83+
v-tooltip="$t('App.settings.tooltip')"
84+
:class="{
85+
'icon-button': !$responsive.wide
86+
}"
87+
value="settings"
88+
icon-left="settings_applications"
89+
class="settings-tab flat"
90+
>
91+
Settings
92+
</VueGroupButton>
8293
</VueGroup>
8394

8495
<VueButton
@@ -138,6 +149,9 @@ export default {
138149
} else if (code === 'Digit3') {
139150
this.$router.push({ name: 'events' })
140151
return false
152+
} else if (code === 'Digit4') {
153+
this.$router.push({ name: 'settings' })
154+
return false
141155
} else if (key === 'p' || code === 'KeyP') {
142156
// Prevent chrome devtools from opening the print modal
143157
return false

src/devtools/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import storage from './storage'
1313
let panelShown = !isChrome
1414
let pendingAction = null
1515

16-
const isDark = isChrome ? chrome.devtools.panels.themeName === 'dark' : false
16+
const chromeTheme = isChrome ? chrome.devtools.panels.themeName : undefined
1717
const isBeta = process.env.RELEASE_CHANNEL === 'beta'
1818

1919
// Capture and log devtool errors when running as actual extension
@@ -96,7 +96,8 @@ function initApp (shell) {
9696
Vue,
9797
storage,
9898
persist: [
99-
'classifyComponents'
99+
'classifyComponents',
100+
'theme'
100101
]
101102
})
102103

@@ -161,14 +162,13 @@ function initApp (shell) {
161162
store,
162163

163164
data: {
164-
isDark,
165165
isBeta
166166
},
167167

168168
watch: {
169-
isDark: {
169+
'$shared.theme': {
170170
handler (value) {
171-
if (value) {
171+
if (value === 'dark' || (value === 'auto' && chromeTheme === 'dark')) {
172172
document.body.classList.add('vue-ui-dark-mode')
173173
} else {
174174
document.body.classList.remove('vue-ui-dark-mode')

src/devtools/locales/en.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export default {
99
refresh: {
1010
tooltip: '[[{{keys.ctrl}}]] + [[{{keys.alt}}]] + [[R]] Force Refresh'
1111
},
12+
settings: {
13+
tooltip: '[[{{keys.ctrl}}]] + [[4]] Switch to Settings'
14+
},
1215
vuex: {
1316
tooltip: '[[{{keys.ctrl}}]] + [[2]] Switch to Vuex'
1417
}

src/devtools/router.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import VueRouter from 'vue-router'
44
import ComponentsTab from './views/components/ComponentsTab.vue'
55
import VuexTab from './views/vuex/VuexTab.vue'
66
import EventsTab from './views/events/EventsTab.vue'
7+
import SettingsTab from './views/settings/SettingsTab.vue'
78

89
Vue.use(VueRouter)
910

@@ -27,6 +28,11 @@ const routes = [
2728
name: 'events',
2829
component: EventsTab
2930
},
31+
{
32+
path: '/settings',
33+
name: 'settings',
34+
component: SettingsTab
35+
},
3036
{
3137
path: '*',
3238
redirect: '/'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<div class="global-preferences">
3+
<VueFormField title="Component Name Format">
4+
<VueGroup
5+
:value="$shared.classifyComponents"
6+
class="extend"
7+
@input="$shared.classifyComponents = $event"
8+
>
9+
<VueGroupButton
10+
:value="false"
11+
label="kebab-case"
12+
/>
13+
<VueGroupButton
14+
:value="true"
15+
label="PascalCase"
16+
/>
17+
</VueGroup>
18+
</VueFormField>
19+
20+
<VueFormField title="Theme">
21+
<VueGroup
22+
:value="$shared.theme"
23+
class="extend"
24+
@input="$shared.theme = $event"
25+
>
26+
<VueGroupButton
27+
value="auto"
28+
label="Auto"
29+
/>
30+
<VueGroupButton
31+
value="dark"
32+
label="Dark"
33+
/>
34+
<VueGroupButton
35+
value="light"
36+
label="Light"
37+
/>
38+
</VueGroup>
39+
</VueFormField>
40+
</div>
41+
</template>
42+
43+
<style lang="stylus" scoped>
44+
.global-preferences
45+
display flex
46+
flex-wrap wrap
47+
padding 1rem 1.5rem
48+
49+
> *
50+
flex-basis 300px
51+
margin 0 .5rem 1rem .5rem
52+
</style>-->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="grid">
3+
<GlobalPreferences />
4+
</div>
5+
</template>
6+
7+
<script>
8+
import GlobalPreferences from './GlobalPreferences.vue'
9+
import { mapState } from 'vuex'
10+
11+
export default {
12+
components: { GlobalPreferences },
13+
14+
computed: mapState('events', [
15+
'enabled'
16+
])
17+
}
18+
</script>

src/shared-data.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Initial state
22
const internalSharedData = {
33
openInEditorHost: '/',
4-
classifyComponents: true
4+
classifyComponents: true,
5+
theme: 'auto'
56
}
67

78
// ---- INTERNALS ---- //

0 commit comments

Comments
 (0)