package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.style/Style/Grid/index.html
Module Style.GridSource
Grid coordinate systems and track utilities with submodules.
include module type of Grid
Coordinate Systems
Two coordinate systems reference grid lines (gaps between rows/columns):
- CSS Grid Line coordinates: Used in
grid-row/grid-columnCSS properties. Line 1 is at the left/top edge of the explicit grid. Line -1 is at the right/bottom edge. Line 0 is invalid and treated asAuto.
- Origin-zero coordinates: Normalized internal form where line 0 is at the left/top edge of the explicit grid. Lines increment rightward/downward (1, 2, 3, ...) and decrement leftward/upward (-1, -2, -3, ...).
All functions in this module operate on these coordinate systems to support grid placement and track resolution.
origin_zero_line is a 0-indexed grid line coordinate used internally during grid layout computation.
Origin-zero coordinates normalize CSS grid lines: line 0 is at the left/top edge of the explicit grid, positive values extend right/down, and negative values extend left/up.
Grid placement specification in origin-zero coordinates.
type track_counts = {negative_implicit : int;(*Number of implicit tracks before the explicit grid.
*)explicit : int;(*Number of explicit tracks.
*)positive_implicit : int;(*Number of implicit tracks after the explicit grid.
*)
}track_counts represents the distribution of tracks across the implicit and explicit grids in a single axis.
The implicit grid extends the explicit grid to accommodate items placed outside it. Tracks are divided into three regions: negative implicit tracks (before the explicit grid), explicit tracks (defined by grid-template-rows/grid-template-columns), and positive implicit tracks (after the explicit grid).
grid_line is a CSS grid line coordinate (1-indexed, negative allowed).
Positive values count from the start of the explicit grid (1, 2, 3, ...). Negative values count from the end (-1, -2, -3, ...). Line 0 is invalid per the CSS Grid specification and is treated as Auto.
Coordinate Conversion
grid_line_to_origin_zero_line line explicit_track_count converts a CSS grid line to an origin-zero line coordinate.
Positive lines are adjusted by subtracting 1 to convert from 1-indexed to 0-indexed. Negative lines count backward from the end of the explicit grid. Line 0 is invalid and converted to 0.
Track Count Operations
val make_track_counts :
negative_implicit:int ->
explicit:int ->
positive_implicit:int ->
track_countsmake_track_counts ~negative_implicit ~explicit ~positive_implicit creates a track count record.
total_track_count counts returns the total number of tracks across implicit and explicit grids.
oz_line_to_track line counts converts an origin-zero line to a track index for the track immediately following the line.
Returns None if line lies outside the implicit grid bounds or refers to the final grid line. Track indices are 0-based relative to the start of the implicit grid and include negative implicit tracks.
oz_line_to_next_track line returns the index of the track immediately following the given origin-zero line.
Negative lines are clamped to 0. This function is used when resolving grid item placement.
oz_line_range_to_track_range start_line end_line converts an origin-zero line range to a track range (inclusive start, exclusive end).
The returned pair represents start_track, end_track indices suitable for iterating over tracks in the range.