# `Macaw.Grid`
[🔗](https://github.com/dcoai/macaw/blob/v0.6.0/lib/macaw/grid.ex#L1)

The grid a surface places its cells on (spec/06 §3.3), the built-in layout `:grid`
(`Macaw.Layout`): 12 columns, or 6 or 24 by `{:grid, columns: n}`.

Places are `%{x, y, w, h}` in integer units: `x` from 0 to one less than the columns,
`w` from 1 with `x + w` at most the columns, `y` from 0, `h` from 1, and `y + h` at most
`rows/0`. Reading order is by `y`, then `x`, then name, and is the DOM order. Placement
is by classes from one static stylesheet, never inline style:

    iex> Macaw.Grid.classes(%{x: 0, y: 2, w: 6, h: 3})
    "mw-cell mw-col-1 mw-span-6 mw-row-3 mw-rows-3"

# `place`

```elixir
@type place() :: %{
  x: non_neg_integer(),
  y: non_neg_integer(),
  w: pos_integer(),
  h: pos_integer()
}
```

# `classes`

```elixir
@spec classes(place()) :: String.t()
```

A place's classes: the cell, its column and span, its row and rows, the same on every
width; the container's class sets the width (`container/1`).

# `columns`

```elixir
@spec columns() :: pos_integer()
```

The grid's columns when a surface chooses none, 12.

# `faults`

```elixir
@spec faults(%{required(String.t()) =&gt; %{place: place()}}) :: [Macaw.Base.Fault.t()]
```

The faults of the cells' places on 12 columns, each at `[:cells, name, :place]`: a bound
broken is `{:out_of_bounds, what, value}` (`what` one of `:x`, `:w`, `:x_plus_w`, `:y`,
`:h`, `:y_plus_h`); two cells overlapping is `{:overlap, other}` at the later one in
reading order. `cells` maps names to anything with a `place`. `faults/2` takes the
grid's options, its columns among them.

# `faults`

```elixir
@spec faults(%{required(String.t()) =&gt; %{place: place()}}, map()) :: [
  Macaw.Base.Fault.t()
]
```

`faults/1` on the options' columns.

# `order`

```elixir
@spec order(%{required(String.t()) =&gt; %{place: place()}}) :: [String.t()]
```

The cells' names in reading order: by `y`, then `x`, then name.

# `rows`

```elixir
@spec rows() :: pos_integer()
```

The most rows a grid places a cell in, 64, so every placement has a class.

# `size`

```elixir
@spec size(place(), number(), number()) :: {number(), number()}
```

A place's declared size in CSS pixels on 12 columns: its share of the surface's width
and its rows' height, `{w * width / 12, h * row_height}`. `size/4` takes the grid's
options, its columns among them.

# `size`

```elixir
@spec size(place(), map(), number(), number()) :: {number(), number()}
```

A place's declared size on the options' columns: `{w * width / columns, h * row_height}`.

# `stylesheet`

```elixir
@spec stylesheet() :: String.t()
```

The grid's one static stylesheet, for every width: the grid (12 columns, and `.mw-grid-6`
and `.mw-grid-24` for the others), a rule per column start and column span up to the
widest, per row start and row span, and the container query that stacks every cell into
reading order when the surface is narrower than 40rem.

# `stylesheet_path`

```elixir
@spec stylesheet_path() :: String.t()
```

The stylesheet's path, its content address (`Macaw.Component.Stylesheet.path/1`).

# `widths`

```elixir
@spec widths() :: [pos_integer(), ...]
```

The widths a grid may have, in columns: 6, 12 and 24, so its stylesheet is static.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
