Expresso.Overlay.Properties (expresso v0.1.0)

Copy Markdown View Source

The check of the custom properties of one slide

slide/1 does the work of Expresso.Overlay.PropertyVerifier, and it is a pure function on an Expresso.Slide struct. It reads the state option and the set option of each on entity of the slide, and it gives one warning for each property that Expresso.Theme reports as a defect.

registered_state/2 does a part of the work of Expresso.Overlay.Verifier. It refuses a state that takes the name of a property that the theme registers.

docs/overlays.md gives the rules.

Summary

Types

A warning of the verifier, with the location of the on entity

Functions

Give an error for a state that takes the name of a property that the theme registers

Give a warning for each custom property of a slide that is a defect

Types

warning()

@type warning() :: {String.t(), :erl_anno.anno()} | String.t()

A warning of the verifier, with the location of the on entity

Functions

registered_state(slide, registered \\ Theme.names().registered)

@spec registered_state(Expresso.Slide.t(), %{required(String.t()) => String.t()}) ::
  :ok | {:error, String.t()}

Give an error for a state that takes the name of a property that the theme registers

The compiler registers each state as a number with the initial value 0, and that registration replaces the registration of the theme. Each element of the deck that reads the property then gets 0 in place of the initial value of the theme, on each slide. The state scale is an example: each element gets the size 0 × 0. The default registrations are those of the theme.

slide(slide, names \\ Theme.names())

@spec slide(Expresso.Slide.t(), Expresso.Css.names()) :: [warning()]

Give a warning for each custom property of a slide that is a defect

The names come from the theme and from the CSS of the deck, which Expresso.Css.merge/2 joins. The default is the theme alone. The function reports these conditions:

  • The state option, or a key of the set option, names a property that the theme does not use. The renderer writes the property, and no rule of the theme reads it. Therefore the value has no effect.
  • The state option names a property that the theme declares, or that the theme registers with a different syntax than a number. The compiler registers each state as a number with the initial value 0. That registration makes the value of the theme invalid, and the theme then loses the property.
  • A key of the set option names a registered property, and the value does not agree with the syntax of that registration. The browser then ignores the value, and the property keeps its initial value. A <length> needs a unit of length, an <angle> needs a unit of angle, and a <number> needs a plain number. A value with a CSS function, such as var() or calc(), and a CSS-wide keyword, such as inherit, get no warning, because the browser calculates them.

Each message holds the path of the slide. The function adds the location of the on entity when Spark has it. A module of a test has no debug information, and Spark then gives nil.