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.

75 lines
1.6 KiB

tag app-home
def mount
2 years ago
$home-input.focus!
def blur
# setTimeout(&, 100) do $home-input.focus!
p!
def handle_paste e
return unless config.data.enable_search_on_paste
return if state.query.length > 0
global.setTimeout(&, 0) do
return if api.math_result isnt no
bang ||= config.data.default_bang
handle_bang!
def handle_click_copy s
try
await window.navigator.clipboard.writeText(s)
state.query = ''
api.sort_links!
def handle_input
2 years ago
state.bang_selection_index = -1
api.set_link_selection_index 0
api.sort_links!
def render
<self>
2 years ago
css w:100% d:flex fld:column ofy:hidden gap:20px
<.header>
css d:flex fld:row w:100%
2 years ago
css .side c:$button-c fs:15px d:flex ja:center w:30px cursor:pointer
css .side svg w:15px d:flex
css .left jc:left
css .right jc:right
<.side.left@click=api.toggle_effective_names>
if config.data.enable_effective_names
<svg src="../assets/eye.svg">
else
<svg src="../assets/eye-off.svg">
2 years ago
<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
2 years ago
@blur=blur
>
if state.query.startsWith "!"
css c:$bang-c
if (let m = api.math_result) isnt no
<.side.right@click=handle_click_copy(m)>
"= {Math.round(m * 100)/100}"
2 years ago
css c:$text-c fs:20px ml:10px w:unset
else
<.side.right @click.if(!state.loading)=refs.settings.open>
<svg src="../assets/settings.svg">
if state.active_bang or state.sorted_links.length < 1
<app-bang>
else
<app-links>