Visualize.Chart.Builder.Palette (Visualize v0.2.25)

Copy Markdown View Source

The builder's style palette: the styles the stack declares, and how one is made (spec/14 §18.14).

A design's styles is a map of name to style node (§3), and a mark refers to one by name. Before this panel there was no way to add a name — §18.5 says "adding a node is adding the key, which is the same edit as any other", but no control added one — so a style could only be edited where some layer had already declared it, and a mark's style was a name typed into a text box and checked by the error list.

The palette is a view of the stacked design, because that is what a mark's reference resolves against: a style the house layer declares is available to a mark in the panel layer, and the palette says so. Creating one writes into the selected layer, because that is where every other edit goes.

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

Summary

Functions

The names the stacked design declares, in name order (spec/14 §18.14).

Renders the palette (spec/10 §15.3).

Functions

names(design)

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

The names the stacked design declares, in name order (spec/14 §18.14).

This is what a {:ref, :style} is a choice among, and it is read from the design rather than kept anywhere: a style a layer stops declaring stops being offered.

iex> Visualize.Chart.Builder.Palette.names(%{styles: %{series: %{}, axis: %{}}})
[:axis, :series]

iex> Visualize.Chart.Builder.Palette.names(%{marks: []})
[]

panel(assigns)

Renders the palette (spec/10 §15.3).

A <div class="vis-builder-palette"> with one <li class="vis-builder-palette-entry"> per declared style and a form that adds one.

Attributes

  • id (:string) - the palette's id, and the stem of its add form's. Defaults to "vis-builder-palette".
  • design (:map) (required) - the stacked design whose styles are the palette.
  • open (:atom) - the style the editor is on, marked in the list. Defaults to nil.
  • target (:any) - the phx-target of the palette's events. Defaults to nil.
  • class (:string) - appended to the palette's class. Defaults to nil.