Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356const setStyles = (node, styles) => { for (const [property, value] of Object.entries(styles)) { node.style.setProperty(property, value); }};
// 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 accentSubtle: "#3d1408ff", // bg/accent-subtle infoSubtle: "#152640ff", // bg/info-subtle warningSubtle: "#362808ff", // bg/warning-subtle }, text: { primary: "#f6f6f7ff", // text/primary secondary: "#929295ff", // text/secondary tertiary: "#67676cff", // text/tertiary accent: "#ff6a45ff", // text/accent info: "#8fb0e8ff", // text/info warning: "#f2c25bff", // text/warning }, border: { subtle: "#222329ff", // border/subtle default: "#2e2f36ff", // border/default strong: "#4b4b52ff", // border/strong accent: "#ff6a45ff", // border/accent info: "#8fb0e8ff", // border/info warning: "#f2c25bff", // border/warning },};
// 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 h4: { "font-size": "18px", "line-height": "26px", "font-weight": "bold" }, // App/Heading/H4 bodySmall: { "font-size": "14px", "line-height": "20px" }, // App/Body/Small labelDefault: { "font-size": "14px", "line-height": "20px", "font-weight": "bold" }, // App/Label/Default labelSmall: { "font-size": "12px", "line-height": "16px", "font-weight": "bold" }, // App/Label/Small caption: { "font-size": "12px", "line-height": "16px" }, // App/Caption};
const makeText = (content, styles = {}) => { const text = app.createElement("text"); setStyles(text, { "font-family": "Noto Sans", ...type.bodySmall, color: color.text.primary, "text-wrap": "wrap", ...styles, }); text.appendChild(app.createTextNode(content)); return text;};
// A block: a fill, a 1px border and 8px corners.const blockStyles = (fill, edge) => ({ "background-color": fill, "border-style": "solid", "border-width": "1px", // stroke/thin "border-color": edge, "border-radius": "8px", // radius/lg});
// Three 260px columns and two 16px gaps fill the stage's 812px content box.const CARD_WIDTH = "260px";const CARD_HEIGHT = "298px";
// A key/value row under a hairline, pinned to the bottom of a card.const makeSpec = (label, value) => { const row = app.createElement("flex"); setStyles(row, { padding: "8px 0px", // space/2 "justify-content": "space-between", "align-items": "center", "border-style": "solid", "border-width": "1px 0px 0px 0px", // stroke/thin, top only "border-color": color.border.subtle, }); row.appendChild(makeText(label, { ...type.caption, color: color.text.tertiary, "text-wrap": "nowrap", })); row.appendChild(makeText(value, { ...type.labelSmall, "text-wrap": "nowrap" })); return row;};
// The card content: a heading, copy that takes the free height, then specs.const fillCard = (card, heading, body, specs) => { card.appendChild(makeText(heading, { ...type.h4, "text-wrap": "nowrap" })); card.appendChild(makeText(body, { color: color.text.secondary, "flex-grow": "1", })); for (const [label, value] of specs) { card.appendChild(makeSpec(label, value)); }};
const makeCard = (heading, body, specs) => { const card = app.createElement("flex"); setStyles(card, { width: CARD_WIDTH, height: CARD_HEIGHT, padding: "16px", // space/4 gap: "8px", // space/2 "flex-direction": "column", ...blockStyles(color.bg.canvas, color.border.default), }); fillCard(card, heading, body, specs); return card;};
// A positioned box in one status tone: subtle fill, tone border and text.const makeTag = (label, detail, height, fill, edge, textColor) => { const tag = app.createElement("flex"); setStyles(tag, { width: "176px", height, padding: "12px", // space/3 gap: "4px", // space/1 "flex-direction": "column", ...blockStyles(fill, edge), "border-radius": "6px", // radius/md }); tag.appendChild(makeText(label, { ...type.labelSmall, color: textColor, "text-wrap": "nowrap", })); tag.appendChild(makeText(detail, { ...type.caption, color: textColor, "text-wrap": "nowrap", })); return tag;};
/*<window title="Burokku mixed positioned layout"> <flex id="shell"> <flex id="header"> <text id="title">Position × mixed layout</text> <text id="subtitle"> Blue is later in the UI tree, but z-index 5 keeps it behind shu at z-index 10. </text> </flex> <grid id="stage" position="relative"> <flex id="stage-header" grid-column="1 / 4"> <text>Relative grid</text> <text>The containing block for both absolute boxes.</text> </flex> <flex id="flow-card" position="static"> <text>Static flex item</text> <text>This card participates normally in the grid.</text> </flex> <div id="static-wrapper" position="static"> <flex id="overlay-host" position="static"> <text>Static block wrapper</text> <text>Both positioned boxes remain nested here in the UI tree.</text> <flex id="absolute-overlay" position="absolute" z-index="10" top="20px" right="20px"> <text>Absolute · z-index 10</text> </flex> <flex id="absolute-underlay" position="absolute" z-index="5" top="50px" right="50px"> <text>Absolute · z-index 5</text> </flex> <flex id="fixed-footer" position="fixed" z-index="20" bottom="0px" left="0px"> <text>Fixed · z-index 20</text> </flex> </flex> </div> <flex id="grid-sibling" position="static"> <text>Normal grid sibling</text> <text>The absolute overlay consumes no grid track.</text> </flex> </grid> </flex></window>*/const windowNode = app.createElement("window");windowNode.setAttribute("title", "Burokku mixed positioned layout");windowNode.setAttribute("width", "900");windowNode.setAttribute("height", "640");setStyles(windowNode, { "background-color": color.bg.canvas,});
// The bottom padding keeps the stage clear of the 40px fixed footer.const shell = app.createElement("flex");setStyles(shell, { width: "100%", height: "100%", padding: "24px 24px 64px 24px", // space/6, plus the footer height gap: "16px", // space/4 "flex-direction": "column",});
const header = app.createElement("flex");setStyles(header, { gap: "4px", // space/1 "flex-direction": "column",});header.appendChild(makeText("Position × mixed layout", { ...type.h3, "text-wrap": "nowrap",}));header.appendChild(makeText( "Blue is later in the UI tree, but z-index 5 keeps it behind shu at z-index 10.", { color: color.text.secondary, "text-wrap": "nowrap" },));shell.appendChild(header);
const stage = app.createElement("grid");setStyles(stage, { position: "relative", width: "100%", padding: "20px", // space/5 "row-gap": "20px", // space/5 "column-gap": "16px", // space/4 // No border: the overlay's top/right offsets are measured from this edge. "background-color": color.bg.surface, "border-radius": "8px", // radius/lg});
// The header spans all three columns. Its fixed height keeps the cards below// the absolute boxes, which sit in the top-right corner of the stage.const stageHeader = app.createElement("flex");setStyles(stageHeader, { "grid-column": "1 / 4", "justify-self": "start", width: "400px", height: "124px", gap: "4px", // space/1 "flex-direction": "column",});stageHeader.appendChild(makeText("Relative grid", { ...type.labelDefault, "text-wrap": "nowrap",}));stageHeader.appendChild(makeText( "The containing block for both absolute boxes: their top and right offsets are measured from this stage's edge.", { color: color.text.secondary },));stage.appendChild(stageHeader);
const flowCard = makeCard( "Static flex item", "This card participates normally in the relative grid's flow.", [["position", "static"], ["grid column", "1"]],);
const staticWrapper = app.createElement("div");setStyles(staticWrapper, { width: CARD_WIDTH, height: CARD_HEIGHT, ...blockStyles(color.bg.sunken, color.border.strong),});
const overlayHost = app.createElement("flex");setStyles(overlayHost, { width: "100%", height: "100%", padding: "16px", // space/4 gap: "8px", // space/2 "flex-direction": "column",});fillCard( overlayHost, "Static block wrapper", "The shu, blue, and gold boxes are nested here in the UI tree, but use different layout parents.", [["position", "static"], ["positioned children", "3"]],);staticWrapper.appendChild(overlayHost);
const gridSibling = makeCard( "Normal grid sibling", "The absolute boxes consume no grid track, so this remains the third in-flow column.", [["position", "static"], ["grid column", "3"]],);
const absoluteOverlay = makeTag( "Absolute · z-index 10", "top: 20px; right: 20px", "72px", color.bg.accentSubtle, color.border.accent, color.text.accent,);setStyles(absoluteOverlay, { position: "absolute", "z-index": "10", top: "20px", right: "20px",});
const absoluteUnderlay = makeTag( "Absolute · z-index 5", "later in the UI tree", "96px", color.bg.infoSubtle, color.border.info, color.text.info,);// The overlay covers the underlay's top; its label sits on the visible bottom.setStyles(absoluteUnderlay, { "justify-content": "flex-end", position: "absolute", "z-index": "5", top: "50px", right: "50px",});
// A status bar pinned to the window, whatever its parent in the UI tree.const fixedFooter = app.createElement("flex");setStyles(fixedFooter, { position: "fixed", "z-index": "20", bottom: "0px", left: "0px", width: "100%", height: "40px", padding: "0px 24px", // space/6 gap: "12px", // space/3 "align-items": "center", "background-color": color.bg.warningSubtle, "border-style": "solid", "border-width": "1px 0px 0px 0px", // stroke/thin, top only "border-color": color.border.warning,});const footerLabel = makeText("Fixed · z-index 20", { ...type.labelSmall, color: color.text.warning, "text-wrap": "nowrap", "flex-grow": "1",});fixedFooter.appendChild(footerLabel);fixedFooter.appendChild(makeText("bottom: 0; left: 0; containing block: window", { ...type.caption, color: color.text.warning, "text-wrap": "nowrap",}));
overlayHost.appendChild(absoluteOverlay);overlayHost.appendChild(absoluteUnderlay);overlayHost.appendChild(fixedFooter);stage.appendChild(flowCard);stage.appendChild(staticWrapper);stage.appendChild(gridSibling);shell.appendChild(stage);windowNode.appendChild(shell);app.appendChild(windowNode);