resolveLength
import { resolveLength } from "@pibbl/core";resolveLength(value, reference, property, context?) resolves a public Length and returns a finite logical
number or undefined for "auto". Numeric values must be finite; percentages
need a definite nonnegative reference. Invalid input produces a contextual
LayoutDiagnostic.
const width = resolveLength("50%", 320, "width"); // 160See Style and draw for local style usage.
API details from source
Section titled “API details from source”
Resolves a numeric or percentage length; automatic sizing returns undefined.
resolveLength: (value: Length, reference: number | undefined, property: string, context?: Readonly<LayoutDiagnosticContext>) => number | undefinedRelated API: resolveLength, Length, LayoutDiagnosticContext.
Parameters
Section titled “Parameters”-
value— Logical length or percentage to resolve. See Length. -
reference— Reference length for percentages, or undefined if unavailable. -
property— Property name used in diagnostics. -
context— Component and property context for diagnostic messages. See LayoutDiagnosticContext .
Returns
Section titled “Returns”The resolved logical length, or undefined for an unresolved automatic length.
See also
Section titled “See also”View source — packages/core/src/lib/style/resolve-length.ts:22
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Box resolution: Resolve padding, percentages, and a constrained box with typed diagnostics. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.