code wiki / _hdl_build / nx_cms_pagebuilder.nx

nx_cms_pagebuilder.nx source

↩ module page · 43 lines · 1905 B

1// nx_cms_pagebuilder.nx -- CMS PAGE BUILDER (sovereign section/column grid layout). The Elementor/Divi 2// class, made Nishi-native: a page is sections of columns over a 12-unit grid, validated deterministically 3// (a row's columns must sum to the grid, each within bounds), with mobile-first RESPONSIVE stacking (below 4// the breakpoint every column goes full-width) and incremental column packing that cannot overflow a row. 5// Pure integer logic -- no Elementor license/bloat, no cloud, layout is reproducible from its data. The 6// grid + breakpoint are the data-driven seam (rule 11). license_tier: ORIGINAL 7import "nx_syscalls.nx" 8 9const NX_PB_GRID: i64 = 12 // columns per row (Bootstrap-style 12-grid) 10const NX_PB_BREAKPOINT_MD: i64 = 768 // px: below this, columns stack full-width (mobile-first) 11 12// is a row of n column widths valid? n>=1, each width in [1,GRID], and the widths sum to exactly GRID. 13func pb_row_valid(widths: *i64, n: i64) -> i64 { 14 if n < 1 { return 0 } 15 var sum: i64 = 0 16 var i: i64 = 0 17 while i < n { 18 let w: i64 = widths[i] 19 if w < 1 { return 0 } 20 if w > NX_PB_GRID { return 0 } 21 sum = sum + w 22 i = i + 1 23 } 24 if sum != NX_PB_GRID { return 0 } 25 return 1 26} 27 28// responsive width: below the MD breakpoint every column is full-grid (stacked); at/above it keeps its 29// declared desktop width. Mobile-first and deterministic. 30func pb_responsive_width(width: i64, viewport_px: i64) -> i64 { 31 if viewport_px < NX_PB_BREAKPOINT_MD { return NX_PB_GRID } 32 return width 33} 34 35// can a column of `add` units be packed into a row that already uses `used` units? add>=1 and no overflow. 36func pb_fits(used: i64, add: i64) -> i64 { 37 if add < 1 { return 0 } 38 if used + add > NX_PB_GRID { return 0 } 39 return 1 40} 41 42// grid units still free in a row 43func pb_remaining(used: i64) -> i64 { return NX_PB_GRID - used }