Loading...
Loading...
Grid and alignment rules for a macOS SwiftUI app, with three checks that catch misalignment (a lint for off-grid numbers, a layout probe that measures real frames in snapshot mode, and a grid overlay). Use when building or reviewing a custom page, card, row, form, or sheet, after every build that touched layout, or when the user says something looks misaligned, crooked, cramped, or unevenly spaced.
npx skill4agent add daveebbelaar/bama layout-grid.padding(13)Sources/<App>/UI/Grid.swifttools/UI/Grid.swifttools/grid-lint.shtools/check-layout.swiftnew-mac-appSnapshot.swiftSpacexs 4sm 8md 12lg 16xl 20xxl 24section 32Space.marginSpace.lgForm.formStyle(.grouped).columnsGridGridRowLabeledContentHStack(alignment: .firstTextBaseline).monospacedDigit()Label.controlSize.offset.position// grid: ok <why>tools/grid-lint.sh
# Sources/Tasks/TaskRow.swift:14: off grid (10): .padding(.horizontal, 10)
# FAIL grid-lint: 1 lines off the gridSpaceVStack(alignment: .leading, spacing: Space.xxl) {
Text("Today").gridProbe("title", area: "page")
StatsRow().gridProbe("stats", area: "page")
TaskCard()
.gridArea("card", inset: Space.lg)
.gridProbe("card", area: "page")
}
.padding(Space.margin)
.gridArea("page").gridArea.gridProbeedge"lead"edge: nil<page>-<mode>-layout.jsonswift tools/check-layout.swift /tmp/<App>-shots/*-layout.json
# PASS today-light-layout.json: 12 probes in 2 areas
# FAIL inbox-light-layout.json
# - edge page/lead has 2 leading edges: title 320, list 324APP_GRID=1 APP_STORE=/tmp/<App>-test.store APP_SNAPSHOT=/tmp/<App>-grid \
~/Applications/<App>.app/Contents/MacOS/<App>| Message | Usual cause | Fix |
|---|---|---|
| starts 23 pt into page | a raw padding on one child | remove it, use the stack's |
| 2 leading edges | a centered stack, or one child with extra padding | |
| gap 10 pt | | a |
| inside its 20 pt inset | a missing margin, or a fixed width wider than the parent | |
| overlap | | remove it, let the stack size the view |
| x between pixels | a fractional number | a whole number from |
tools/grid-lint.shtools/check-layout.swift.gridArea