You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.3 KiB

2 years ago
tag app-bang
2 years ago
def unmount
state.bang_selection_index = -1
2 years ago
get tips
2 years ago
let result = []
2 years ago
2 years ago
if state.bang_selection_index > -1
result.push <>
<.tip
@click=api.handle_bang
@hotkey('return').force=api.handle_bang
2 years ago
>
<.tip-hotkey> "Return"
<.tip-content> "Use History Item"
2 years ago
else
result.push <>
<.tip
@click=api.handle_bang
@hotkey('return').force=api.handle_bang
2 years ago
>
<.tip-hotkey> "Return"
<.tip-content> "Search"
2 years ago
2 years ago
result.push <>
2 years ago
<.tip.ellipsis
2 years ago
@click=api.handle_add_link
@hotkey('shift+return').force=api.handle_add_link
2 years ago
>
<.tip-hotkey> "Shift + Return"
<.tip-content.ellipsis>
<span[ws:pre]> "Create Link "
let sq = state.query.trim!.split /\s+/
if sq.length >= 2
let url = sq.pop!
<span> '"'
<span> sq.join " "
<span[c:blue3 ws:pre]> " {url}"
<span> '"'
else
<span> "\"{sq.join " "}\""
if state.bang_selection_index > -1
result.push <>
<.tip
@click=api.delete_bang_history_item
@hotkey('shift+backspace').force=api.delete_bang_history_item
>
<.tip-hotkey> "Shift + Backspace"
<.tip-content> "Delete History Item"
if state.active_bang
result.push <>
2 years ago
<.tip
@click=api.unset_active_bang
@hotkey('esc').force=api.unset_active_bang
2 years ago
>
<.tip-hotkey> "Esc"
<.tip-content> "Back"
2 years ago
result.push <>
<.tip@click=(api.delete_bang_history! and $tips.show_more = no)>
<.tip-hotkey> "Click"
<.tip-content> "Delete Bang History"
result.push <>
<.tip @click=api.handle_cut>
2 years ago
if api.math_result
<.tip-hotkey> "Cut (Math, If No Selection)"
<.tip-content> "Cut Math Result"
else
<.tip-hotkey> "Cut (If No Selection)"
<.tip-content> "Cut All Text"
result.push <>
<.tip.noclick>
<.tip-hotkey> "Paste (If Input Empty)"
<.tip-content> "Instant Search"
2 years ago
2 years ago
result
2 years ago
def render
2 years ago
<self
@hotkey("tab").force=api.increment_bang_selection_index
@hotkey("up").force=api.decrement_bang_selection_index
@hotkey("down").force=api.increment_bang_selection_index
@hotkey("shift+tab").force=api.decrement_bang_selection_index
>
css w:100% d:flex fld:column gap:15px ofy:hidden
2 years ago
<app-tips$tips tips=tips>
2 years ago
unless $tips.show_more
2 years ago
<.bang
.selected=(state.bang_selection_index is -1)
[c:$bang-c]=(state.bang_selection_index is -1)
@pointerover=(state.bang_selection_index = -1)
2 years ago
@click=api.handle_bang
>
css d:flex fld:row jc:space-between ai:center
2 years ago
px:16px py:11px rd:5px cursor:pointer c:$text-c
2 years ago
<.link-left>
2 years ago
css d:flex fl:1 ofy:hidden
2 years ago
2 years ago
<img.link-icon src=api.bang.icon>
css w:20px h:20px mr:10px rd:3px
2 years ago
<.display-name> "...{api.encoded_bang_query_nourl}"
2 years ago
css fs:20px of:hidden text-overflow:ellipsis
2 years ago
<.link-right>
css d:flex fld:row jc:space-between ai:center
2 years ago
2 years ago
<.frequency> api.bang.frequency
css fs:15px ml:7px
2 years ago
<.history>
css d:flex fld:column jc:start ai:center ofy:auto
2 years ago
for item, index in api.sorted_bang_history
<.item
@pointerover=(state.bang_selection_index = index)
@click=api.handle_bang
[c:$bang-c]=(state.bang_selection_index is index)
.selected=(state.bang_selection_index is index)
> item
2 years ago
css w:100% fs:17px c:$text-c rd:5px p:10px 10px
box-sizing:border-box cursor:pointer