Browse Source

refactor

main
familyfriendlymikey 2 years ago
parent
commit
3b016afb85
  1. 18
      app/components/app-bang.imba
  2. 108
      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 tag app-bang
get tips get tips
let tips = [] let result = []
tips.push <> result.push <>
<.tip <.tip
@click=api.handle_bang @click=api.handle_bang
@hotkey('return').capture.if(!state.loading)=api.handle_bang @hotkey('return').capture.if(!state.loading)=api.handle_bang
@ -11,7 +11,7 @@ tag app-bang
<.tip-hotkey> "Return" <.tip-hotkey> "Return"
<.tip-content> "Search" <.tip-content> "Search"
tips.push <> result.push <>
<.tip <.tip
@click=api.handle_add_link @click=api.handle_add_link
@hotkey('shift+return').capture.if(!state.loading)=api.handle_add_link @hotkey('shift+return').capture.if(!state.loading)=api.handle_add_link
@ -29,7 +29,7 @@ tag app-bang
else else
<span> "\"{sq.join " "}\"" <span> "\"{sq.join " "}\""
tips.push <> result.push <>
if state.active_bang if state.active_bang
<.tip <.tip
@click=api.unset_active_bang @click=api.unset_active_bang
@ -42,7 +42,7 @@ tag app-bang
<.tip-hotkey> "Paste (If Input Empty)" <.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search" <.tip-content> "Instant Search"
tips.push <> result.push <>
<.tip <.tip
@click.if(!state.loading)=api.toggle_effective_names @click.if(!state.loading)=api.toggle_effective_names
@hotkey('tab').capture.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-hotkey> "Tab"
<.tip-content> "Toggle Effective Names" <.tip-content> "Toggle Effective Names"
tips.push <> result.push <>
<.tip @click.if(!loading)=api.handle_cut> <.tip @click.if(!loading)=api.handle_cut>
if api.math_result if api.math_result
<.tip-hotkey> "Cut (Math, If No Selection)" <.tip-hotkey> "Cut (Math, If No Selection)"
@ -59,7 +59,7 @@ tag app-bang
<.tip-hotkey> "Cut (If No Selection)" <.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text" <.tip-content> "Cut All Text"
tips.push <> result.push <>
<.tip <.tip
@click.if(!state.loading)=refs.settings.open @click.if(!state.loading)=refs.settings.open
@hotkey('shift+tab').capture.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" <.tip-content> "Toggle Settings"
if state.active_bang if state.active_bang
tips.push <> result.push <>
<.tip.noclick> <.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)" <.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search" <.tip-content> "Instant Search"
tips result
def render def render

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

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

12
app/components/app-edit.imba

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

20
app/components/app-links.imba

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

41
app/components/app-settings.imba

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

Loading…
Cancel
Save