Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add settings tab #713

Merged
merged 4 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/devtools/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@
>
Events
</VueGroupButton>
<VueGroupButton
v-tooltip="$t('App.settings.tooltip')"
:class="{
'icon-button': !$responsive.wide
}"
value="settings"
icon-left="settings_applications"
class="settings-tab flat"
>
Settings
</VueGroupButton>
</VueGroup>

<VueButton
Expand Down Expand Up @@ -138,6 +149,9 @@ export default {
} else if (code === 'Digit3') {
this.$router.push({ name: 'events' })
return false
} else if (code === 'Digit4') {
this.$router.push({ name: 'settings' })
return false
} else if (key === 'p' || code === 'KeyP') {
// Prevent chrome devtools from opening the print modal
return false
Expand Down
10 changes: 5 additions & 5 deletions src/devtools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import storage from './storage'
let panelShown = !isChrome
let pendingAction = null

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

// Capture and log devtool errors when running as actual extension
Expand Down Expand Up @@ -96,7 +96,8 @@ function initApp (shell) {
Vue,
storage,
persist: [
'classifyComponents'
'classifyComponents',
'theme'
]
})

Expand Down Expand Up @@ -161,14 +162,13 @@ function initApp (shell) {
store,

data: {
isDark,
isBeta
},

watch: {
isDark: {
'$shared.theme': {
handler (value) {
if (value) {
if (value === 'dark' || (value === 'auto' && chromeTheme === 'dark')) {
document.body.classList.add('vue-ui-dark-mode')
} else {
document.body.classList.remove('vue-ui-dark-mode')
Expand Down
3 changes: 3 additions & 0 deletions src/devtools/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default {
refresh: {
tooltip: '[[{{keys.ctrl}}]] + [[{{keys.alt}}]] + [[R]] Force Refresh'
},
settings: {
tooltip: '[[{{keys.ctrl}}]] + [[4]] Switch to Settings'
},
vuex: {
tooltip: '[[{{keys.ctrl}}]] + [[2]] Switch to Vuex'
}
Expand Down
6 changes: 6 additions & 0 deletions src/devtools/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import VueRouter from 'vue-router'
import ComponentsTab from './views/components/ComponentsTab.vue'
import VuexTab from './views/vuex/VuexTab.vue'
import EventsTab from './views/events/EventsTab.vue'
import SettingsTab from './views/settings/SettingsTab.vue'

Vue.use(VueRouter)

Expand All @@ -27,6 +28,11 @@ const routes = [
name: 'events',
component: EventsTab
},
{
path: '/settings',
name: 'settings',
component: SettingsTab
},
{
path: '*',
redirect: '/'
Expand Down
52 changes: 52 additions & 0 deletions src/devtools/views/settings/GlobalPreferences.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<div class="global-preferences">
<VueFormField title="Component Name Format">
<VueGroup
:value="$shared.classifyComponents"
class="extend"
@input="$shared.classifyComponents = $event"
>
<VueGroupButton
:value="false"
label="kebab-case"
/>
<VueGroupButton
:value="true"
label="PascalCase"
/>
</VueGroup>
</VueFormField>

<VueFormField title="Theme">
<VueGroup
:value="$shared.theme"
class="extend"
@input="$shared.theme = $event"
>
<VueGroupButton
value="auto"
label="Auto"
/>
<VueGroupButton
value="dark"
label="Dark"
/>
<VueGroupButton
value="light"
label="Light"
/>
</VueGroup>
</VueFormField>
</div>
</template>

<style lang="stylus" scoped>
.global-preferences
display flex
flex-wrap wrap
padding 1rem 1.5rem

> *
flex-basis 300px
margin 0 .5rem 1rem .5rem
</style>-->
18 changes: 18 additions & 0 deletions src/devtools/views/settings/SettingsTab.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="grid">
<GlobalPreferences />
</div>
</template>

<script>
import GlobalPreferences from './GlobalPreferences.vue'
import { mapState } from 'vuex'

export default {
components: { GlobalPreferences },

computed: mapState('events', [
'enabled'
])
}
</script>
3 changes: 2 additions & 1 deletion src/shared-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Initial state
const internalSharedData = {
openInEditorHost: '/',
classifyComponents: true
classifyComponents: true,
theme: 'auto'
}

// ---- INTERNALS ---- //
Expand Down