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

Inline result overhaul #127

Merged
merged 121 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
ed8ccb8
initial improvements
pfitzseb Apr 17, 2017
4a7db2e
fix result resizing
pfitzseb Apr 17, 2017
e11ab5b
style tweaks
pfitzseb Apr 18, 2017
5d2e053
more tweaking
pfitzseb Apr 18, 2017
26dff69
make result invalidation more robust
pfitzseb Apr 18, 2017
5a4f447
better positioning
pfitzseb Apr 18, 2017
6c16d90
reset width on collapse
pfitzseb Apr 18, 2017
f9c747e
fix undef `el`
pfitzseb Apr 18, 2017
4993a8c
add default keybindings
pfitzseb Apr 19, 2017
6679278
proper code font size
pfitzseb Apr 19, 2017
b51684e
make text in results selectable
pfitzseb Apr 19, 2017
97bff4a
slight cleanup
pfitzseb Apr 20, 2017
93bc956
fix keymap and resizing
pfitzseb Apr 20, 2017
930c456
fix specs
pfitzseb Apr 20, 2017
a5b9b48
make console results selectable too
pfitzseb Apr 20, 2017
a75776f
fix mac keybinding
pfitzseb Apr 25, 2017
11905d7
fix keybindings for real
pfitzseb Apr 26, 2017
02c6c1f
fix
pfitzseb Apr 28, 2017
7f4e173
pref improvements (BROKEN!)
pfitzseb May 3, 2017
46a7671
perf "improvements" (kinda working)
pfitzseb May 4, 2017
066980d
somewhat almost acceptable performance
pfitzseb May 4, 2017
b2ed763
update?
pfitzseb May 4, 2017
9c1abe7
slight cleanup
pfitzseb May 8, 2017
6f8f7ff
maybe better perf?
pfitzseb May 8, 2017
2e4acb1
Use DisplayMarkerLayer for Results
pfitzseb May 9, 2017
3bb3592
Fix Set usage
pfitzseb May 9, 2017
8787b22
new result expanding strategy
pfitzseb May 9, 2017
ed1fa40
revert console changes, clean up css
pfitzseb May 9, 2017
a642f91
fix and generalize tooltips
pfitzseb May 11, 2017
aa29064
add result toolbar
pfitzseb May 11, 2017
a392df4
style tweaks
pfitzseb May 11, 2017
72134c4
make tooltips more robust
pfitzseb May 11, 2017
d47fa90
nicer css
pfitzseb May 11, 2017
a2c84e4
add and document custom buttons for results
pfitzseb May 11, 2017
3f4433a
line-height instead of padding
pfitzseb May 11, 2017
faa8cde
move result toolbar to the right
pfitzseb May 11, 2017
0a12263
requestAnimationFrame goodness
pfitzseb May 11, 2017
648dca1
Revert "requestAnimationFrame goodness"
pfitzseb May 12, 2017
6125f4b
nicer code
pfitzseb May 12, 2017
1afacc2
fix styling
pfitzseb May 12, 2017
82289fd
perf improvements
pfitzseb May 12, 2017
5fb5b87
be a bit smarter about what to update, improve perf
pfitzseb May 12, 2017
a425767
cleanup
pfitzseb May 12, 2017
08db273
fix resizing
pfitzseb May 14, 2017
53fc5e6
js-ify results
pfitzseb May 14, 2017
ad4c8e9
fix block results
pfitzseb May 14, 2017
543dd32
fix styling
pfitzseb May 14, 2017
2ff73a8
don't show toolbar for small results
pfitzseb May 14, 2017
72e86ac
fix css
pfitzseb May 19, 2017
afb796c
better toolbar positioning
pfitzseb May 19, 2017
521fa52
fix non-perf comments
pfitzseb May 19, 2017
d6f131f
extensible toolbar, destroy fix, better css
pfitzseb May 20, 2017
a2f522c
better styling
pfitzseb May 20, 2017
bd7701f
slightly nicer API
pfitzseb May 20, 2017
77ee257
get rid of console border
pfitzseb May 20, 2017
73423fd
simplify standard buttons
pfitzseb May 20, 2017
696c1ab
smaller toolbar
pfitzseb May 20, 2017
346f65c
some whitespace css fixes
pfitzseb May 22, 2017
d3dd910
get rid of fastdom
pfitzseb May 24, 2017
37a7d51
fix travis for atom beta
pfitzseb May 25, 2017
60b61ad
Merge remote-tracking branch 'origin/master'
pfitzseb May 25, 2017
2860142
initial improvements
pfitzseb Apr 17, 2017
8d3a41e
fix result resizing
pfitzseb Apr 17, 2017
281add0
style tweaks
pfitzseb Apr 18, 2017
f35a2b0
more tweaking
pfitzseb Apr 18, 2017
18f7d1a
make result invalidation more robust
pfitzseb Apr 18, 2017
4e8684e
better positioning
pfitzseb Apr 18, 2017
d9f70a8
reset width on collapse
pfitzseb Apr 18, 2017
0d3dadf
fix undef `el`
pfitzseb Apr 18, 2017
db0a279
add default keybindings
pfitzseb Apr 19, 2017
c628a81
proper code font size
pfitzseb Apr 19, 2017
ef610c7
make text in results selectable
pfitzseb Apr 19, 2017
a4e15ba
slight cleanup
pfitzseb Apr 20, 2017
aa233f5
fix keymap and resizing
pfitzseb Apr 20, 2017
10e78d9
fix specs
pfitzseb Apr 20, 2017
481924b
make console results selectable too
pfitzseb Apr 20, 2017
8da4719
fix mac keybinding
pfitzseb Apr 25, 2017
eb04014
fix keybindings for real
pfitzseb Apr 26, 2017
7371c13
fix
pfitzseb Apr 28, 2017
716de34
pref improvements (BROKEN!)
pfitzseb May 3, 2017
c1f2e07
perf "improvements" (kinda working)
pfitzseb May 4, 2017
a40b030
somewhat almost acceptable performance
pfitzseb May 4, 2017
40153b4
update?
pfitzseb May 4, 2017
5e7c995
slight cleanup
pfitzseb May 8, 2017
ad5def1
maybe better perf?
pfitzseb May 8, 2017
21bbaa7
Use DisplayMarkerLayer for Results
pfitzseb May 9, 2017
2c6387b
Fix Set usage
pfitzseb May 9, 2017
dd24c53
new result expanding strategy
pfitzseb May 9, 2017
2d21266
revert console changes, clean up css
pfitzseb May 9, 2017
de042d0
fix and generalize tooltips
pfitzseb May 11, 2017
3d8ece2
add result toolbar
pfitzseb May 11, 2017
a86561b
style tweaks
pfitzseb May 11, 2017
44c316e
make tooltips more robust
pfitzseb May 11, 2017
b6f629e
nicer css
pfitzseb May 11, 2017
b287cd1
add and document custom buttons for results
pfitzseb May 11, 2017
34d198e
line-height instead of padding
pfitzseb May 11, 2017
3783451
move result toolbar to the right
pfitzseb May 11, 2017
b7d9ade
requestAnimationFrame goodness
pfitzseb May 11, 2017
289abd8
Revert "requestAnimationFrame goodness"
pfitzseb May 12, 2017
7567bf1
nicer code
pfitzseb May 12, 2017
fd53dea
fix styling
pfitzseb May 12, 2017
fad2a52
perf improvements
pfitzseb May 12, 2017
8f5b711
be a bit smarter about what to update, improve perf
pfitzseb May 12, 2017
87e18d9
cleanup
pfitzseb May 12, 2017
4b5a4bc
fix resizing
pfitzseb May 14, 2017
8bde805
js-ify results
pfitzseb May 14, 2017
2b353e5
fix block results
pfitzseb May 14, 2017
cf43f97
fix styling
pfitzseb May 14, 2017
c9ed22b
don't show toolbar for small results
pfitzseb May 14, 2017
02ee9f8
fix css
pfitzseb May 19, 2017
359b9c5
better toolbar positioning
pfitzseb May 19, 2017
4678545
fix non-perf comments
pfitzseb May 19, 2017
3965142
extensible toolbar, destroy fix, better css
pfitzseb May 20, 2017
91ae5bd
better styling
pfitzseb May 20, 2017
552275e
slightly nicer API
pfitzseb May 20, 2017
6d85e11
get rid of console border
pfitzseb May 20, 2017
cc9fe84
simplify standard buttons
pfitzseb May 20, 2017
ca7bebd
smaller toolbar
pfitzseb May 20, 2017
ff9a012
some whitespace css fixes
pfitzseb May 22, 2017
96e5015
get rid of fastdom
pfitzseb May 24, 2017
c354ee2
Merge remote-tracking branch 'origin/sp/newrsults' into sp/newrsults
pfitzseb May 25, 2017
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 keymaps/ink.cson
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
'ink-console':
'shift-space': 'unset!'

