# `MishkaCmsBuilder.ShownWhen`
[🔗](https://github.com/mishka-group/mishka_cms_builder/blob/v0.0.1-alpha.2/lib/mishka_cms_builder/shown_when.ex#L5)

The properties a component draws only while one of its switches is on.

## Why the Inspector has to say so

`chelekom-pagination` draws its first and last buttons under `:if={@rest[:show_edges]}`, so
`first_label`, `first_label_class`, `last_label` and `last_label_class` reach the canvas only once
Show edges is on. Until then, whatever is typed into them changes nothing, and the palette sweep
reported exactly that. The fields work; they are waiting for a switch the panel offers a few rows
away, and the panel says which.

## Read off the component's markup

A property is behind a switch when EVERY place the component reads it sits inside an element whose
`:if` is that switch alone — `:if={@rest[:show_edges]}` or `:if={@show_edges}` — itself or through
an ancestor. One read anywhere else (outside such an element, in a `:for`, in a helper's body, in
text) and the property may show without it, so nothing is said. A switch counts only when the panel
offers it as one: a boolean the component declares, or a `@rest` key its body reads as a flag
(`MishkaCmsCore.Runtime.Authoring.Inspector.rest_attrs/1`).

# `on?`

```elixir
@spec on?(MishkaCmsCore.Runtime.Authoring.Tree.Node.t(), String.t(), map()) ::
  boolean()
```

Whether the switch `name` is on for this node: written, and not written `false` or `nil`, or not
written at all and declared on by default — `chelekom-skeleton`'s `visible`.

# `switches`

```elixir
@spec switches(map()) :: %{required(String.t()) =&gt; String.t()}
```

Each property drawn only behind a switch, with that switch's name: `%{"first_label" =>
"show_edges"}`. Empty for a component with no markup, or none behind a switch.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
