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. 154
      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 catch e
err "deleting some link histories", e err "deleting some link histories", e
imba.commit! imba.commit!

3
app/components/app-home.imba

@ -4,8 +4,7 @@ tag app-home
$home-input.focus! $home-input.focus!
def blur def blur
# setTimeout(&, 100) do $home-input.focus! setTimeout(&, 100) do $home-input.focus!
p!
def handle_paste e def handle_paste e
return unless config.data.enable_search_on_paste 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 def handle_pin link
api.pin_link link api.pin_link link
def handle_edit
return unless state.sorted_links.length > 0
refs.edit.open api.selected_link
def render def render
<self <self
@pointerover=api.set_link_selection_index(index) @pointerover=api.set_link_selection_index(index)
@ -55,7 +51,7 @@ tag app-link
css .link-button svg w:15px 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'> <svg src='../assets/edit-2.svg'>
<.link-button@click.prevent.stop=handle_delete(link)> <.link-button@click.prevent.stop=handle_delete(link)>

154
app/components/app-links.imba

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