Flow and flex layout
Stack a banner with a flexible row of marks.
APIs demonstrated
Section titled “APIs demonstrated”- Flow from
@pibbl/core - FlowProps from
@pibbl/core - FlowStyle from
@pibbl/core - Flex from
@pibbl/core - FlexProps from
@pibbl/core - FlexStyle from
@pibbl/core - FlexItemStyle 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 { Flex, Flow, Rectangle, pibbl, type FlexItemStyle, type FlexProps, type FlexStyle, type FlowProps, type FlowStyle,} from "@pibbl/core";
const flexItem: FlexItemStyle = { flexGrow: 1, flexBasis: 60 };const flexStyle: FlexStyle = { width: 300, height: 90, flexDirection: "row", justifyContent: "space-between", gap: 8,};const flexProps: FlexProps = { children: ( <> <Rectangle style={{ ...flexItem, width: 60, minWidth: 0, height: 70, fill: "#0f766e", }} /> <Rectangle style={{ ...flexItem, width: 60, minWidth: 0, height: 70, fill: "#f97316", }} /> <Rectangle style={{ ...flexItem, width: 60, minWidth: 0, height: 70, fill: "#7c3aed", }} /> </> ),};const flowStyle: FlowStyle = { width: 320, height: 220, direction: "vertical", gap: 12, padding: 10,};const flowProps: FlowProps = { children: ( <> <Rectangle style={{ width: 300, height: 50, fill: "#e11d48" }} /> <Flex {...flexProps} style={flexStyle} /> </> ),};const canvas = document.createElement("canvas");canvas.width = 320;canvas.height = 220;document.body.append(canvas);const app = pibbl(canvas, <Flow {...flowProps} style={flowStyle} />);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.