Browse Source

refactor

main
familyfriendlymikey 2 years ago
parent
commit
3b016afb85
  1. 18
      app/components/app-bang.imba
  2. 78
      app/components/app-community-links.imba
  3. 12
      app/components/app-edit.imba
  4. 20
      app/components/app-links.imba
  5. 41
      app/components/app-settings.imba

18
app/components/app-bang.imba

@ -1,9 +1,9 @@
tag app-bang
get tips
let tips = []
let result = []
tips.push <>
result.push <>
<.tip
@click=api.handle_bang
@hotkey('return').capture.if(!state.loading)=api.handle_bang
@ -11,7 +11,7 @@ tag app-bang
<.tip-hotkey> "Return"
<.tip-content> "Search"
tips.push <>
result.push <>
<.tip
@click=api.handle_add_link
@hotkey('shift+return').capture.if(!state.loading)=api.handle_add_link
@ -29,7 +29,7 @@ tag app-bang
else
<span> "\"{sq.join " "}\""
tips.push <>
result.push <>
if state.active_bang
<.tip
@click=api.unset_active_bang
@ -42,7 +42,7 @@ tag app-bang
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
tips.push <>
result.push <>
<.tip
@click.if(!state.loading)=api.toggle_effective_names
@hotkey('tab').capture.if(!state.loading)=api.toggle_effective_names
@ -50,7 +50,7 @@ tag app-bang
<.tip-hotkey> "Tab"
<.tip-content> "Toggle Effective Names"
tips.push <>
result.push <>
<.tip @click.if(!loading)=api.handle_cut>
if api.math_result
<.tip-hotkey> "Cut (Math, If No Selection)"
@ -59,7 +59,7 @@ tag app-bang
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
tips.push <>
result.push <>
<.tip
@click.if(!state.loading)=refs.settings.open
@hotkey('shift+tab').capture.if(!state.loading)=refs.settings.open
@ -68,12 +68,12 @@ tag app-bang
<.tip-content> "Toggle Settings"
if state.active_bang
tips.push <>
result.push <>
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
tips
result
def render

78
app/components/app-community-links.imba

@ -1,11 +1,15 @@
let p = console.log
import links from '../assets/community_links'
import fzi from 'fzi'
tag app-community-links
active = no
active = yes
selection_index = 0
def mount
$cli.focus!
def open
active = yes
@ -29,48 +33,41 @@ tag app-community-links
await api.reload_db!
imba.commit!
def render
get tips
let result = []
<self
@hotkey('esc').capture.if(!loading)=close
@hotkey('down').capture.if(!loading)=increment_selection_index
@hotkey('up').capture.if(!loading)=decrement_selection_index
>
result.push <>
<.tip @click=close>
<.tip-hotkey> "Esc"
<.tip-content> "Exit Community Links"
css self
d:flex fld:column jc:start fl:1
w:100% ofy:auto pt:15px
result.push <>
<.tip @click=handle_shift_return>
<.tip-hotkey> "Shift + Return Or Click"
<.tip-content> "Add To Your Links"
css .link
d:flex fld:row jc:space-between ai:center
px:16px py:11px rd:5px cursor:pointer c:blue3
min-height:35px
result.push <>
<.tip.noclick
@hotkey('down').capture.if(!state.loading)=increment_selection_index
@hotkey('up').capture.if(!state.loading)=decrement_selection_index
>
<.tip-hotkey> "Up/Down Arrow"
<.tip-content> "Move Selection"
css .link-left
fl:1
result
css .link-right
fl:1
overflow-wrap:anywhere
word-break:break-all
def render
css .bang
c:#FAD4AB
<self>
css d:flex fld:column jc:start gap:15px fl:1 w:100% ofy:hidden
css .selected
bg:blue3/5
<div>
<input$cli autofocus>
<.tips>
<.tip[jc:start ta:center fl:1]
@click=handle_esc
>
<.tip-hotkey> "Esc"
<.tip-content> "Exit Community Links"
<.tip[jc:end ta:center fl:1]
@click=handle_shift_return
>
<.tip-hotkey> "Shift + Return"
<.tip-content> "Add To Your Links"
<app-tips tips=tips>
<.links>
css ofy:auto
for link_text, index in links
<.link
@ -78,6 +75,15 @@ tag app-community-links
@pointerover=(selection_index = index)
@click=(add_community_link(link_text))
>
css d:flex fld:row jc:space-between ai:center px:16px
py:11px rd:5px cursor:pointer c:blue3 min-height:35px
let { url, rest } = get_link_obj link_text
<.link-left .bang=rest.startsWith("!")> rest
<.link-left> rest
css fl:1
if rest.startsWith("!")
css c:#FAD4AB
<.link-right> url
css fl:1 overflow-wrap:anywhere word-break:break-all

12
app/components/app-edit.imba

