Allocated layout box
Read the current canvas allocation and draw an inset panel.
APIs demonstrated
Section titled “APIs demonstrated”- useLayoutBox from
@pibbl/core - LayoutItemStyle from
@pibbl/core
Complete example
Section titled “Complete example”Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".
import { Rectangle, Text, pibbl, useLayoutBox, type LayoutItemStyle,} from "@pibbl/core";
function Scene() { const box = useLayoutBox(); const item: LayoutItemStyle = { left: 16, top: 16 }; return ( <> <Rectangle style={{ ...item, width: box.width - 32, height: box.height - 32, fill: "#0f766e", }} /> <Text style={{ left: 28, top: 48, font: "16px sans-serif", fill: "#fff" }} > {`${box.width} x ${box.height}`} </Text> </> );}const canvas = document.createElement("canvas");canvas.width = 320;canvas.height = 220;document.body.append(canvas);const app = pibbl(canvas, <Scene />);window.addEventListener("pagehide", () => app.dispose(), { once: true });Usage notes
Section titled “Usage notes”- Creates its own canvas and disposes the Pibbl mount on pagehide.
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.