Raxol.UI.Components.Dashboard.GridContainer (Raxol v2.0.1)
View SourceCalculates layout bounds for widgets within a grid configuration. This module provides functions to determine the position and size of widgets based on a grid layout definition (columns, rows, gaps).
Summary
Functions
Calculates the absolute bounds for a widget within a grid layout.
Calculates the dimensions of a single cell in the grid.
Resolves the effective grid parameters (cols, rows) based on breakpoints defined in the grid configuration and the current parent width.
Functions
@spec calculate_widget_bounds(map(), any()) :: %{ x: integer(), y: integer(), width: integer(), height: integer() }
Calculates the absolute bounds for a widget within a grid layout.
Parameters:
widget_config: Map containing at leastgrid_spec: %{col: integer(), row: integer(), col_span: integer(), row_span: integer()}.grid_config: Map containingparent_bounds: %{x: integer(), y: integer(), width: integer(), height: integer()}, and optionallycols: integer(),rows: integer(),gap: integer().
Returns:
%{x: integer(), y: integer(), width: integer(), height: integer()}representing the absolute bounds.
@spec default_cols() :: integer()
@spec default_gap() :: integer()
@spec default_rows() :: integer()
Calculates the dimensions of a single cell in the grid.
Parameters:
grid_config: Map containing grid configuration including parent_bounds, cols, rows, and gap.
Returns:
{cell_width, cell_height}tuple with the dimensions of a single cell.
Resolves the effective grid parameters (cols, rows) based on breakpoints defined in the grid configuration and the current parent width.
Parameters:
grid_config: Map containingparent_bounds: %{width: _}andbreakpoints: %{...}.Breakpoints map should have keys like `:small`, `:medium`, `:large`, with values like `%{max_width: _, cols: _, rows: _}` or just `%{cols: _, rows: _}` for the largest/default breakpoint.
Returns:
%{cols: integer(), rows: integer()}