Skip to content
docsv0.1.0

MilpaDesign

Locates the `@milpa/design` package on disk and resolves paths within it. Consuming applications install `@milpa/design` via npm at the project root (`node_modules/@milpa/design`); a lab/test checkout without an npm install can instead point `MILPA_DESIGN_PATH` at a local `milpa-design` checkout — every method here checks the env override first and falls back to the npm layout.

MilpaDesign::cssFiles()

public static function cssFiles(): array

The design system's stylesheet files this package's templates expect, keyed by their path relative to the design package root and resolved to absolute filesystem paths under {@see path()}.

MilpaDesign::path()

public static function path(): string

Resolves the `@milpa/design` package root: `MILPA_DESIGN_PATH` when set, otherwise `node_modules/@milpa/design` under the project root. Throws `RuntimeException` if the resolved directory does not exist.

MilpaDesign::source()

public static function source(): string

A human-readable label for where {@see path()} resolved its answer from — `"env:MILPA_DESIGN_PATH"` or `"npm:@milpa/design"` — useful in diagnostics and error messages.

MilpaDesign::contract()

public static function contract(string $relativePath): string

A stable identifier for a path within the design package, e.g. `"@milpa/design:dist/milpa-tokens.css"`, for use in contract/error references that name a design-system asset without hardcoding a filesystem path.

Parameters

Parameters of contract()
NameTypeDescription
$relativePathstring