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

Copy Markdown View Source

The context panel as the picker for the selected field (spec/14 §19.10).

A field is selected by clicking into it, and the panel shows the control its type deserves at a size the form cannot afford: a colour's patches above its picker, each patch draggable onto any colour well of the form (drop_colour), a font's faces in their own face, an enum's glyphs, a reference's local keys and library entries, a ranged number's slider. Every control here writes through the same edit the form does, under the same names — key, key.slot, key.range, key.var — so the panel is a bigger view of one field and never a second form.

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

Summary

Functions

The face the panel shows a field with, from its key and type (spec/14 §19.10): a colour, a font, a drawn enum's glyphs, an enum's words, a reference, a ranged number, or a plain box.

Renders the picker for one field: a <form class="vis-builder-picker"> whose controls write the field through edit.

Functions

face(arg)

@spec face(%{key: atom(), spec: map()}) ::
  :colour | :font | :glyphs | :enum | :reference | :range | :plain

The face the panel shows a field with, from its key and type (spec/14 §19.10): a colour, a font, a drawn enum's glyphs, an enum's words, a reference, a ranged number, or a plain box.

iex> Visualize.Chart.Builder.Picker.face(%{key: :fill, spec: %{type: :colour, range: nil}})
:colour

iex> Visualize.Chart.Builder.Picker.face(%{key: :curve, spec: %{type: {:enum, [:linear]}, range: nil}})
:glyphs

panel(assigns)

Renders the picker for one field: a <form class="vis-builder-picker"> whose controls write the field through edit.

Attributes

  • id (:string) (required) - the panel's id.
  • key (:any) - the selected field's key; nil shows the picker with nothing to write. Defaults to nil.
  • spec (:map) - the key's spec, as Schema.describe/1 gives it. Defaults to %{type: :colour, range: nil}.
  • value (:any) - the field's current value, or nil. Defaults to nil.
  • swatches (:list) - {slot, colour} for the theme's colour slots. Defaults to [].
  • recent (:list) - the colour literals the design already uses. Defaults to [].
  • refs (:map) - the names and ids a reference may take, by kind. Defaults to %{}.
  • entries (:list) - the library's entries, for a reference's names. Defaults to [].
  • target (:any) - the phx-target of the panel's events. Defaults to nil.