feat: the Kanban's frame, a rail of sections and a new top bar (redesign, step 1)
All checks were successful
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 54s
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m54s

The sections move from tabs in the top bar to a rail on the left, with
an icon each, the counters for Cotações, Pagamentos and Integrações, the
light/dark switch and the account button at the bottom. Its menu holds
"Trocar de máquina", the theme, "Minha senha" and "Sair". The machine of
the session shows in the rail and as a chip in the top bar, both opening
the machine question.

The top bar carries the page's name (Produção also says what is open:
"13 pedidos, 17,40 m em produção"), the search, Tiny only when it needs
attention, and "Atualizado às 09:18": a click there sets how often it
updates by itself, over the same remembered setting, or updates now.
The pages' own headings are gone; on narrow screens the rail lies along
the top until their own layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-31 09:19:45 -03:00
parent 05139b71ff
commit c76d2fa7f3
3 changed files with 165 additions and 80 deletions

View File

@@ -562,7 +562,8 @@ async function load(quiet=false){
board.orders.push(...olderFinished.filter(o=>!known.has(o.id)));
if(finishedMore===null)finishedMore=board.finished_total>board.finished_shown;
$('login').hidden=true;$('app').hidden=false;
if(!quiet)say('Atualizado às '+new Date().toLocaleTimeString('pt-BR')+tinyNotice,false,tinyNotice?6000:2500);
$('sync-at').textContent='Atualizado às '+new Date().toLocaleTimeString('pt-BR',{hour:'2-digit',minute:'2-digit'});
if(!quiet&&tinyNotice)say(tinyNotice.replace(/^ · /,''),false,6000);
render();
askMachine();
syncFolder();
@@ -573,9 +574,12 @@ async function load(quiet=false){
say(e.message,true);
}
}
// 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;
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';
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));
@@ -584,7 +588,6 @@ function render(){
$('who').textContent=ME?(ME.name||ME.email):'';
$('who-role').textContent=ME?(ROLE_NAMES[ME.role]||ME.role)+' · '+ME.email:'';
$('initials').textContent=ME?((ME.name||ME.email).trim().split(/\s+/).slice(0,2).map(w=>w[0]).join('').toUpperCase()):'·';
$('count-board').textContent=String(board.orders.filter(o=>o.state!=='fin'&&!o.cancelled_at).length);
$('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();
@@ -762,7 +765,8 @@ function renderBoard(){
renderFilters();
const active=board.orders.filter(o=>['rec','tra','imp'].includes(o.state));
const queued=active.reduce((s,o)=>s+o.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0),0);
$('board-summary').textContent=metres(queued)+' em produção';
const open=board.orders.filter(o=>o.state!=='fin'&&!o.cancelled_at).length;
$('board-summary').textContent=plural(open,'pedido','pedidos')+', '+metres(queued)+' em produção';
$('kan').replaceChildren(...Object.entries(board.states).map(([state,title])=>{
const column=node('section',undefined,'col');column.dataset.state=state;column.style.setProperty('--c',STAGE_COLORS[state]);
// A queue: the order paid first is on top, the newest at the bottom, however
@@ -1495,14 +1499,18 @@ function askMachine(again=false){
}
// The machine beside the account button: green, and a click changes it.
function paintMyMachine(){
const pill=$('my-machine');
pill.hidden=!ME?.machine_question;
if(pill.hidden)return;
pill.replaceChildren(icon(ICON_PRINTER),myMachine()?myMachine().name:'Sem máquina');
pill.classList.toggle('on',!!myMachine());
pill.title=myMachine()?'Você está na '+myMachine().name+'. Clique para trocar.':'Você não está em máquina. Clique para escolher.';
const asked=!!ME?.machine_question, mine=myMachine();
for(const id of ['my-machine','rail-machine','account-machine'])$(id).hidden=!asked;
if(!asked)return;
const name=mine?mine.name:'Sem máquina';
const chip=$('my-machine');chip.replaceChildren(node('i'),'Máquina ',node('b',name));
chip.classList.toggle('on',!!mine);
chip.title=mine?'Você está na '+mine.name+'. Clique para trocar.':'Você não está em máquina. Clique para escolher.';
const rail=$('rail-machine');rail.querySelector('b').textContent=mine?mine.name:'Nenhuma';rail.classList.toggle('on',!!mine);rail.title=chip.title;
$('account-machine').querySelector('.lbl').textContent=mine?mine.name:'';
}
$('my-machine').onclick=()=>askMachine(true);
for(const id of ['my-machine','rail-machine'])$(id).onclick=()=>askMachine(true);
$('account-machine').onclick=()=>{$('account-menu').hidden=true;askMachine(true);};
// The order's machine: chosen, or the first that prints its product.
function machineCard(order){
@@ -1646,9 +1654,18 @@ function passwordForm(){
});
}
$('my-password').onclick=()=>{$('account-menu').hidden=true;passwordForm();};
// Dark or light, per browser (web/theme.js); the menu names the one a click gives.
function paintThemeToggle(){$('theme-toggle').textContent=kanbanTheme.get()==='light'?'Tema escuro':'Tema claro';}
// Dark or light, per browser (web/theme.js): the rail's button and the account
// menu name the one a click gives.
const ICON_SUN='M6.75 10a3.25 3.25 0 1 0 6.5 0a3.25 3.25 0 1 0 -6.5 0 M10 2v1.75 M10 16.25V18 M2 10h1.75 M16.25 10H18 M4.35 4.35l1.24 1.24 M14.41 14.41l1.24 1.24 M4.35 15.65l1.24-1.24 M14.41 5.59l1.24-1.24';
const ICON_MOON='M16.25 12.25A6.75 6.75 0 0 1 7.75 3.75a6.75 6.75 0 1 0 8.5 8.5z';
function paintThemeToggle(){
const light=kanbanTheme.get()==='light', label=light?'Mudar para o modo escuro':'Mudar para o modo claro';
for(const id of ['theme-rail','theme-toggle'])$(id).querySelector('path').setAttribute('d',light?ICON_MOON:ICON_SUN);
$('theme-rail').setAttribute('aria-label',label);$('theme-rail').title=label;
$('theme-toggle').querySelector('span').textContent=light?'Modo escuro':'Modo claro';
}
$('theme-toggle').onclick=()=>{$('account-menu').hidden=true;kanbanTheme.toggle();paintThemeToggle();};
$('theme-rail').onclick=()=>{kanbanTheme.toggle();paintThemeToggle();};
paintThemeToggle();
$('account').onclick=e=>{e.stopPropagation();const m=$('account-menu');m.hidden=!m.hidden;
if(!m.hidden)document.addEventListener('click',()=>{m.hidden=true;},{once:true});};
@@ -2011,9 +2028,8 @@ if(tinyResult)history.replaceState(null,'',location.pathname);
function tinyHeader(){
const t=board.tiny||{};const el=$('tiny');
if(!t.configured){el.textContent='';return;}
const trouble=!t.connected||t.problem;
el.textContent=!t.connected?'Tiny não conectado':t.problem?'Tiny: verificar conexão':'Tiny conectado';
el.style.setProperty('--dot',trouble?'var(--warn)':'var(--fin)');
el.textContent=!t.connected?'Tiny não conectado':t.problem?'Tiny: verificar conexão':'';
el.style.setProperty('--dot','var(--warn)');
}
const TINY_PROBLEMS={refused:'O Tiny recusou a renovação da conexão. Conecte de novo.',
expired:'A conexão com o Tiny expirou. Conecte de novo.',
@@ -2408,8 +2424,22 @@ function scheduleAuto(){
$('refresh-every').value=[...$('refresh-every').options].some(o=>o.value===saved)?saved:'30';
$('refresh-every').onchange=()=>{
try{localStorage.setItem('dtf-refresh-every',$('refresh-every').value);}catch(_){}
scheduleAuto();$('refresh-every').blur();
scheduleAuto();paintSync();
};
scheduleAuto();
scheduleAuto();paintSync();
})();
function paintSync(){
const every=$('refresh-every'), on=every.value!=='0';
$('sync').classList.toggle('off',!on);
$('sync').title=on?'Atualiza sozinho '+every.selectedOptions[0].textContent.toLowerCase()+'. Clique para mudar.':'Não atualiza sozinho. Clique para mudar.';
$('sync-every').replaceChildren(...[...every.options].map(o=>{
const b=node('button',undefined,'menuitem');b.type='button';b.setAttribute('role','menuitemradio');
b.setAttribute('aria-checked',String(o.value===every.value));b.append(node('span',o.textContent));
if(o.value===every.value)b.append(icon(ICON_OK));
b.onclick=()=>{$('sync-menu').hidden=true;every.value=o.value;every.dispatchEvent(new Event('change'));};
return b;}));
}
$('sync').onclick=e=>{e.stopPropagation();const m=$('sync-menu');m.hidden=!m.hidden;$('sync').setAttribute('aria-expanded',String(!m.hidden));
if(!m.hidden)document.addEventListener('click',()=>{m.hidden=true;$('sync').setAttribute('aria-expanded','false');},{once:true});};
$('refresh').addEventListener('click',()=>{$('sync-menu').hidden=true;});
restoreFolder().finally(()=>load());