Browse Source

refactor

main
familyfriendlymikey 2 years ago
parent
commit
a5a637c2a2
  1. 8
      app/api.imba
  2. 19
      app/components/app-bang.imba
  3. 21
      app/components/app-home.imba
  4. 2
      app/components/app-link.imba
  5. 23
      app/components/app-links.imba
  6. 1
      app/components/app-settings.imba

8
app/api.imba

@ -205,3 +205,11 @@ export default new class api
catch e
err "adding link", e
state.loading = no
def handle_click_link
let link = selected_link
if link.is_bang
state.query = ''
state.active_bang = link
else
navigate link

19
app/components/app-bang.imba

@ -1,8 +1,7 @@
tag app-bang
get bang
return active_bang if state.active_bang
config.data.default_bang
state.active_bang or config.data.default_bang
get encoded_bang_query
"{bang.url}{window.encodeURIComponent(state.query)}"
@ -22,8 +21,8 @@ tag app-bang
<.tip-row>
<.tip
@click=(state.active_bang = no)
@hotkey('esc').capture.if(!state.loading)=(state.active_bang = no)
@click=handle_bang
@hotkey('return').capture.if(!state.loading)=handle_bang
>
<.tip-hotkey> "Return"
<.tip-content> "Search"
@ -53,12 +52,9 @@ tag app-bang
<.tip-hotkey> "Esc"
<.tip-content> "Back"
else
<.tip
@click.if(!state.loading)=refs.settings.open
@hotkey('esc').capture.if(!state.loading)=refs.settings.open
>
<.tip-hotkey> "Esc"
<.tip-content> "Toggle Settings"
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
<app-tips-more$tips-more>
@ -81,9 +77,12 @@ tag app-bang
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
if state.active_bang
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
else
<.tip.placeholder>
unless $tips-more.active
<.bang.selected@click=handle_bang>

21
app/components/app-home.imba

@ -21,27 +21,6 @@ tag app-home
api.set_link_selection_index 0
api.sort_links!
def handle_click_link
if state.active_bang or state.sorted_links.length < 1
return handle_bang!
let link = api.selected_link
if link.is_bang
state.query = ''
state.active_bang = link
else
api.navigate link
def handle_click_delete link
return unless window.confirm "Do you really want to delete {link..display_name}?"
handle_delete link
def handle_click_pin link
api.pin_link link
def handle_shift_backspace
return unless state.sorted_links.length > 0
refs.edit.open api.selected_link
def render
<self>

2
app/components/app-link.imba

@ -3,7 +3,7 @@ tag app-link
def render
<self
@pointerover=api.set_link_selection_index(index)
@click=handle_click
@click=api.handle_click_link
.selected=(index is state.link_selection_index)
>
css d:flex fld:row jc:space-between ai:center

23
app/components/app-links.imba

@ -1,5 +1,16 @@
tag app-links
def handle_click_delete link
return unless window.confirm "Do you really want to delete {link..display_name}?"
handle_delete link
def handle_click_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>
@ -10,8 +21,8 @@ tag app-links
<.tip-row>
<.tip
@click=handle_click_link
@hotkey('return').force.if(!loading)=handle_click_link
@click=api.handle_click_link
@hotkey('return').force.if(!loading)=api.handle_click_link
>
<.tip-hotkey> "Return"
<.tip-content> "Navigate To Link"
@ -34,8 +45,8 @@ tag app-links
<span> "\"{sq.join " "}\""
<.tip
@click=handle_shift_backspace
@hotkey('shift+backspace').capture.if(!state.loading)=handle_shift_backspace
@click=handle_edit
@hotkey('shift+backspace').capture.if(!state.loading)=handle_edit
>
<.tip-hotkey> "Shift + Backspace"
<.tip-content> "Edit Link"
@ -53,9 +64,9 @@ tag app-links
<.tip
@click.if(!state.loading)=refs.settings.open
@hotkey('esc').capture.if(!state.loading)=refs.settings.open
@hotkey('shift+tab').capture.if(!state.loading)=refs.settings.open
>
<.tip-hotkey> "Esc"
<.tip-hotkey> "Shift + Tab"
<.tip-content> "Toggle Settings"
<.tip.noclick

1
app/components/app-settings.imba

@ -98,6 +98,7 @@ tag app-settings
<.settings-button
@click=close
@hotkey("esc")=close
@hotkey("shift+tab")=close
> "BACK"
<.settings-container>
<.settings-button

Loading…
Cancel
Save