Raxol.UI.Components.Dashboard.GridContainer (Raxol v0.4.0)

View Source

Calculates 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

calculate_widget_bounds(widget_config, invalid_grid_config)

@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 least grid_spec: %{col: integer(), row: integer(), col_span: integer(), row_span: integer()}.
  • grid_config: Map containing parent_bounds: %{x: integer(), y: integer(), width: integer(), height: integer()}, and optionally cols: integer(), rows: integer(), gap: integer().

Returns:

  • %{x: integer(), y: integer(), width: integer(), height: integer()} representing the absolute bounds.

default_cols()

@spec default_cols() :: integer()

default_gap()

@spec default_gap() :: integer()

default_rows()

@spec default_rows() :: integer()

get_cell_dimensions(invalid_input)

@spec get_cell_dimensions(any()) :: {integer(), 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.

resolve_grid_params(invalid_input)

Resolves the effective grid parameters (cols, rows) based on breakpoints defined in the grid configuration and the current parent width.

Parameters:

  • grid_config: Map containing parent_bounds: %{width: _} and breakpoints: %{...}.
             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()}