package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.style/Style/Grid_placement/index.html
Module Style.Grid_placementSource
CSS Grid item placement specification.
This module defines how grid items are positioned within a CSS Grid container using line-based placement. It supports CSS grid line coordinates, named grid lines, and span-based placement.
Grid lines use CSS coordinates where positive indices start from 1 at the grid's start edge and negative indices start from -1 at the grid's end edge. Line index 0 is invalid and treated as Auto.
Grid line coordinate in CSS Grid coordinates.
Positive values start from 1 at the grid's start edge. Negative values start from -1 at the grid's end edge. The value 0 is invalid and treated as Auto.
type t = | Auto(*Place item according to auto-placement algorithm.
*)| Line of grid_line(*Place item at specified line index.
*)| Named_line of string * int(*Place item at specified named line. The string is the line name and the int is the occurrence count (e.g., the 2nd line named "header").
*)| Span of int(*Item spans specified number of tracks.
*)| Named_span of string * int(*Item spans until the nth line named with the given string.
*)
Grid placement specification for a single axis.
Defaults to Auto.
Construction
line index creates a line-based placement at index.
Line 0 is invalid and will be treated as Auto during layout.
named_line name index creates a placement at the indexth occurrence of the named line name.
named_span name count creates a span until the countth occurrence of the named line name.
Predicates
is_definite placement returns true if the placement is definite.
A placement is definite if it specifies a non-zero line index or a named line. Auto and Span values are indefinite. Line 0 is invalid and treated as Auto, thus indefinite.
Conversion
into_origin_zero_placement_ignoring_named placement explicit_track_count converts placement to origin-zero coordinates, ignoring named lines.
Named lines and named spans are converted to Auto. Line 0 is converted to Auto. Other line placements are converted using explicit_track_count to translate CSS grid coordinates (1-indexed, negatives from end) to origin-zero coordinates (0-indexed from start).
into_origin_zero_placement placement explicit_track_count converts placement to origin-zero coordinates.
Line 0 is converted to Auto. Other line placements are converted using explicit_track_count to translate CSS grid coordinates to origin-zero coordinates.
Raises Failure if placement is Named_line or Named_span. Named lines must be resolved before calling this function.
Comparison and display
compare a b provides a total ordering on placements.
Ordering: Auto < Line < Named_line < Span < Named_span. Within each variant, values are compared structurally.
pp fmt placement pretty-prints placement to fmt.
Line operations
Operations on Geometry.Line.t containing grid placements. These work on pairs of start and end placements along a single axis.