'.platform-win32 .ink, .platform-linux .ink':
'ctrl-c': 'native!'

'.platform-darwin .ink':
'cmd-c': 'native!'

'atom-text-editor:not([mini])':
'escape': 'inline:clear-current'
'alt-t': 'inline-results:toggle'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keybinding is quite generic – ideally I'd use a prefix – but maybe it's common enough to be worthwhile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-i C-t maybe? I kinda like an unprefixed keybinding for this, but don't have any super strong feelings about it.


'.platform-darwin atom-text-editor:not([mini])':
'cmd-i cmd-c': 'inline-results:clear-all'
Expand Down
2 changes: 1 addition & 1 deletion lib/console/view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ConsoleElement extends HTMLElement
@isLoading = l

# Scrolling
scrollDown: -> throttle (=> delay (=> @lastElement().scrollIntoView()), 20), 130, {leading: false}
scrollDown: -> throttle (=> delay (=> @lastElement()?.scrollIntoView()), 20), 130, {leading: false}

lock: (f) ->
if @isVisible @lastElement()
Expand Down
152 changes: 152 additions & 0 deletions lib/editor/result-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
'use babel'
import {CompositeDisposable} from 'atom'
let views = require('../util/views')
let {span, div} = views.tags

export default class ResultView {
constructor (model, opts = {}) {
this.model = model
this.disposables = new CompositeDisposable()
this.completeView(opts)

this.model.onDidRemove(() => this.destroy())
this.model.onDidUpdate(() => this.modelUpdated = true)
this.model.onDidInvalidate(() => this.view.classList.add('invalid'))
this.model.onDidValidate(() => this.view.classList.remove('invalid'))
this.model.onDidAttach(() => this.overlayElement = this.complete.parentElement)

this.lastEdWidth = -1

return this
}

getView () {
return this.model.type == 'inline' ? this.complete : this.view
}

getContent () {
return this.view
}

getRawContent () {
return this.rawContent
}

completeView (opts) {
this.complete = document.createElement('div')
this.complete.classList.add('ink-result-container')
if (!opts.noTB && opts.type === 'inline') {
this.toolbarView = this.toolbar(opts.buttons, opts.customButtons)
this.complete.appendChild(this.toolbarView)
}

this.complete.appendChild(this.content(opts))

this.disposables.add(atom.config.observe('editor.lineHeight', (h) => {
this.complete.style.top = -h + 'em'
this.complete.style.minHeight = h + 'em'
}))
}

content (opts) {
let {content, fade, loading, type} = opts
this.view = document.createElement('div')
this.view.setAttribute('tabindex', '-1')
this.view.classList.add('ink', 'result', opts.scope)
if (type === 'inline') {
this.view.classList.add('inline')
} else if (type === 'block') {
this.view.classList.add('under')
}

this.view.addEventListener('mousewheel', (e) => {
if ((this.view.offsetHeight < this.view.scrollHeight ||
this.view.offsetWidth < this.view.scrollWidth) &&
((e.deltaY > 0 && this.view.scrollHeight - this.view.scrollTop > this.view.clientHeight) ||
(e.deltaY < 0 && this.view.scrollTop > 0) ||
(e.deltaX > 0 && this.view.scrollWidth - this.view.scrollLeft > this.view.clientWidth) ||
(e.deltaX < 0 && this.view.scrollLeft > 0))) {
e.stopPropagation()
}
})

this.view.addEventListener('click', () => {
if (this.overlayElement === null) return
this.overlayElement.parentNode.appendChild(this.overlayElement)
})

this.disposables.add(atom.commands.add(this.view, {'inline-results:clear': () => this.remove()}))

if (fade) this.fadeIn()
if (content != null) this.setContent(content, opts)
if (loading) this.setContent(views.render(span('loading icon icon-gear')), opts)

return this.view
}

fadeIn () {
this.view.classList.add('ink-hide')
setTimeout(() => this.view.classList.remove('ink-hide'), 20)
}

setContent (view, {error = false, loading = false}) {
this.rawContent = [view, {error, loading}]
while (this.view.firstChild != null) {
this.view.removeChild(this.view.firstChild)
}
error ? this.view.classList.add('error') : this.view.classList.remove('error')
loading ? this.view.classList.add('loading') : this.view.classList.remove('loading')
this.view.appendChild(view)

// HACK: don't display toolbar for "small" results
if (this.model.type === 'inline' && this.toolbarView && view.innerHTML.length < 100 ) {
this.toolbarView.classList.add('hide')
} else {
this.toolbarView.classList.remove('hide')
}
}

toolbar (buttons, customButtons) {
let tb = views.render(div('btn-group'))
let addButtons = (buttons) => {
for (let b of buttons(this.model)) {
let v = document.createElement('button')
v.classList.add('btn', b.icon)
v.addEventListener('click', b.onclick)
tb.appendChild(v)
}
}
if (customButtons) addButtons(customButtons)
addButtons(buttons)
return views.render(div('ink-result-toolbar', tb))
}

// only read from the DOM
decideUpdateWidth (edRect) {
this.isVisible = false
this.left = 0
this.newEdWidth = false
if (this.overlayElement) {
let rect = this.view.getBoundingClientRect()
this.isVisible = rect.top < edRect.bottom && rect.bottom > edRect.top
this.left = parseInt(this.getView().parentElement.style.left)
this.newEdWidth = edRect.width !== this.lastEdWidth
}
}

// only write to the DOM
updateWidth (edRect) {
if ((this.isVisible && this.newEdWidth) || this.modelUpdated) {
let w = edRect.width + edRect.left - 40 - this.left
if (w < 100) w = 100
this.getView().style.maxWidth = w + 'px'
this.lastEdWidth = edRect.width
this.modelUpdated = false
}
}

destroy () {
this.view.classList.add('ink-hide')
this.disposables.dispose()
}
}
203 changes: 0 additions & 203 deletions lib/editor/result.coffee

This file was deleted.

Loading