@ -33,9 +33,9 @@ tag app-edit
err "saving link", e
get tips
let tips = []
let result = []
tips.push <>
result.push <>
<.tip
@click=handle_delete
@hotkey('shift+backspace').capture.if(!state.loading)=handle_delete
@ -43,7 +43,7 @@ tag app-edit
<.tip-hotkey> "Shift + Backspace"
<.tip-content> "Delete Link"
tips.push <>
result.push <>
<.tip
@click=save
@hotkey('return').capture.if(!state.loading)=save
@ -52,12 +52,12 @@ tag app-edit
<.tip-content> "Update Link"
if link.is_bang
tips.push <>
result.push <>
<.tip @click=handle_click_set_default_bang>
<.tip-hotkey> "Click"
<.tip-content> "Set Default Bang"
tips.push <>
result.push <>
<.tip
@click=close
@hotkey('esc').capture.if(!state.loading)=close
@ -65,7 +65,7 @@ tag app-edit
<.tip-hotkey> "Esc"
<.tip-content> "Cancel"
tips
result
def render

20
app/components/app-links.imba

@ -12,9 +12,9 @@ tag app-links
refs.edit.open api.selected_link
get tips
let tips = []
let result = []
tips.push <>
result.push <>
<.tip
@click=api.handle_add_link
@hotkey('shift+return').capture.if(!state.loading)=api.handle_add_link
@ -32,7 +32,7 @@ tag app-links
else
<span> "\"{sq.join " "}\""
tips.push <>
result.push <>
<.tip
@click=api.handle_click_link
@hotkey('return').force.if(!loading)=api.handle_click_link
@ -40,7 +40,7 @@ tag app-links
<.tip-hotkey> "Return"
<.tip-content> "Navigate To Link"
tips.push <>
result.push <>
<.tip
@click=handle_edit
@hotkey('shift+backspace').capture.if(!state.loading)=handle_edit
@ -48,7 +48,7 @@ tag app-links
<.tip-hotkey> "Shift + Backspace"
<.tip-content> "Edit Link"
tips.push <>
result.push <>
<.tip
@click.if(!state.loading)=api.toggle_effective_names
@hotkey('tab').capture.if(!state.loading)=api.toggle_effective_names
@ -56,7 +56,7 @@ tag app-links
<.tip-hotkey> "Tab"
<.tip-content> "Toggle Effective Names"
tips.push <>
result.push <>
<.tip
@click.if(!state.loading)=refs.settings.open
@hotkey('shift+tab').capture.if(!state.loading)=refs.settings.open
@ -64,7 +64,7 @@ tag app-links
<.tip-hotkey> "Shift + Tab"
<.tip-content> "Toggle Settings"
tips.push <>
result.push <>
<.tip @click.if(!loading)=api.handle_cut>
if api.math_result
<.tip-hotkey> "Cut (Math, If No Selection)"
@ -73,7 +73,7 @@ tag app-links
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
tips.push <>
result.push <>
<.tip.noclick
@hotkey('down').capture.if(!state.loading)=api.increment_link_selection_index
@hotkey('up').capture.if(!state.loading)=api.decrement_link_selection_index
@ -81,12 +81,12 @@ tag app-links
<.tip-hotkey> "Up/Down Arrow"
<.tip-content> "Move Selection"
tips.push <>
result.push <>
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
tips
result
def render

41
app/components/app-settings.imba

@ -76,7 +76,8 @@ tag app-settings
def render
<self[w:100%]>
<self>
css w:100%
css .settings-container
d:flex fld:row jc:space-around ai:center
@ -94,19 +95,23 @@ tag app-settings
if refs.community-links.active
<app-community-links>
else
<.settings-container>
<.settings-button
@click=close
@hotkey("esc")=close
@hotkey("shift+tab")=close
> "BACK"
<.settings-container>
<.settings-button
@click.if(!loading)=$community-links.open
>
<.settings-button @click.if(!loading)=(refs.community-links.open! and close!)>
"VIEW COMMUNITY LINKS"
<.settings-container>
<label.settings-button>
"IMPORT"
<input[d:none]
@ -115,21 +120,21 @@ tag app-settings
@click=(this.value = '')
type="file"
>
<.settings-button
@click.if(!loading)=handle_click_export
> "EXPORT"
<.settings-button @click.if(!loading)=handle_click_export>
"EXPORT"
<.settings-container>
<.settings-button
@click.if(!loading)=handle_click_github
> "TUTORIAL"
<.settings-button
@click.if(!loading)=handle_click_github
> "GITHUB"
<.settings-button @click.if(!loading)=handle_click_github>
"TUTORIAL"
<.settings-button @click.if(!loading)=handle_click_github>
"GITHUB"
<.settings-container>
<.settings-button @click=handle_click_toggle_tips>
let t= p config.data
config.data.enable_tips ? "DISABLE TIPS" : "ENABLE TIPS"
<.settings-button @click=handle_click_toggle_buttons>
@ -137,12 +142,8 @@ tag app-settings
<.settings-container>
<.settings-button
@click=handle_click_toggle_search_on_paste
>
<.settings-button @click=handle_click_toggle_search_on_paste>
config.data.enable_search_on_paste ? "DISABLE SEARCH ON PASTE" : "ENABLE SEARCH ON PASTE"
<.settings-button
@click.if(!loading)=handle_toggle_light_theme
>
<.settings-button @click.if(!loading)=handle_toggle_light_theme>
config.data.enable_dark_theme ? "DISABLE DARK THEME" : "ENABLE DARK THEME"

Loading…
Cancel
Save