-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New keyboard shortcuts + tooltips refactoring #519
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
Changes from 9 commits
8e60d1b
4d1d172
b6e2f17
224ee41
224584d
e7d16bb
e77abfe
15ba636
b31a0bb
53ce622
e485f0b
a8d1a64
2b9ac21
b9176e9
341e7c2
f5a9fe1
95fddbc
95d2f5f
657bbd4
c749098
8bb0d28
1c35f69
a8034c1
db8e451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Vue from 'vue' | ||
|
||
// Env | ||
|
||
export const isChrome = typeof chrome !== 'undefined' && !!chrome.devtools | ||
export const isMac = navigator.platform === 'MacIntel' | ||
export const keys = { | ||
ctrl: isMac ? '⌘' : 'Ctrl', | ||
shift: 'Shift', | ||
alt: isMac ? '⌥' : 'Alt' | ||
} | ||
|
||
Object.defineProperties(Vue.prototype, { | ||
'$isChrome': { get: () => isChrome }, | ||
'$isMac': { get: () => isMac }, | ||
'$keys': { get: () => keys } | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
export default { | ||
App: { | ||
components: { | ||
tooltip: '[{{keys.alt}}] + [C] Switch to Components' | ||
}, | ||
events: { | ||
tooltip: '[{{keys.alt}}] + [E] Switch to Events' | ||
}, | ||
refresh: { | ||
tooltip: '[{{keys.ctrl}}] + [{{keys.shift}}] + [R] Force Refresh' | ||
}, | ||
vuex: { | ||
tooltip: '[{{keys.alt}}] + [V] Switch to Vuex' | ||
} | ||
}, | ||
StateInspector: { | ||
dataType: { | ||
tooltip: '[{{keys.ctrl}}] + |mouse|: Collapse All<br>[{{keys.shift}}] + |mouse|: Expand All' | ||
} | ||
}, | ||
DataField: { | ||
edit: { | ||
cancel: { | ||
tooltip: '[Esc] Cancel' | ||
}, | ||
submit: { | ||
tooltip: '[Enter] Submit change' | ||
} | ||
}, | ||
quickEdit: { | ||
number: { | ||
tooltip: `Quick Edit<br><br> | ||
[{{keys.ctrl}}] + |mouse|: {{operator}}5<br> | ||
[{{keys.shift}}] + |mouse|: {{operator}}10<br> | ||
[{{keys.alt}}] + |mouse|: {{operator}}100` | ||
} | ||
} | ||
}, | ||
ComponentTree: { | ||
select: { | ||
tooltip: '[S] Select component in the page' | ||
}, | ||
filter: { | ||
tooltip: '[F] Filter components by name' | ||
} | ||
}, | ||
EventsHistory: { | ||
filter: { | ||
tooltip: '[F] To filter on components, type <span class="input-example"><i class="material-icons">search</i> <MyComponent></span> or just <span class="input-example"><i class="material-icons">search</i> <mycomp</span>.' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HTML with classes in translations make it much harder to maintain code dependent on it, you never know which change might affect it. I'd be careful about this |
||
}, | ||
clear: { | ||
tooltip: '[{{keys.ctrl}}] + [C] Clear Log' | ||
}, | ||
startRecording: { | ||
tooltip: '[R] Start recording' | ||
}, | ||
stopRecording: { | ||
tooltip: '[R] Stop recording' | ||
} | ||
}, | ||
VuexHistory: { | ||
filter: { | ||
tooltip: '[F] Filter mutations' | ||
}, | ||
commitAll: { | ||
tooltip: '[{{keys.ctrl}}] + [C] Commit all' | ||
}, | ||
revertAll: { | ||
tooltip: '[{{keys.ctrl}}] + [R] Revert all' | ||
}, | ||
startRecording: { | ||
tooltip: '[R] Start recording' | ||
}, | ||
stopRecording: { | ||
tooltip: '[R] Stop recording' | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { scrollIntoView } from 'src/util' | ||
|
||
export default { | ||
watch: { | ||
inspectedIndex (value) { | ||
this.$nextTick(() => { | ||
const el = value === -1 ? this.$refs.baseEntry : this.$refs.entries[value] | ||
el && scrollIntoView(document.querySelector('.left .scroll'), el, false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend we use |
||
}) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import Vue from 'vue' | ||
import VTooltip from 'v-tooltip' | ||
import VI18n from './plugins/i18n' | ||
import { keys } from './env' | ||
|
||
Vue.use(VTooltip, { | ||
defaultDelay: { | ||
|
@@ -8,3 +10,19 @@ Vue.use(VTooltip, { | |
}, | ||
defaultOffset: 2 | ||
}) | ||
|
||
const currentLocale = 'en' | ||
const locales = require.context('./locales') | ||
const keyboardReg = /\[(\w+)\]/g | ||
const iconReg = /\|(\w+)\|/g | ||
Vue.use(VI18n, { | ||
strings: locales(`./${currentLocale}`).default, | ||
defaultValues: { | ||
keys | ||
}, | ||
replacer: text => { | ||
text = text.replace(keyboardReg, '<span class="keyboard">$1</span>') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this solution. Now whenever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are going to have a lot of keyboard shortcuts in the strings--more than icons 😛 |
||
text = text.replace(iconReg, '<i class="material-icons">$1</i>') | ||
return text | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now since you moved this code to a separate file this comment seems redundant