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

Sync 'classifyComponents' settings with backend #533

Merged
merged 2 commits into from
Jan 21, 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
7 changes: 7 additions & 0 deletions src/backend/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export let claissifyComponents = false

export default function (bridge) {
bridge.on('config:classifyComponents', value => {
claissifyComponents = value
})
}
8 changes: 5 additions & 3 deletions src/backend/highlighter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inDoc } from '../util'
import { inDoc, classify } from '../util'
import { getInstanceName } from './index'
import { claissifyComponents } from './config'

const overlay = document.createElement('div')
overlay.style.backgroundColor = 'rgba(104, 182, 255, 0.35)'
Expand Down Expand Up @@ -30,8 +31,9 @@ export function highlight (instance) {
const rect = getInstanceRect(instance)
if (rect) {
let content = ''
const name = getInstanceName(instance)
name && (content = `<span style="opacity: .6;">&lt;</span>${name}<span style="opacity: .6;">&gt;</span>`)
let name = getInstanceName(instance)
if (claissifyComponents) name = classify(name)
if (name) content = `<span style="opacity: .6;">&lt;</span>${name}<span style="opacity: .6;">&gt;</span>`
showOverlay(rect, content)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { initEventsBackend } from './events'
import { stringify, classify, camelize, set, parse } from '../util'
import path from 'path'
import ComponentSelector from './component-selector'
import config from './config'

// Use a custom basename functions instead of the shimed version
// because it doesn't work on Windows
Expand Down Expand Up @@ -39,6 +40,8 @@ export function initBackend (_bridge) {
} else {
hook.once('init', connect)
}

config(bridge)
}

function connect () {
Expand Down
2 changes: 2 additions & 0 deletions src/devtools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ function initApp (shell) {
}
}
}).$mount('#app')

store.dispatch('init')
})
}

Expand Down
7 changes: 7 additions & 0 deletions src/devtools/views/components/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ const mutations = {
}

const actions = {
init: {
handler ({ state }) {
bridge.send('config:classifyComponents', state.classifyComponents)
},
root: true
},
toggleInstance ({ commit, dispatch, state }, { instance, expanded, recursive, parent = false } = {}) {
const id = instance.id

Expand Down Expand Up @@ -98,6 +104,7 @@ const actions = {
const newValue = !state.classifyComponents
commit('CLASSIFY_COMPONENTS', newValue)
storage.set(CLASSIFY_COMPONENTS_KEY, newValue)
bridge.send('config:classifyComponents', newValue)
}
}

Expand Down