# `MishkaDocument.Resources.Helpers.Labels`
[🔗](https://github.com/mishka-group/mishka_document/blob/v0.0.1/lib/mishka_document/resources/__helpers/labels.ex#L5)

The small words, numbers and dates the document resources' tables draw in their cells.

A table cell only receives the fields it `requires`, and a field the viewer's policy hides arrives
as a struct rather than a value, so each function here takes `term()` and answers a safe value for
anything it was not given.

    Labels.version_label("1.2.0")   #=> "v1.2.0"
    Labels.counted(%Ash.NotLoaded{})  #=> 0

# `badge`

```elixir
@type badge() :: %{label: String.t(), class: String.t()}
```

A badge a cell draws: its words and the Tailwind classes it wears.

# `counted`

```elixir
@spec counted(term()) :: non_neg_integer()
```

A count as a cell draws it: the integer itself, else `0`.

# `first_loaded`

```elixir
@spec first_loaded(map(), [atom()]) :: term()
```

The first of `fields` of `record` that is loaded, `nil` when none is or the loaded one holds `nil`.

A record read by a master carries its relationships under `master_` names, one read by a site
user under the plain ones; the other set stays `%Ash.NotLoaded{}`.

    Labels.first_loaded(draft, [:master_section, :section])

# `increment_label`

```elixir
@spec increment_label(term()) :: String.t()
```

The word for a kind of version bump, in the viewer's language.

# `inserted_on`

```elixir
@spec inserted_on(term()) :: String.t()
```

The day a record was written, in the viewer's language; a dash for anything that is not a time.

# `review_badge`

```elixir
@spec review_badge(term()) :: badge()
```

The badge a review status wears, `%{label: label, class: classes}`, with the label in the viewer's
language. A status that is none of the five reads as a dash.

# `translate_label`

```elixir
@spec translate_label(badge()) :: badge()
```

A badge map with its `:label` message id translated into the viewer's language.

# `version_label`

```elixir
@spec version_label(term()) :: String.t()
```

A version number as a tag reads it, `v1.2.0`; a record without one reads as `v0.0.1`.

---

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