feat: the Kanban on the phone follows the phone mockup
All checks were successful
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Successful in 3m40s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 56s

- Top bar with the logo, search and filters; at the bottom Produção,
  Cotações, Pagamentos, Números and "Mais" (Integrações, Usuários, the
  machine, the theme, the password, Sair) in a sheet.
- Produção: the stages as chips, the stage's metres and the session's
  machine over the cards, the queue's download as a button, the
  filters (product included) in a sheet.
- The order as a page: back, the order and its stage, the next step
  with its buttons at the bottom, the facts as rows, WhatsApp, Arquivos
  and Histórico; its actions in a sheet. A quote opens the same way.
- Pagamentos as cards, Números as the mockup's figures, chart and
  lists, Usuários as a list, Integrações as cards, the search as a page,
  dialogs as sheets, and the sign-in with the sheet rolling on top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-31 15:00:08 -03:00
parent f5c8bcfb90
commit 0b8eb143ad
3 changed files with 426 additions and 95 deletions

View File

@@ -137,6 +137,7 @@ const IC={
rework:'M15.5 7.5A6 6 0 0 0 4.25 9 M4.5 12.5A6 6 0 0 0 15.75 11 M15.75 3.75V7.5H12 M4.25 16.25V12.5H8',
back:'M8 5L4 9l4 4 M4 9h8a4 4 0 0 1 0 8h-2',
ban:C(10,10,7.25)+' M5 15L15 5',
logout:'M8 3.25H3.75v13.5H8 M12 6.5l3.5 3.5-3.5 3.5 M15.5 10H7.5',
printer:'M5.75 7.5V3h8.5v4.5 M5.75 14H3V7.5h14V14h-2.75 M5.75 11.25h8.5v5.75h-8.5z',
eye:'M2.5 10s2.75-5.25 7.5-5.25S17.5 10 17.5 10s-2.75 5.25-7.5 5.25S2.5 10 2.5 10z '+C(10,10,2.25),
edit:'M12.5 4l3.5 3.5L7.5 16H4v-3.5z M10.5 6l3.5 3.5',
@@ -592,9 +593,10 @@ async function load(quiet=false){
// The page's name in the top bar; Produção also says what is open.
const PAGE_TITLES={board:'Produção',quotes:'Cotações',payments:'Pagamentos',stats:'Números',integrations:'Integrações',users:'Usuários'};
function showTab(name){
tab=name;
tab=name;$('tab-quotes').classList.remove('reviewing');
for(const b of document.querySelectorAll('[data-tab]'))b.setAttribute('aria-selected',String(b.dataset.tab===name));
$('page-title').textContent=PAGE_TITLES[name];$('board-summary').hidden=name!=='board';
$('page-title').textContent=PAGE_TITLES[name];$('board-summary').hidden=name!=='board';$('filter-open').hidden=name!=='board';
$('more-nav').classList.toggle('on',['integrations','users'].includes(name));
for(const id of ['board','quotes','payments','stats','integrations','users'])$('tab-'+id).hidden=name!==id;
const lists={quotes:loadQuotes,payments:loadIssues,stats:loadStats,integrations:eventsIfAllowed,users:loadUsers};
if(board&&lists[name])lists[name]().catch(e=>say(e.message,true));
@@ -607,6 +609,7 @@ function render(){
$('badge-quotes').textContent=board.pending_total?String(board.pending_total):'';
$('badge-payments').textContent=board.payment_issues_total?String(board.payment_issues_total):'';
tinyHeader();renderBoard();renderIntegrations();
$('badge-more').textContent=$('badge-integrations').textContent;
// Lists live on their own pages of the API; refresh the one being looked at.
const lists={quotes:loadQuotes,payments:loadIssues,stats:loadStats,integrations:eventsIfAllowed,users:loadUsers};
if(lists[tab])lists[tab]().catch(e=>say(e.message,true));
@@ -755,6 +758,7 @@ function renderFilters(){
if(used.length>1){const all=node('button','Limpar','btn ghost');all.type='button';all.onclick=clearFilters;tags.push(all);}
$('filter-tags').replaceChildren(...tags);
$('filter-count').hidden=!used.length;$('filter-count').textContent=String(used.length);
const all=used.length+(boardFilter.product?1:0);$('filter-dot').hidden=!all;$('filter-dot').textContent=String(all);
$('filter-btn').classList.toggle('on',used.length>0);
if(!$('filter-pop').hidden)filterCounts();
}
@@ -795,6 +799,14 @@ function renderBoard(){
// Finished orders are a recent window, not the whole history: the count is the whole.
head.append(node('span',String(state==='fin'&&!filtered?Math.max(board.finished_total||0,orders.length):orders.length),'coln'));
column.append(head);
// The phone's line over the cards: this stage's metres and the session's machine.
const sum=node('div',undefined,'msum');const total=node('span');
total.append(node('b',state==='fin'?plural(orders.length,'pedido','pedidos'):metres(orders.reduce((t,o)=>t+orderMetres(o),0))),state==='fin'?' recentes':' nesta etapa');
sum.append(total);
if(myMachine()){const m=node('span',undefined,'right mcell');m.append(node('i',undefined,'mdot'),'Máquina ',node('b',myMachine().name));sum.append(m);}
column.append(sum);
if(state==='tra'&&may('print')&&orders.length){
const dl=button('Baixar os arquivos da fila',downloadQueue,'btn mdl');dl.prepend(svgIcon(IC.download,'i m'));column.append(dl);}
if(state==='imp')column.append(...printingLanes(orders));
else if(state==='fin')column.append(...orders.map(miniCard));
else column.append(...orders.map((o,i)=>card(o,state==='tra'?queuePlace(o,orders):null)));
@@ -1114,6 +1126,76 @@ function dropField(input,{title='Arraste o arquivo para cá',hint=''}={}){
return l;
}
// ---- Phone (the design canvas' phone screens) -------------------------------
// Under 700 px the Kanban is the phone mockup: sections at the bottom, menus
// and filters as sheets from the bottom, the order and the quote as pages.
const PHONE=matchMedia('(max-width:700px)');
PHONE.addEventListener('change',()=>{if(board)render();});
// A sheet from the bottom: the grab, then what it holds. Escape or the scrim closes.
function sheet(parts,{label='',role='dialog',onclose}={}){
const scrim=node('div',undefined,'mscrim');
const box=node('div',undefined,'msheet');box.setAttribute('role',role);if(label)box.setAttribute('aria-label',label);
box.append(node('span',undefined,'grab'),...parts);
const entry={box,host:document.body,close(){const i=MODALS.indexOf(entry);if(i<0)return;MODALS.splice(i,1);scrim.remove();box.remove();onclose?.();}};
scrim.onclick=()=>entry.close();
MODALS.push(entry);document.body.append(scrim,box);return entry;
}
// A row of a phone sheet: an icon, the words, and maybe something on the right.
function mrow(d,text,fn,className='mrow',end=null){
const b=node('button',undefined,className);b.type='button';b.setAttribute('role','menuitem');
b.append(svgIcon(d),node('span',text,'mtext'),...(end?[end]:[]));
b.onclick=async()=>{try{await fn();}catch(e){say(e.message,true);}};return b;
}
// "Mais": who is signed in, the sections that do not fit the bar, the machine,
// the theme, the password and Sair.
function phoneMenu(){
let m=null;
const go=fn=>async()=>{m.close();await fn();};
const who=node('div',undefined,'who sheetwho'),words=node('span');
const ava=node('span',initialsOf(ME.name||ME.email),'ava');ava.append(node('i',undefined,'pres on'));
words.append(node('b',ME.name||ME.email),node('span',(ROLE_NAMES[ME.role]||ME.role)+(myMachine()?', na '+myMachine().name:''),'sub'));
who.append(ava,words);
const rows=[];
if(TAB_NEEDS.integrations()){const n=$('badge-integrations').textContent;
rows.push(mrow(IC.link,'Integrações',go(()=>showTab('integrations')),'mrow',n?statePill(n,'warn'):null));}
if(TAB_NEEDS.users())rows.push(mrow(IC.user,'Usuários',go(()=>showTab('users'))));
if(ME.machine_question)rows.push(mrow(IC.printer,'Trocar de máquina',go(()=>askMachine(true)),'mrow',node('span',myMachine()?.name||'','lbl')));
const light=kanbanTheme.get()==='light';
rows.push(mrow(light?ICON_MOON:ICON_SUN,light?'Mudar para o modo escuro':'Mudar para o modo claro',go(()=>{kanbanTheme.toggle();paintThemeToggle();})));
rows.push(mrow(IC.key,'Trocar a senha',go(accountForm)));
rows.push(mrow(IC.logout,'Sair',go(()=>$('logout').click()),'mrow bad'));
const body=node('div',undefined,'sbody');body.append(...rows);
m=sheet([who,body],{label:'Mais',role:'menu'});
}
// The board's filters on the phone: every kind, the product too, and how many
// orders they show.
function phoneFilters(){
const kinds=[{key:'product',label:'Produto',options:PRODUCTS.filter(([v])=>v)},...filterKinds()];
const body=node('div',undefined,'sbody');
const show=node('button','','btn pri');show.type='button';
const paint=()=>{
body.replaceChildren(...kinds.map(kind=>{
const group=node('div',undefined,'fgroup'),opts=node('div',undefined,'fopts');
for(const [value,text] of kind.options){
const on=boardFilter[kind.key]===value;
const b=node('button',text,'fopt'+(on?' on':''));b.type='button';b.setAttribute('aria-pressed',String(on));
b.append(node('span',String(filterCount({...boardFilter,[kind.key]:value})),'n'));
b.onclick=()=>{boardFilter[kind.key]=on?'':value;renderBoard();paint();};opts.append(b);
}
group.append(node('span',kind.label),opts);return group;}));
show.textContent='Ver '+plural(filterCount(boardFilter),'pedido','pedidos');
};
const close=iconButton(IC.close,'Fechar',()=>m.close(),'mic right');
const head=node('div',undefined,'shead');head.append(node('b','Filtros'),close);
const clear=node('button','Limpar','btn');clear.type='button';clear.onclick=()=>{for(const k in boardFilter)boardFilter[k]='';renderBoard();paint();};
const foot=node('div',undefined,'sfoot');foot.append(clear,show);
const m=sheet([head,body,foot],{label:'Filtros'});show.onclick=()=>m.close();
paint();
}
$('more-nav').onclick=()=>phoneMenu();
$('filter-open').onclick=()=>phoneFilters();
// ---- Order panel ---------------------------------------------------------
// The panel's tab stays while the same order is open.
@@ -1169,6 +1251,11 @@ function renderPanel(order){
if(at>=0&&i<at)li.classList.add('done');if(i===at)li.classList.add('now');steps.append(li);}
if(order.state==='cor')steps.classList.add('paused');
const head=node('div',undefined,'dhead');head.append(top,sub,steps);
// The phone's head: back, the order and where it is, its menu.
const mhead=node('div',undefined,'mhead phone'),mt=node('span',undefined,'t');
mt.append(node('b','#'+order.number+' '+who.title),node('span',(order.cancelled_at?'Cancelado':stateName(order.state))+', '+money(s.total_cents)+(isTest(order)?' de teste':' pago')));
const phoneMore=moreMenu(order,'mic');
mhead.append(iconButton(IC.left,'Voltar',closePanel,'mic'),mt,...(phoneMore?[phoneMore]:[]));
const body=node('div',undefined,'dbody');
if(order.cancelled_at)body.append(cancelledNotice(order));
@@ -1187,16 +1274,28 @@ function renderPanel(order){
for(const [key,view] of Object.entries(views))view.hidden=key!==panelTab;};
paintTabs();
body.append(tabs,...Object.values(views));
// On the phone the order is one page; its files and history open as sheets.
let fileRows=null,historyRows=null;
const mbtns=node('div',undefined,'mbtns phone');
const zap=whatsappLink(s.customer.zap);
if(zap){const a=node('a','WhatsApp','btn');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.prepend(svgIcon(IC.chat,'i m'));mbtns.append(a);}
const sheetOf=(title,fill)=>()=>{const box=node('div',undefined,'sbody pad');fill(box);
const m=sheet([sheetHead(title,()=>m.close()),box],{label:title});};
const files=node('button','Arquivos','btn');files.type='button';files.onclick=sheetOf('Arquivos',box=>fileRows?filesView(order,fileRows,box):box.append(node('p','Carregando…','lbl')));
const hist=node('button','Histórico','btn');hist.type='button';hist.onclick=sheetOf('Histórico',box=>historyRows?historyView(order,historyRows,box):box.append(node('p','Carregando…','lbl')));
mbtns.append(files,hist);body.append(mbtns);
// A re-render keeps where the body was scrolled.
const scrolled=panel.querySelector('.dbody')?.scrollTop||0;
panel.replaceChildren(head,body);body.scrollTop=scrolled;
panel.replaceChildren(mhead,head,body);body.scrollTop=scrolled;
api('/orders/'+order.id+'/files').then(rows=>{if(token!==openToken)return;filesView(order,rows,views.files);
api('/orders/'+order.id+'/files').then(rows=>{if(token!==openToken)return;fileRows=rows;filesView(order,rows,views.files);
tabs.querySelector('[data-ptab=files] .n').textContent=rows.length?String(rows.length):'';}).catch(e=>say(e.message,true));
api('/orders/'+order.id+'/history').then(rows=>{if(token===openToken)historyView(order,rows,views.history);}).catch(e=>say(e.message,true));
api('/orders/'+order.id+'/history').then(rows=>{if(token===openToken){historyRows=rows;historyView(order,rows,views.history);}}).catch(e=>say(e.message,true));
}
// A phone sheet's title line with its close button.
function sheetHead(title,close){const h=node('div',undefined,'shead');h.append(node('b',title),iconButton(IC.close,'Fechar',close,'mic right'));return h;}
// The order's own menu: the rare things, some of them destructive.
function moreMenu(order){
function moreMenu(order,buttonClass='btn sq ghost'){
const items=[];
const item=(d,text,fn,className='menuitem')=>{const b=node('button',undefined,className);b.type='button';b.setAttribute('role','menuitem');
b.append(svgIcon(d,'i m'),text);b.onclick=async e=>{e.stopPropagation();menu.hidden=true;try{await fn();}catch(err){say(err.message,true);}};items.push(b);return b;};
@@ -1218,7 +1317,7 @@ function moreMenu(order){
const last=items.at(-1);if(last.classList.contains('bad')&&items.length>1)items.splice(-1,0,node('div',undefined,'menusep'));
menu.append(...items);
const b=iconButton(IC.more,'Mais ações',()=>{menu.hidden=!menu.hidden;b.setAttribute('aria-expanded',String(!menu.hidden));
if(!menu.hidden)document.addEventListener('click',()=>{menu.hidden=true;b.setAttribute('aria-expanded','false');},{once:true});});
if(!menu.hidden)document.addEventListener('click',()=>{menu.hidden=true;b.setAttribute('aria-expanded','false');},{once:true});},buttonClass);
b.setAttribute('aria-haspopup','menu');b.setAttribute('aria-expanded','false');
const wrap=node('span',undefined,'morewrap');wrap.append(b,menu);return wrap;
}
@@ -1567,7 +1666,20 @@ function orderView(order){
if(order.reworks?.length)view.append(reworkSection(order));
return view;
}
// On the phone: one row per fact, the label on the left.
function phoneFacts(order){
const s=order.snapshot, dest=s.destination, who=buyer(s);
const box=node('div',undefined,'mblock mfacts');
const row=(k,v)=>{if(!v)return;const r=node('div',undefined,'mfact');r.append(node('span',k),node('b',v));box.append(r);};
row('Cliente',who.title);row('E-mail',s.customer.mail);row(docKind(s.customer.cnpj),cnpj(s.customer.cnpj));
row('Entrega',dest?dest.city+'/'+dest.state:'Retirada em Franca');
row('Máquina',order.machine?.name||'Nenhuma');row('Código','DTF-'+order.number+', cliente '+orderCode(order.id));
// Choosing the machine stays where it is allowed.
if(may('print')&&ME?.role!=='operador'&&board.machines?.length){const m=machineCard(order).querySelector('select');if(m)box.append(m);}
return box;
}
function orderFacts(order){
if(PHONE.matches)return phoneFacts(order);
const s=order.snapshot, dest=s.destination, who=buyer(s);
const grid=node('div',undefined,'facts3');
const client=node('div',undefined,'fact');
@@ -1898,6 +2010,15 @@ function renderUsers(){
node('td',u.last_login_at?ago(u.last_login_at):'nunca entrou','muted'),open);
return tr;
}));
// On the phone, a list of people, each a row that opens them.
const list=$('users-phone');list.replaceChildren(...users.map(u=>{
const editable=u.role!=='superadmin'||ME.role==='superadmin';
const row=node('button',undefined,'mli');row.type='button';row.disabled=!editable;if(editable)row.onclick=()=>userForm(u);
const words=node('span',undefined,'grow'),sub=node('span',undefined,'sub mcell');
sub.append(ROLE_NAMES[u.role]+(u.active?'':', desativado'));
if(u.machines.length){sub.append(node('i',undefined,'mdot'),u.machines.map(machineName).join(', '));}
words.append(node('b',u.name||u.email),sub);
row.append(avatar(u),words,svgIcon(IC.right,'i m'));return row;}));
const head=node('tr');head.append(node('th',''));for(const r of ROLE_COLUMNS)head.append(node('th',ROLE_NAMES[r]));
for(const th of head.children)th.scope='col';head.firstChild.append(node('span','Ação','vh'));
const thead=node('thead');thead.append(head);const tbody=node('tbody');
@@ -2198,7 +2319,8 @@ function statsChart(box,daily){
if(avg>0){const a=node('span',undefined,'avg');a.style.bottom=100*avg/ceiling+'%';plot.append(a);}
const bars=node('div',undefined,'bars'),axis=node('div',undefined,'axis');axis.setAttribute('aria-hidden','true');
bars.style.gridTemplateColumns=axis.style.gridTemplateColumns='repeat('+daily.length+',minmax(0,1fr))';
const every=Math.ceil(daily.length/10);
// A phone has room for fewer dates under the bars.
const every=Math.ceil(daily.length/(PHONE.matches?5:10));
daily.forEach((d,i)=>{
const b=node('span',undefined,'bar'+(d.day===today?' now':''));b.style.height=(d.metres>0?Math.max(1,100*d.metres/ceiling):0)+'%';
b.style.animationDelay=Math.min(i*12,400)+'ms';
@@ -2303,7 +2425,8 @@ function renderQuotes(){
// Approved by the Site is the rule; only a person's review is worth a word.
if(pay||q.approved&&!q.auto_approved){const line=node('span',undefined,'qpay');
if(pay)line.append(pay);if(q.approved&&!q.auto_approved)line.append(badge('Revisada pela equipe',''));main.append(line);}
b.append(artBox(items,'qthumb'),main);b.onclick=()=>{currentQuote=q;renderQuotes();};return b;
b.append(artBox(items,'qthumb'),main);
b.onclick=()=>{currentQuote=q;$('tab-quotes').classList.toggle('reviewing',PHONE.matches);renderQuotes();};return b;
});
const filtered=quoteQuery||quoteProduct||quoteLayout||quoteFlag;
if(!list.length)list.push(node('p',filtered?'Nenhuma cotação com esses filtros.':
@@ -2312,13 +2435,23 @@ function renderQuotes(){
$('quote-pager').replaceChildren(...(quoteTotal?[pager({page:quotePage,size:quoteSize,total:quoteTotal,noun:'cotações',compact:true,fixedSize:true,
onPage:n=>{quotePage=n;quoteFitting=0;loadQuotes().catch(e=>say(e.message,true));}})]:[]));
requestAnimationFrame(fitQuotes);
$('reviews').replaceChildren(...(currentQuote?review(currentQuote):[emptyState(IC.file,'Selecione uma cotação','A revisão dela abre aqui.')]));
if(!currentQuote)$('tab-quotes').classList.remove('reviewing');
$('reviews').replaceChildren(...(currentQuote?[quoteHead(currentQuote),...review(currentQuote)]:[emptyState(IC.file,'Selecione uma cotação','A revisão dela abre aqui.')]));
}
// A page or a pane with nothing to show: a mark, a line, and what to do.
function emptyState(d,title,text){
const box=node('div',undefined,'emptystate'),ico=node('span',undefined,'dropico');ico.append(svgIcon(d));
box.append(ico,node('b',title),...(text?[node('span',text)]:[]));return box;
}
// The phone's head of a quote's page: back to the list, who, and WhatsApp.
function quoteHead(quote){
const h=node('div',undefined,'mhead phone'),t=node('span',undefined,'t'),who=buyer(quote.draft);
t.append(node('b',who.title),node('span',productLine(quote.draft.items)+', recebida '+ago(quote.created_at)));
h.append(iconButton(IC.left,'Voltar',()=>$('tab-quotes').classList.remove('reviewing'),'mic'),t);
const zap=whatsappLink(quote.draft.customer.zap);
if(zap){const a=node('a',undefined,'mic');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.setAttribute('aria-label','WhatsApp');a.append(svgIcon(IC.chat));h.append(a);}
return h;
}
const QUOTE_STATUS={pending_review:['A revisar','warn'],approved:['Aprovada, aguardando pagamento','ok'],expired:['Expirada','bad'],paid:['Paga','ok']};
function review(quote){
const head=node('div',undefined,'rhead');head.dataset.quote=quote.id;
@@ -2573,6 +2706,20 @@ function renderIssues(){
issueState==='open'?'Quando um pagamento precisar de alguém, ele aparece aqui.':''));
return;
}
// On the phone each payment is a card.
if(PHONE.matches){
$('payments').replaceChildren(tools,...issueRows.map(issue=>{
const card=node('div',undefined,'mblock pcard'),refused=issue.outcome.startsWith('refused');
const top=node('div',undefined,'prow');top.append(issue.resolved_at?statePill('Resolvido','ok'):statePill(refused?'Recusado':'Atenção',refused?'bad':'warn'),node('span',when(issue.received_at),'lbl right'));
const mid=node('div',undefined,'prow base');
mid.append(node('b',issue.reference?'Cotação '+String(issue.reference).slice(0,8):'Sem cotação','grow'),node('b',issue.amount_cents==null?'Sem valor':money(issue.amount_cents)));
card.append(top,mid,node('span',issue.provider+', evento '+issue.event_id,'sub'),node('p',outcomeText(issue.outcome),'nnote'));
if(issue.resolved_at)card.append(node('span','Por '+issue.resolved_by+' em '+when(issue.resolved_at)+': '+issue.resolution,'sub'));
else if(may('manage'))card.append(button('Registrar resolução',async()=>resolveDialog(issue),'btn wide'));
return card;}),pager({page:issuePage,size:issueSize,total:issueTotal,noun:'pagamentos',compact:true,fixedSize:true,
onPage:n=>{issuePage=n;loadIssues().catch(e=>say(e.message,true));}}));
return;
}
const table=node('table',undefined,'table');
const head=node('tr');for(const [t,c] of [['Quando'],['O que aconteceu'],['Referência'],['Valor pago','r'],['']]){const th=node('th',t,c);th.scope='col';head.append(th);}
const thead=node('thead');thead.append(head);const tbody=node('tbody');
@@ -2760,6 +2907,7 @@ for(const b of document.querySelectorAll('[data-tab]'))b.onclick=()=>showTab(b.d
// ---- Search: orders (any stage) and unpaid quotes ---------------------------
// On a phone the search is behind a button, and opens over the top bar.
$('search-back').onclick=()=>{$('search').value='';closeSearch();document.querySelector('.top').classList.remove('searching');$('search-open').setAttribute('aria-expanded','false');};
$('search-open').onclick=()=>{const on=document.querySelector('.top').classList.toggle('searching');
$('search-open').setAttribute('aria-expanded',String(on));if(on)$('search').focus();};
@@ -2785,7 +2933,7 @@ function hitRow(items,title,sub,meta,state,tone,open){
const text=node('span',undefined,'rtext');text.append(node('b',title),node('span',sub,'sub'),node('span',meta,'rmeta'));
el.append(artBox(items,'qthumb rart'),text,badge(state,tone));
el.onmousedown=e=>e.preventDefault();
el.onclick=()=>{closeSearch();open();};
el.onclick=()=>{closeSearch();document.querySelector('.top').classList.remove('searching');open();};
return {el,open};
}
function orderHit(order){
@@ -2820,7 +2968,7 @@ $('search').onkeydown=e=>{
}
if(e.key==='Enter'){e.preventDefault();const hit=searchHits[Math.max(0,searchAt)];closeSearch();hit.open();}
};
$('search').onblur=()=>setTimeout(()=>{closeSearch();if(!$('search').value.trim())document.querySelector('.top').classList.remove('searching');},150);
$('search').onblur=()=>setTimeout(()=>{closeSearch();if(!$('search').value.trim()&&!PHONE.matches)document.querySelector('.top').classList.remove('searching');},150);
$('search').onfocus=()=>{if($('search').value.trim().length>=2&&searchHits.length){$('search-results').hidden=false;$('search').setAttribute('aria-expanded','true');}};
// "/" jumps to the search, as the field shows, unless typing somewhere else.
document.addEventListener('keydown',e=>{