Skip to content

Commit 99cc2e3

Browse files
author
Guillaume Chau
authored
Sync 'classifyComponents' settings with backend (#533)
* Sync 'classifyComponents' settings with backend * Apply feedback
1 parent c24a4e8 commit 99cc2e3

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/backend/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export let claissifyComponents = false
2+
3+
export default function (bridge) {
4+
bridge.on('config:classifyComponents', value => {
5+
claissifyComponents = value
6+
})
7+
}

src/backend/highlighter.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { inDoc } from '../util'
1+
import { inDoc, classify } from '../util'
22
import { getInstanceName } from './index'
3+
import { claissifyComponents } from './config'
34

45
const overlay = document.createElement('div')
56
overlay.style.backgroundColor = 'rgba(104, 182, 255, 0.35)'
@@ -30,8 +31,9 @@ export function highlight (instance) {
3031
const rect = getInstanceRect(instance)
3132
if (rect) {
3233
let content = ''
33-
const name = getInstanceName(instance)
34-
name && (content = `<span style="opacity: .6;">&lt;</span>${name}<span style="opacity: .6;">&gt;</span>`)
34+
let name = getInstanceName(instance)
35+
if (claissifyComponents) name = classify(name)
36+
if (name) content = `<span style="opacity: .6;">&lt;</span>${name}<span style="opacity: .6;">&gt;</span>`
3537
showOverlay(rect, content)
3638
}
3739
}

src/backend/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { initEventsBackend } from './events'
77
import { stringify, classify, camelize, set, parse } from '../util'
88
import path from 'path'
99
import ComponentSelector from './component-selector'
10+
import config from './config'
1011

1112
// Use a custom basename functions instead of the shimed version
1213
// because it doesn't work on Windows
@@ -39,6 +40,8 @@ export function initBackend (_bridge) {
3940
} else {
4041
hook.once('init', connect)
4142
}
43+
44+
config(bridge)
4245
}
4346

4447
function connect () {

src/devtools/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ function initApp (shell) {
166166
}
167167
}
168168
}).$mount('#app')
169+
170+
store.dispatch('init')
169171
})
170172
}
171173

src/devtools/views/components/module.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ const mutations = {
6161
}
6262

6363
const actions = {
64+
init: {
65+
handler ({ state }) {
66+
bridge.send('config:classifyComponents', state.classifyComponents)
67+
},
68+
root: true
69+
},
6470
toggleInstance ({ commit, dispatch, state }, { instance, expanded, recursive, parent = false } = {}) {
6571
const id = instance.id
6672

@@ -98,6 +104,7 @@ const actions = {
98104
const newValue = !state.classifyComponents
99105
commit('CLASSIFY_COMPONENTS', newValue)
100106
storage.set(CLASSIFY_COMPONENTS_KEY, newValue)
107+
bridge.send('config:classifyComponents', newValue)
101108
}
102109
}
103110

0 commit comments

Comments
 (0)