File tree and editor
A dark editor with folders that open and close, the active and modified files marked, tabs, and a status line. Stacks when the column is narrow.
export default {
crew: "reyes-framing",
currency: "USD",
rounding: "line",
reminders: [7, 14, 30],
// Sync offline sheets
sync: { every: "15m" },
};
TypeScriptLn 5, Col 25
The code
Plain HTML and CSS on your kit's variables. Put it next to tokens/variables.css from your kit's files and it draws in your look.
<div class="ukc-code-file-tree">
<div class="ide">
<nav class="tree" aria-label="Project files">
<p class="proj">halden-app</p>
<ul>
<li><details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>src</summary><ul>
<li><details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>jobs</summary><ul>
<li><a href="#">sheet.ts</a></li>
<li><a href="#" class="mod">sync.ts<span class="sr"> (modified)</span></a></li>
</ul></details></li>
<li><a href="#">invoices.ts</a></li>
</ul></details></li>
<li><details><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>tests</summary><ul><li><a href="#">totals.test.ts</a></li></ul></details></li>
<li><a href="#" class="on" aria-current="page">halden.config.ts</a></li>
<li><a href="#">package.json</a></li>
</ul>
</nav>
<div class="ed">
<div class="tabs"><a class="tab on" href="#" aria-current="page">halden.config.ts</a><a class="tab" href="#">sync.ts<span class="dot"></span><span class="sr"> (unsaved)</span></a></div>
<pre class="src"><code><span class="l"><span class="k">export default</span> {</span>
<span class="l"> crew: <span class="s">"reyes-framing"</span>,</span>
<span class="l"> currency: <span class="s">"USD"</span>,</span>
<span class="l"> rounding: <span class="s">"line"</span>,</span>
<span class="l cur"> reminders: [<span class="n">7</span>, <span class="n">14</span>, <span class="n">30</span>]<span class="caret" aria-hidden="true"></span>,</span>
<span class="l"> <span class="c">// Sync offline sheets</span></span>
<span class="l"> sync: { every: <span class="s">"15m"</span> },</span>
<span class="l">};</span></code></pre>
<p class="status"><span>TypeScript</span><span>Ln 5, Col 25</span></p>
</div>
</div>
</div>
.ukc-code-file-tree { position: relative; font-family: var(--uk-font-body, system-ui, sans-serif); color: var(--uk-ink); font-size: 15px; line-height: 1.5;
--tint: color-mix(in srgb, var(--uk-accent) 12%, var(--uk-paper));
--tint-strong: color-mix(in srgb, var(--uk-accent) 22%, var(--uk-paper));
--accent-deep: color-mix(in srgb, var(--uk-accent) 72%, black);
--ink-soft: color-mix(in srgb, var(--uk-ink) 8%, var(--uk-paper));
--line-strong: color-mix(in srgb, var(--uk-ink) 32%, var(--uk-paper));
--danger-tint: color-mix(in srgb, var(--uk-danger) 12%, var(--uk-paper));
--high-tint: color-mix(in srgb, var(--uk-highlight) 28%, var(--uk-paper)); }
.ukc-code-file-tree *, .ukc-code-file-tree *::before, .ukc-code-file-tree *::after { box-sizing: border-box; }
.ukc-code-file-tree :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) { margin: 0; }
.ukc-code-file-tree :where(ul, ol) { padding: 0; list-style: none; }
.ukc-code-file-tree :where(button, input, select, textarea) { font: inherit; color: inherit; }
.ukc-code-file-tree :where(a) { color: inherit; }
.ukc-code-file-tree svg { flex: none; }
.ukc-code-file-tree .sr { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ukc-code-file-tree { container-type: inline-size; inline-size: 100%; }
.ukc-code-file-tree .ide { display: grid; grid-template-columns: clamp(136px, 34%, 184px) minmax(0, 1fr); max-width: 640px; border: var(--uk-border-width) solid color-mix(in srgb, var(--uk-ink) 30%, black); border-radius: var(--uk-radius-lg); overflow: hidden; background: color-mix(in srgb, var(--uk-ink) 12%, black); color: color-mix(in srgb, var(--uk-paper) 15%, white); box-shadow: var(--uk-card-shadow); }
.ukc-code-file-tree .tree { min-width: 0; padding: 10px 6px 12px; border-right: 1px solid color-mix(in srgb, white 12%, transparent); background: color-mix(in srgb, white 4%, transparent); font-size: 12.5px; line-height: 1.5; }
.ukc-code-file-tree .proj { padding: 0 6px 6px; color: color-mix(in srgb, white 50%, transparent); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.ukc-code-file-tree .tree ul ul { padding-left: 10px; }
.ukc-code-file-tree .tree summary, .ukc-code-file-tree .tree a { display: flex; align-items: center; gap: 4px; padding: 2px 6px; overflow: hidden; border-radius: min(var(--uk-radius-sm), 4px); color: color-mix(in srgb, white 78%, transparent); text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--uk-motion-duration) var(--uk-motion-ease); }
.ukc-code-file-tree .tree summary { list-style: none; }
.ukc-code-file-tree .tree summary::-webkit-details-marker { display: none; }
.ukc-code-file-tree .tree summary svg { color: color-mix(in srgb, white 45%, transparent); transition: transform var(--uk-motion-duration) var(--uk-motion-ease); }
.ukc-code-file-tree .tree details[open] > summary svg { transform: rotate(90deg); }
.ukc-code-file-tree .tree a { padding-left: 22px; }
.ukc-code-file-tree .tree summary:hover, .ukc-code-file-tree .tree a:hover { background: color-mix(in srgb, white 7%, transparent); }
.ukc-code-file-tree .tree a.on { background: color-mix(in srgb, white 11%, transparent); box-shadow: inset 2px 0 0 color-mix(in srgb, var(--uk-accent) 55%, white); color: white; }
.ukc-code-file-tree .tree a.mod::after { content: "M"; margin-left: auto; color: var(--uk-highlight); font: 600 10.5px/1 var(--uk-font-mono, ui-monospace, monospace); }
.ukc-code-file-tree .tree summary:focus-visible, .ukc-code-file-tree .tree a:focus-visible, .ukc-code-file-tree .tab:focus-visible { outline: 2px solid color-mix(in srgb, var(--uk-accent) 55%, white); outline-offset: -2px; }
.ukc-code-file-tree .ed { display: flex; flex-direction: column; min-width: 0; }
.ukc-code-file-tree .tabs { display: flex; overflow-x: auto; border-bottom: 1px solid color-mix(in srgb, white 12%, transparent); }
.ukc-code-file-tree .tab { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-right: 1px solid color-mix(in srgb, white 12%, transparent); color: color-mix(in srgb, white 55%, transparent); font: 12px/1.5 var(--uk-font-mono, ui-monospace, monospace); text-decoration: none; white-space: nowrap; }
.ukc-code-file-tree .tab.on { background: color-mix(in srgb, white 5%, transparent); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--uk-accent) 55%, white); color: white; }
.ukc-code-file-tree .dot { width: 7px; height: 7px; border-radius: var(--uk-radius-full); background: var(--uk-highlight); }
.ukc-code-file-tree .src { margin: 0; overflow-x: auto; font: 12px/1.7 var(--uk-font-mono, ui-monospace, monospace); tab-size: 2; }
.ukc-code-file-tree .src code { display: grid; width: max-content; min-width: 100%; font: inherit; }
.ukc-code-file-tree .src .l { min-height: 1.7em; padding: 0 16px; white-space: pre; }
.ukc-code-file-tree .src code { counter-reset: ln; }
.ukc-code-file-tree .src .l { padding-left: 0; }
.ukc-code-file-tree .src .l::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 5ch; padding-right: 2ch; text-align: right; color: color-mix(in srgb, white 35%, transparent); user-select: none; }
.ukc-code-file-tree .src { flex: 1; padding: 10px 0; }
.ukc-code-file-tree .src .l::before { width: 4.5ch; padding-right: 1.5ch; }
.ukc-code-file-tree .src .cur { background: color-mix(in srgb, white 6%, transparent); }
.ukc-code-file-tree .src .cur::before { color: white; }
.ukc-code-file-tree .caret { display: inline-block; width: 2px; height: 1.25em; margin: 0 -1px; vertical-align: -0.28em; background: color-mix(in srgb, var(--uk-accent) 55%, white); }
.ukc-code-file-tree .src .k { color: color-mix(in srgb, var(--uk-accent) 55%, white); }
.ukc-code-file-tree .src .s, .ukc-code-file-tree .src .n { color: color-mix(in srgb, var(--uk-highlight) 80%, white); }
.ukc-code-file-tree .src .c { color: color-mix(in srgb, white 50%, transparent); font-style: italic; }
.ukc-code-file-tree .src .f { color: white; font-weight: 600; }
.ukc-code-file-tree .status { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; border-top: 1px solid color-mix(in srgb, white 12%, transparent); color: color-mix(in srgb, white 50%, transparent); font: 11px/1.5 var(--uk-font-mono, ui-monospace, monospace); }
@container (max-width: 380px) { .ukc-code-file-tree .ide { grid-template-columns: minmax(0, 1fr); } .ukc-code-file-tree .tree { border-right: 0; border-bottom: 1px solid color-mix(in srgb, white 12%, transparent); } }
More code blocks
All 24- POST
/v2/invoicesCreate an invoice from a signed-off job sheet.Request
Authorization: Bearer $HALDEN_KEY Content-Type: application/json { "job": "JS-2207", "due_days": 30, "send": true }Response
{ "id": "inv_0418", "number": "INV-0418", "status": "sent", "total": 2140.00, "currency": "USD", "pdf": "/v2/invoices/inv_0418.pdf" }{ "error": "job_not_signed_off", "message": "JS-2207 has no sign-off yet", "field": "job" }201 Created · 184 ms422 Unprocessable · 61 ms
- job-sheet.json1.2 kB
{ 7 keys }
"id": "JS-2207","site": "14 Alder St","signed_off": true,"crew": [ 2 items ],
"Ines Ortega","Dana Whitfield"],"hours": { 3 keys },
"labor": 22.5,"travel": 1.5,"overtime": 0},"materials": [ 2 items ],
{ 3 keys },
"sku": "OAK-WT-30","qty": 1,"unit_cost": 41800},{ 3 keys }
"sku": "2x6-PT-12","qty": 40,"unit_cost": 1145}],"invoice": null}Path
$.materials[1].qty Step 3Handle the webhook
export async function POST(req: Request) { const raw = await req.text(); const event = verify(raw, req.headers); (note 1) if (event.type === "invoice.paid") { (note 2) await markPaid(event.invoice); } return new Response(null, { status: 204 }); (note 3) }Note 1:
verifythrows if the signature or timestamp is off, so a forged call never reaches your code.Note 2: Check the type first. New event types get added, so skip the ones you don't handle.
Note 3: Answer within 10 seconds. Slow or failed deliveries are retried for three days.
TypeError: Cannot read properties of undefined (reading 'rate')
lineTotalsrc/totals.ts:15:23
export function lineTotal(l: Line) { const price = PRICES[l.sku]; return l.qty * price.rate; ^^^^^ price is undefined }buildInvoicesrc/invoices.ts:42:18
for (const line of sheet.lines) { totals.push(lineTotal(line)); }POSTapp/api/invoices/route.ts:18:9
const sheet = await getSheet(body.job); const draft = buildInvoice(sheet);3 frames in node_modules
- handle @halden/sdk/dist/http.js:88:11
- dispatch router-lite/index.js:41:7
- run router-lite/index.js:12:3
- .env.local4 of 5 set
- # Halden, test mode
-
HALDEN_API_KEY=hidden, ends in 4f9chld_test_8Kq2Vn5x4f9c HALDEN_ENV=test-
DB_PASSWORD=hiddenlocal-dev-only - # Webhooks
HALDEN_WEBHOOK_SECRET=Empty Webhook checks fail until this is set. Copy it from Settings, then Webhooks.