Browse Source

refactor tips and links page tips

main
familyfriendlymikey 2 years ago
parent
commit
129df10c97
  1. 1
      app/api.imba
  2. 3
      app/components/app-home.imba
  3. 6
      app/components/app-link.imba
  4. 158
      app/components/app-links.imba
  5. 21
      app/components/app-tips.imba

1
app/api.imba

@ -316,4 +316,3 @@ export default new class api
catch e
err "deleting some link histories", e
imba.commit!

3
app/components/app-home.imba

@ -4,8 +4,7 @@ tag app-home
$home-input.focus!
def blur
# setTimeout(&, 100) do $home-input.focus!
p!
setTimeout(&, 100) do $home-input.focus!
def handle_paste e
return unless config.data.enable_search_on_paste

6
app/components/app-link.imba

@ -7,10 +7,6 @@ tag app-link
def handle_pin link
api.pin_link link
def handle_edit
return unless state.sorted_links.length > 0
refs.edit.open api.selected_link
def render
<self
@pointerover=api.set_link_selection_index(index)
@ -55,7 +51,7 @@ tag app-link
css .link-button svg w:15px
<.link-button@click.prevent.stop=handle_edit(link)>
<.link-button@click.prevent.stop=handle_edit>
<svg src='../assets/edit-2.svg'>
<.link-button@click.prevent.stop=handle_delete(link)>

158
app/components/app-links.imba

@ -1,82 +1,90 @@
tag app-links
def handle_edit
return unless state.sorted_links.length > 0
refs.edit.open api.selected_link
get tips
let result = []
let temp
temp = {
click_handler: api.handle_click_link.bind(api)
hotkey_handler: api.handle_click_link.bind(api)
hotkey: 'return'
hotkey_display_name: 'Return'
}
temp.content = api.selected_link.is_bang ? "Use Bang" : "Navigate To Link"
result.push temp
temp = {
click_handler: api.handle_add_link.bind(api)
hotkey_handler: api.handle_add_link.bind(api)
hotkey: 'shift+return'
hotkey_display_name: 'Shift + Return'
content: "Create Link \"{state.query.trim!}\""
}
result.push temp
temp = {
click_handler: handle_edit.bind(this)
hotkey_handler: handle_edit.bind(this)
hotkey: 'shift+backspace'
hotkey_display_name: "Shift + Backspace"
content: "Edit Link"
}
result.push temp
temp = {
click_handler: api.toggle_effective_names.bind(api)
hotkey_handler: api.toggle_effective_names.bind(api)
hotkey: 'tab'
hotkey_display_name: "Tab"
content: "Toggle Effective Names"
}
result.push temp
temp = {
click_handler: (do refs.settings.open!).bind(this)
hotkey_handler: (do refs.settings.open!).bind(this)
hotkey: 'shift+tab'
hotkey_display_name: "Shift + Tab"
content: "Toggle Settings"
}
result.push temp
temp = {
click_handler: api.handle_cut.bind(api)
}
if api.math_result
temp.hotkey_display_name = "Cut (If No Selection)"
temp.content = "Cut All Text"
else
temp.hotkey_display_name = "Cut (Math, If No Selection)"
temp.content = "Cut Math Result"
result.push temp
temp = {
hotkey_handler: api.increment_link_selection_index.bind(api)
hotkey: 'down'
hotkey_display_name: "Down Arrow"
content: "Move Selection Down"
}
result.push temp
temp = {
hotkey_handler: api.decrement_link_selection_index.bind(api)
hotkey: 'up'
hotkey_display_name: "Up Arrow"
content: "Move Selection Up"
}
result.push temp
result.push <>
<.tip
@click=api.handle_click_link
@hotkey('return').force=api.handle_click_link
>
<.tip-hotkey> "Return"
if api.selected_link.is_bang
<.tip-content> "Use Bang"
else
<.tip-content> "Navigate To Link"
result.push <>
<.tip
@click=api.handle_add_link
@hotkey('shift+return').force=api.handle_add_link
>
<.tip-hotkey> "Shift + Return"
<.tip-content.ellipsis>
<span[ws:pre]> "Create Link "
let sq = state.query.trim!.split /\s+/
if sq.length >= 2
let url = sq.pop!
<span> '"'
<span> sq.join " "
<span[c:blue3 ws:pre]> " {url}"
<span> '"'
else
<span> "\"{sq.join " "}\""
result.push <>
<.tip
@click=handle_edit
@hotkey('shift+backspace').force=handle_edit
>
<.tip-hotkey> "Shift + Backspace"
<.tip-content> "Edit Link"
result.push <>
<.tip
@click=api.toggle_effective_names
@hotkey('tab').force=api.toggle_effective_names
>
<.tip-hotkey> "Tab"
<.tip-content> "Toggle Effective Names"
result.push <>
<.tip
@click=refs.settings.open
@hotkey('shift+tab').force=refs.settings.open
>
<.tip-hotkey> "Shift + Tab"
<.tip-content> "Toggle Settings"
result.push <>
<.tip @click=api.handle_cut>
if api.math_result
<.tip-hotkey> "Cut (Math, If No Selection)"
<.tip-content> "Cut Math Result"
else
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
result.push <>
<.tip.noclick
@hotkey('down').force=api.increment_link_selection_index
@hotkey('up').force=api.decrement_link_selection_index
>
<.tip-hotkey> "Up/Down Arrow"
<.tip-content> "Move Selection"
result.push <>
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
temp = {
hotkey_display_name: "Paste (If Input Empty)"
content: "Instant Search"
}
result.push temp
result
@ -91,5 +99,5 @@ tag app-links
<.links>
css ofy:scroll
for link, index in state.sorted_links
<app-link link=link index=index>
<app-link link=link index=index handle_edit=handle_edit>

21
app/components/app-tips.imba

@ -8,13 +8,10 @@ tag app-tips
def toggle
show_more = not show_more
get placeholder
<.tip.placeholder>
def pad arr
let i = arr.length
while i < 3
arr.push placeholder
arr.push { placeholder: yes }
i += 1
def get_chunks
@ -54,7 +51,13 @@ tag app-tips
<.tip-row>
for tip in chunks[0]
<> tip
<.tip
.noclick=(not tip.click_handler)
@click.if(tip.click_handler)=tip.click_handler
@hotkey(tip.hotkey).if(tip.hotkey_handler and tip.hotkey).force=tip.hotkey_handler
>
<.tip-hotkey> tip.hotkey_display_name
<.tip-content> tip.content
if chunks.length > 1
@ -79,4 +82,10 @@ tag app-tips
for row in chunks.slice(1)
<.tip-row>
for tip in row
<> tip
<.tip
.noclick=(not tip.click_handler)
@click.if(tip.click_handler)=tip.click_handler
@hotkey(tip.hotkey).if(tip.hotkey_handler and tip.hotkey).force=tip.hotkey_handler
>
<.tip-hotkey> tip.hotkey_display_name
<.tip-content> tip.content

Loading…
Cancel
Save