package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/compute_grid/Compute_grid/Explicit_grid/index.html
Module Compute_grid.Explicit_gridSource
Explicit grid track initialization from CSS styles.
Implements CSS Grid auto-repeat evaluation and track instantiation. Explicit tracks are those defined in grid-template-rows/columns, including auto-fit and auto-fill repetitions. This module resolves repetition counts and builds the track list with gutters.
Auto-repeat fit strategy for computing repetition counts.
Determines whether to maximize fit without overflow (for definite/max sizes) or minimize fit with overflow (for min sizes).
val compute_explicit_grid_size_in_axis :
style:Style.t ->
auto_fit_container_size:float option ->
auto_fit_strategy:auto_repeat_strategy ->
resolve_calc_value:Style.calc_resolver ->
axis:Geometry.absolute_axis ->
int * intcompute_explicit_grid_size_in_axis style auto_fit_container_size auto_fit_strategy resolve_calc_value axis computes explicit grid track counts.
Returns (num_auto_repetitions, total_explicit_track_count) where the first element is the number of auto-fit/auto-fill repetitions resolved (0 if none) and the second is the total number of explicit tracks.
Algorithm validates the template, then:
- If no auto-repeat: count tracks from single definitions and fixed-count repetitions.
- If auto-repeat present: compute repetitions based on container size, gap, and non-repeating track space.
- Return (0, 0) if template is invalid (multiple auto-repeats, empty repetitions, or auto-repeat with non-fixed-size tracks).
The repetition count is clamped to at least 1 if the first repetition overflows.
Invariant: At most one auto-repeat definition per axis is valid.
val initialize_grid_tracks :
tracks:Compute_grid__.Grid_track.t list Stdlib.ref ->
counts:Grid_track_counts.t ->
style:Style.t ->
axis:Geometry.absolute_axis ->
track_has_items:(int -> bool) ->
unitinitialize_grid_tracks tracks counts style axis track_has_items populates tracks with grid tracks and gutters.
Clears tracks and rebuilds it with:
- Initial gutter (collapsed).
- Negative implicit tracks (from grid-auto-rows/columns, cycling if needed).
- Explicit tracks (from grid-template-rows/columns, expanding repetitions).
- Positive implicit tracks.
- Final gutter (collapsed).
Auto-fit tracks without items are collapsed. Gutters are sized per gap style. All tracks alternate with gutters in the output list.
Precondition: counts must match the actual track counts computed for the grid.