Visualize.Chart.Builder.Masks (Visualize v0.2.35)

Copy Markdown View Source

The context panel over a layer — its key and its free variables (spec/14 §19.5, §19.10) — and the rows of its mask, which the layer's row lists (§18.8, #316).

A site's mask is the keys removed at that site, so a lower layer shows through (§19.5). rows/2 lists the paths the site's contribution carries — its top-level keys, and the keys of each node under them — one checkbox per path under the layer's › Mask item, checked where the mask holds it. A site masked as a whole is disabled (§19.3) and is said so rather than drawn as every box checked.

This module compiles only when Phoenix.Component is loaded (spec/10 §1.1, D-45, D-85).

Summary

Functions

Whether a contribution is of a kind the document keys by name — style, scale, source, var — so the site needs a key to be declared under (spec/14 §19.3).

Renders the layer's context: its declared as key control, its lock actions, the save as form of an inline group (§18.8, #382), its not-placed fault, and the free variables the site carries. Its mask is the layer row's (§18.8).

The paths a site's contribution can mask: every top-level key, and the keys of each node under one, as Visualize.Chart.Use.mask/2 takes them (spec/14 §19.5).

Whether a contribution is a source, whose key is chosen from the host's pool rather than typed (spec/14 §19.10).

One row per maskable path of a contribution, for the layer row's › Mask item (spec/14 §18.8, #316): its name (the keys joined by ., which is the checkbox's name), whether use masks it, and the class and title that say so.

A mask with a path added or removed, as a checkbox says: checked masks it, unchecked does not. A path is spelt as its keys joined by ., which is the checkbox's name.

Functions

keyed?(fragment)

@spec keyed?(map()) :: boolean()

Whether a contribution is of a kind the document keys by name — style, scale, source, var — so the site needs a key to be declared under (spec/14 §19.3).

iex> Visualize.Chart.Builder.Masks.keyed?(%{style: %{stroke: "#111"}})
true

iex> Visualize.Chart.Builder.Masks.keyed?(%{frames: %{main: %{}}})
false

panel(assigns)

Renders the layer's context: its declared as key control, its lock actions, the save as form of an inline group (§18.8, #382), its not-placed fault, and the free variables the site carries. Its mask is the layer row's (§18.8).

Attributes

  • id (:string) (required) - the panel's id.
  • use (:any) (required) - the selected site, a Visualize.Chart.Use.
  • label (:string) (required) - the site's name.
  • fragment (:map) (required) - what the site contributes before its mask: the referenced body under its local.
  • free (:list) - the site's free variables, as free_vars/1 gives them. Defaults to [].
  • keyless (:boolean) - whether the site was left out for want of a key. Defaults to false.
  • pool (:list) - the names of the host's sample sources, sorted (§19.10). Defaults to [].
  • index (:any) - the site's row, which the lock actions take (§18.8, #381). Defaults to nil.
  • reverting (:boolean) - whether a revert of this site is armed and the next click does it. Defaults to false.
  • store? (:boolean) - whether a store is configured, for save as. Defaults to false.
  • target (:any) - the phx-target of the panel's events. Defaults to nil.

paths(fragment)

@spec paths(map()) :: [[atom()]]

The paths a site's contribution can mask: every top-level key, and the keys of each node under one, as Visualize.Chart.Use.mask/2 takes them (spec/14 §19.5).

iex> Visualize.Chart.Builder.Masks.paths(%{theme: :dark, frames: %{main: %{legend: %{}, margin: %{}}}})
[[:frames], [:frames, :main], [:frames, :main, :legend], [:frames, :main, :margin], [:theme]]

pooled?(fragment)

@spec pooled?(map()) :: boolean()

Whether a contribution is a source, whose key is chosen from the host's pool rather than typed (spec/14 §19.10).

iex> Visualize.Chart.Builder.Masks.pooled?(%{source: %{fields: [:t]}})
true

iex> Visualize.Chart.Builder.Masks.pooled?(%{style: %{}})
false

rows(fragment, use)

@spec rows(map(), Visualize.Chart.Use.t()) :: [map()]

One row per maskable path of a contribution, for the layer row's › Mask item (spec/14 §18.8, #316): its name (the keys joined by ., which is the checkbox's name), whether use masks it, and the class and title that say so.

iex> use = %Visualize.Chart.Use{id: 1, ref: nil, mask: [[:frames, :main, :margin]]}
iex> rows = Visualize.Chart.Builder.Masks.rows(%{frames: %{main: %{margin: %{top: 1}}}}, use)
iex> Enum.map(rows, &{&1.name, &1.masked})
[{"frames", false}, {"frames.main", false}, {"frames.main.margin", true}]

toggle(use, name, checked)

A mask with a path added or removed, as a checkbox says: checked masks it, unchecked does not. A path is spelt as its keys joined by ., which is the checkbox's name.