Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355// Scrolling showcase: overflow, wheel and keyboard scrolling, draggable// scrollbar thumbs, scroll events, script scrolling, and focus.
const setStyles = (node, styles) => { for (const [property, value] of Object.entries(styles)) { node.style.setProperty(property, value); }};
const element = (tag, styles = {}, attributes = {}) => { const node = app.createElement(tag); setStyles(node, styles); for (const [name, value] of Object.entries(attributes)) { node.setAttribute(name, value); } return node;};
// Burokku design system, dark theme. Burokku has no CSS variables, so each// value is the resolved colour of the token named beside it.const color = { bg: { canvas: "#16171dff", // bg/canvas surface: "#1b1c22ff", // bg/surface sunken: "#0f1014ff", // bg/sunken hover: "#222329ff", // bg/hover selected: "#2e2f36ff", // bg/selected accentSubtle: "#3d1408ff", // bg/accent-subtle infoSubtle: "#152640ff", // bg/info-subtle successSubtle: "#17301bff", // bg/success-subtle warningSubtle: "#362808ff", // bg/warning-subtle dangerSubtle: "#2b1d16ff", // bg/danger-subtle }, text: { primary: "#f6f6f7ff", // text/primary secondary: "#929295ff", // text/secondary tertiary: "#67676cff", // text/tertiary accent: "#ff6a45ff", // text/accent info: "#8fb0e8ff", // text/info success: "#8cc67aff", // text/success warning: "#f2c25bff", // text/warning danger: "#c9a088ff", // text/danger }, border: { subtle: "#222329ff", // border/subtle default: "#2e2f36ff", // border/default strong: "#4b4b52ff", // border/strong accent: "#ff6a45ff", // border/accent focus: "#8fb0e8ff", // border/focus info: "#8fb0e8ff", // border/info success: "#8cc67aff", // border/success warning: "#f2c25bff", // border/warning danger: "#c9a088ff", // border/danger },};
// App text styles. Noto Sans is the only font the examples bundle.const type = { h3: { "font-size": "22px", "line-height": "30px", "font-weight": "bold" }, // App/Heading/H3 bodySmall: { "font-size": "14px", "line-height": "20px" }, // App/Body/Small labelDefault: { "font-size": "14px", "line-height": "20px", "font-weight": "bold" }, // App/Label/Default caption: { "font-size": "12px", "line-height": "16px" }, // App/Caption};
const makeText = (content, styles = {}) => { const node = element("text", { "font-family": "Noto Sans", ...type.bodySmall, color: color.text.primary, "text-wrap": "nowrap", ...styles, }); node.appendChild(app.createTextNode(content)); return node;};
// The panels share the row. `min-width: 0px` lets a panel shrink below its// content's width, so wide content such as the card strip overflows inside the// panel's scrollers instead of widening the panel. The title bar names the// panel and the overflow value it shows.const panel = (title, meta) => { const node = element("flex", { "flex-direction": "column", "flex-basis": "0px", "flex-grow": "1", "min-width": "0px", "background-color": color.bg.surface, "border-style": "solid", "border-width": "1px", // stroke/thin "border-color": color.border.default, "border-radius": "8px", // radius/lg }); const bar = element("flex", { padding: "12px 16px", // space/3 space/4 gap: "12px", // space/3 "align-items": "center", "justify-content": "space-between", "border-style": "solid", "border-width": "0px 0px 1px 0px", // stroke/thin, bottom only "border-color": color.border.default, }); bar.appendChild(makeText(title, type.labelDefault)); bar.appendChild(makeText(meta, { ...type.caption, color: color.text.tertiary })); node.appendChild(bar); return node;};
// A strip under a hairline at the foot of a panel.const panelFooter = () => element("flex", { padding: "12px 16px", // space/3 space/4 gap: "8px", // space/2 "flex-direction": "column", "border-style": "solid", "border-width": "1px 0px 0px 0px", // stroke/thin, top only "border-color": color.border.default,});
const windowNode = element("window", { "background-color": color.bg.canvas,}, { title: "Burokku scrolling", width: "860", height: "620" });
const shell = element("flex", { width: "100%", height: "100%", padding: "24px", // space/6 gap: "16px", // space/4 "flex-direction": "column",});const header = element("flex", { gap: "4px", // space/1 "flex-direction": "column",});header.appendChild(makeText("Scrolling", type.h3));header.appendChild(makeText( "Wheel or drag a thumb. Click a scroller, then use the arrows, Page Up/Down, Space, Home, or End.", { color: color.text.secondary, "text-wrap": "wrap" },));shell.appendChild(header);
const panels = element("flex", { "flex-basis": "0px", "flex-grow": "1", gap: "16px", // space/4});
// A long list in an `overflow-y: auto` scroller. As a flex item with// non-visible overflow, it shrinks to the panel instead of growing to fit.const listPanel = panel("Message list", "overflow-y: auto");const list = element("div", { "flex-basis": "0px", "flex-grow": "1", "overflow-y": "auto", "background-color": color.bg.sunken,}, { "data-name": "message list" });// List rows stack edge to edge, divided by hairlines.const rows = [];for (let index = 1; index <= 60; index += 1) { const row = element("flex", { padding: "8px 16px", // space/2 space/4 "border-style": "solid", "border-width": "0px 0px 1px 0px", // stroke/thin, bottom only "border-color": color.border.subtle, }); row.appendChild(makeText(`Message #${index}`)); list.appendChild(row); rows.push(row);}const listStatus = makeText("scrollTop 0", { ...type.caption, color: color.text.secondary });const listFooter = panelFooter();listFooter.appendChild(listStatus);listPanel.appendChild(list);listPanel.appendChild(listFooter);
const showListPosition = () => { const end = list.scrollHeight - list.clientHeight; listStatus.textContent = `scrollTop ${Math.round(list.scrollTop)} of ${Math.round(end)}`;};// `scroll` fires once per change after wheel, thumb, keyboard, or script// scrolling. It does not bubble.list.addEventListener("scroll", showListPosition);
// A scroller inside a scroller. The wheel scrolls the innermost container// that can still move, then chains outward.const nestedPanel = panel("Nested scrollers", "overflow: auto inside overflow: auto");const outer = element("div", { "flex-basis": "0px", "flex-grow": "1", overflow: "auto", padding: "16px", // space/4 "background-color": color.bg.sunken,}, { "data-name": "outer scroller" });outer.appendChild(makeText( "This box scrolls vertically. The card strip below scrolls sideways.", { color: color.text.secondary, "text-wrap": "wrap" },));const strip = element("flex", { gap: "8px", // space/2 padding: "8px 0px", // space/2 "overflow-x": "auto",}, { "data-name": "card strip" });// Each card takes one status tone: a subtle fill, with its border and text// in the tone colour.const tones = [ [color.bg.accentSubtle, color.border.accent, color.text.accent], [color.bg.infoSubtle, color.border.info, color.text.info], [color.bg.successSubtle, color.border.success, color.text.success], [color.bg.warningSubtle, color.border.warning, color.text.warning], [color.bg.dangerSubtle, color.border.danger, color.text.danger], [color.bg.selected, color.border.strong, color.text.primary],];for (let index = 0; index < 12; index += 1) { const [fill, edge, label] = tones[index % tones.length]; const card = element("flex", { width: "110px", height: "80px", "flex-shrink": "0", padding: "8px", // space/2 "background-color": fill, "border-width": "1px", // stroke/thin "border-style": "solid", "border-color": edge, // Mixed radii: top-left and bottom-right 8px (radius/lg), the others 4px (radius/sm). "border-radius": "8px 4px", }); card.appendChild(makeText(`Card ${index + 1}`, { ...type.labelDefault, color: label })); strip.appendChild(card);}outer.appendChild(strip);for (let index = 1; index <= 6; index += 1) { const block = element("div", { height: "70px", padding: "8px", // space/2 margin: "8px", // space/2 "background-color": color.bg.surface, // An uneven border: a shu accent on the left side only. "border-width": "0px 0px 0px 2px", // stroke/thick, left only "border-style": "solid", "border-color": color.border.accent, // Only the right corners are rounded. "border-radius": "0px 6px 6px 0px", // radius/md }); block.appendChild(makeText(`Section ${index}`, { color: color.text.secondary })); outer.appendChild(block);}nestedPanel.appendChild(outer);
// `overflow: hidden` clips and shows no scrollbar. Only script scrolls it.const tickerFooter = panelFooter();tickerFooter.appendChild(makeText("Ticker — overflow: hidden, scrolled by a timer", { ...type.caption, color: color.text.tertiary,}));// A flex row sizes the text to its content, so the text's box overflows.// It is still a scroll container, which a click focuses, so it has a name// for the focus readout as the other scrollers do.const ticker = element("flex", { height: "28px", padding: "0px 8px", // space/2 overflow: "hidden", "align-items": "center", "background-color": color.bg.sunken, "border-radius": "4px", // radius/sm}, { "data-name": "ticker" });ticker.appendChild(makeText( "Burokku • overlay scrollbars take no layout space • scroll offsets live outside the UI tree, so scrolling only repaints • ", { color: color.text.secondary },));tickerFooter.appendChild(ticker);nestedPanel.appendChild(tickerFooter);setInterval(() => { const end = ticker.scrollWidth - ticker.clientWidth; ticker.scrollLeft = ticker.scrollLeft >= end ? 0 : ticker.scrollLeft + 1;}, 30);
panels.appendChild(listPanel);panels.appendChild(nestedPanel);
// A toolbar of focusable buttons: `tabindex="0"` puts them in Tab order. The// focus readout sits at the far end.const controls = element("flex", { gap: "8px", // space/2 "align-items": "center",});const actions = { Top: () => list.scrollTo({ top: 0 }), "Jump to #42": () => { for (const row of rows) row.style.removeProperty("background-color"); // Shu marks the selected row. rows[41].style.setProperty("background-color", color.bg.accentSubtle); rows[41].scrollIntoView({ block: "center" }); }, "Page down": () => list.scrollBy(0, list.clientHeight), Bottom: () => list.scrollTo(0, list.scrollHeight),};const buttons = {};for (const [label, action] of Object.entries(actions)) { // Secondary buttons. Burokku has no :hover or :focus styles, so pointer and // focus events swap the fill and border colour. The focus border keeps its // 1px width so the layout does not move. const button = element("flex", { height: "32px", padding: "0px 12px", // space/3 "align-items": "center", "background-color": color.bg.surface, "border-width": "1px", // stroke/thin "border-style": "solid", "border-color": color.border.strong, "border-radius": "6px", // radius/md }, { tabindex: "0", "data-name": `"${label}" button` }); button.appendChild(makeText(label, type.labelDefault)); button.addEventListener("click", action); button.addEventListener("keydown", event => { if (event.key === "Enter" || event.key === " ") { // Without this, Space would also scroll. event.preventDefault(); action(); } }); button.addEventListener("pointerenter", () => button.style.setProperty("background-color", color.bg.hover)); button.addEventListener("pointerleave", () => button.style.setProperty("background-color", color.bg.surface)); button.addEventListener("focus", () => button.style.setProperty("border-color", color.border.focus)); button.addEventListener("blur", () => button.style.setProperty("border-color", color.border.strong)); controls.appendChild(button); buttons[label] = button;}
const focusStatus = makeText("Focus: none — press Tab to reach the buttons", { ...type.caption, color: color.text.secondary,});// The readout grows from the left, so pin its text to the right edge.const focusSlot = element("flex", { "flex-grow": "1", "justify-content": "flex-end",});focusSlot.appendChild(focusStatus);controls.appendChild(focusSlot);// `focusin` and `focusout` bubble, so the window sees every focus change.windowNode.addEventListener("focusin", event => { focusStatus.textContent = `Focus: ${event.target.getAttribute("data-name")}`;});windowNode.addEventListener("focusout", () => { focusStatus.textContent = "Focus: none";});
shell.appendChild(controls);shell.appendChild(panels);windowNode.appendChild(shell);app.appendChild(windowNode);