Browse Source

refactor

main
familyfriendlymikey 2 years ago
parent
commit
b4e08f656f
  1. 2
      app/api.imba
  2. 2
      app/client.imba
  3. 10
      app/components/app-bang.imba
  4. 22
      app/components/app-edit.imba
  5. 9
      app/components/app-home.imba
  6. 16
      app/components/app-links.imba
  7. 1
      app/components/app-tips.imba

2
app/api.imba

@ -237,4 +237,4 @@ export default new class api
def unset_active_bang
state.active_bang = no
api.sort_links!
sort_links!

2
app/client.imba

@ -6,6 +6,8 @@ p "fuzzyhome version {version}"
# import sw from './sw.imba?serviceworker'
# navigator..serviceWorker..register(sw).then! do |reg| reg.update!
p "hehe"
import { nanoid } from 'nanoid'
import { err } from './utils'

10
app/components/app-bang.imba

@ -33,7 +33,7 @@ tag app-bang
if state.active_bang
<.tip
@click=api.unset_active_bang
@hotkey('esc').capture.if(!state.loading)=unset_active_bang
@hotkey('esc').capture.if(!state.loading)=api.unset_active_bang
>
<.tip-hotkey> "Esc"
<.tip-content> "Back"
@ -59,6 +59,14 @@ tag app-bang
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
tips.push <>
<.tip
@click.if(!state.loading)=refs.settings.open
@hotkey('shift+tab').capture.if(!state.loading)=refs.settings.open
>
<.tip-hotkey> "Shift + Tab"
<.tip-content> "Toggle Settings"
if state.active_bang
tips.push <>
<.tip.noclick>

22
app/components/app-edit.imba

@ -1,8 +1,11 @@
tag app-edit
get render? do mounted?
active = no
def mount
$dn.setSelectionRange 0, 0
$dn.focus!
def open data
link = data
new_link_text = value=api.construct_link_text(link)
@ -11,11 +14,6 @@ tag app-edit
def close
active = no
def mount
setTimeout(&, 40) do
$dn.focus!
imba.commit!
def handle_click_set_default_bang
config.set_default_bang link
close!
@ -59,16 +57,6 @@ tag app-edit
<.tip-hotkey> "Click"
<.tip-content> "Set Default Bang"
else
tips.push <>
<.tip
@click=close
@hotkey('esc').capture.if(!state.loading)=close
>
<.tip-hotkey> "Esc"
<.tip-content> "Cancel"
if link.is_bang
tips.push <>
<.tip
@click=close
@ -85,6 +73,6 @@ tag app-edit
css d:flex fld:column gap:20px w:100%
<div>
<input$dn bind=new_link_text>
<input$dn autofocus bind=new_link_text>
<app-tips tips=tips>

9
app/components/app-home.imba

@ -1,7 +1,10 @@
tag app-home
def mount
$links-input.focus!
$home-input.focus!
def blur
setTimeout(&, 100) do $home-input.focus!
def handle_paste e
return unless config.data.enable_search_on_paste
@ -41,12 +44,14 @@ tag app-home
else
<svg src="../assets/eye-off.svg">
<input$links-input
<input$home-input
autofocus
bind=state.query
@input.if(!state.loading)=handle_input
@paste.if(!state.loading)=handle_paste
@cut=api.handle_cut
disabled=state.loading
@blur=blur
>
if (let m = api.math_result) isnt no

16
app/components/app-links.imba

@ -14,14 +14,6 @@ tag app-links
get tips
let tips = []
tips.push <>
<.tip
@click=api.handle_click_link
@hotkey('return').force.if(!loading)=api.handle_click_link
>
<.tip-hotkey> "Return"
<.tip-content> "Navigate To Link"
tips.push <>
<.tip
@click=api.handle_add_link
@ -40,6 +32,14 @@ tag app-links
else
<span> "\"{sq.join " "}\""
tips.push <>
<.tip
@click=api.handle_click_link
@hotkey('return').force.if(!loading)=api.handle_click_link
>
<.tip-hotkey> "Return"
<.tip-content> "Navigate To Link"
tips.push <>
<.tip
@click=handle_edit

1
app/components/app-tips.imba

@ -2,6 +2,7 @@ import { chunk, fill } from 'lodash'
tag app-tips
def unmount
show_more = no
def toggle

Loading…
Cancel
Save