Macaw.Frame.Style.Defaults (macaw_frame v0.1.0)

Copy Markdown View Source

Defaults inherited by container and layer kind (spec/02 §3.8): what a style does not say comes from the containers the element sits in.

An element's defaults are its containers' in order, farthest first (the theme's root, the design, the frame, the element's own defaults); for each, its part defaults, then its entry for the element's layer kind; the site's stack is laid over the result. A label, an axis and a legend take the part defaults alone. The base is never written onto an element (base/0): it is what the backends already draw when a key is absent.

iex> design = %{"line" => %{stroke: %{cap: :round}}, stroke: %{width: 2}}
iex> frame = %{stroke: %{width: 3}}
iex> Macaw.Frame.Style.Defaults.layer([design, frame], "line")
%{stroke: %{width: 3, cap: :round}}
iex> Macaw.Frame.Style.Defaults.layer([design, frame], "area")
%{stroke: %{width: 3}}

Summary

Functions

The theme's root defaults: every part, defined (§3.8).

A container's entry for a layer kind, %{} when it has none.

The defaults an element of layer kind kind inherits from containers, farthest first: each container's parts, then its entry for the kind; with kind nil (a label, an axis, a legend) the parts alone. A container that is no map gives nothing.

A container's part defaults: its node without its kind entries.

Functions

base()

@spec base() :: map()

The theme's root defaults: every part, defined (§3.8).

entry(container, kind)

@spec entry(term(), term()) :: map()

A container's entry for a layer kind, %{} when it has none.

layer(containers, kind)

@spec layer(term(), term()) :: map()

The defaults an element of layer kind kind inherits from containers, farthest first: each container's parts, then its entry for the kind; with kind nil (a label, an axis, a legend) the parts alone. A container that is no map gives nothing.

parts(container)

@spec parts(term()) :: map()

A container's part defaults: its node without its kind entries.