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

Copy Markdown View Source

A root tab as one page of sections (spec/14 §18.15, #249).

A node's keys are grouped by facet into collapsible sections; a key that holds a node — one, a map of them or a list — is not a textarea in its facet's section but a sub-section inside it, titled by the node's label, itself a page, so the whole subtree under a root reads as one page and nothing is listed twice. The frame's page reads as a frame: kind, then the design's name and description (the meta node), then size — the size and margin nodes together — then binding, then its parts. Every form on the page carries its node's label, so an edit anywhere aims at its node.

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

Summary

Functions

Renders a node as a page of sections, its sub-nodes as sub-sections.

The sections of a node's page: for each facet, the keys that are values and the child nodes the facet's node keys hold; a frame's are its own — kind first, bare, then size (the size and margin nodes together), binding, then the parts.

Whether a node kind carries a style stack, so its section selects it (spec/14 §18.18).

Functions

page(assigns)

Renders a node as a page of sections, its sub-nodes as sub-sections.

Attributes

  • id (:string) (required) - the page's id; sub-sections extend it.
  • kind (:atom) (required) - the node kind.
  • node (:map) (required) - the node's value.
  • path (:list) (required) - where the node sits in the design.
  • label (:string) (required) - the node's label, as Editor.label/1 spells it.
  • before (:list) - forms shown first: %{kind, node, path, label} (the frame's meta). Defaults to [].
  • collapsed (:any) - the section keys folded shut (toggle_section). Defaults to MapSet.new([]).
  • errors (:list) - the design's faults. Defaults to [].
  • refs (:map) - Defaults to %{}.
  • selected (:string) - the selected field's key. Defaults to nil.
  • selected_node (:string) - the label of the node the selected field is in. Defaults to nil.
  • found (:string) - Defaults to nil.
  • theme (:any) - Defaults to nil.
  • defs (:map) - Defaults to %{}.
  • pool (:list) - Defaults to [].
  • hidden (:list) - Defaults to [].
  • columns (:map) - Defaults to %{}.
  • source_name (:any) - Defaults to nil.
  • channel_columns (:map) - Defaults to %{}.
  • owners (:map) - the label of the layer that owns each path of the design (§18.15). Defaults to %{}.
  • layer (:any) - the selected layer's label. Defaults to nil.
  • locked (:any) - the labels of the sites that are the library's, read-only here, each to its row (§18.15, #381). Defaults to %{}.
  • guessed (:any) - the field labels a placed mark guessed, drawn as guesses (§18.16). Defaults to MapSet.new([]).
  • target (:any) - Defaults to nil.
  • depth (:integer) - Defaults to 0.

Slots

  • style_for - rendered with the selected node's label inside its section, after its form: the style stack and editor of a styled node (spec/14 §18.18, #378).

sections(page)

@spec sections(map()) :: [map()]

The sections of a node's page: for each facet, the keys that are values and the child nodes the facet's node keys hold; a frame's are its own — kind first, bare, then size (the size and margin nodes together), binding, then the parts.

iex> page = %{kind: :mark, node: %{type: :line, data: :p, channels: %{x: :t}, options: %{}}, path: [:marks, 0], label: "marks[0]", errors: []}
iex> for s <- Enum.take(Visualize.Chart.Builder.Page.sections(page), 3), do: {s.name, s.keys, Enum.map(s.children, & &1.label)}
[{"binding", [:data, :frame], []}, {"channel", [:type, :scales, :offset], ["marks[0].channels"]}, {"geometry", [:render, :transition], ["marks[0].options"]}]

A node key the node does not carry yet — the mark's scales above — stays a field, so the node can be given there; once it is, it is a sub-section.

styled?(kind)

@spec styled?(atom()) :: boolean()

Whether a node kind carries a style stack, so its section selects it (spec/14 §18.18).