# `Alternera.UIKit`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_ui_kit/lib/alternera/ui_kit.ex#L1)

The proxy's look as function components, for a package to draw with no
proxy around: `icon/1`, `callout/1`, `badge/1`, `copy_button/1`,
`disclosure/1` and `chart/1`. The proxy's own `<.callout>`,
`<.alternera_badge>` and `<.chart>` call these, so what a package draws is
the proxy's markup.

Both UI contracts build on it: a step plugin's editor through
`Alternera.Plugin.Editor`, which delegates to it, and a resource
package's UI through `Alternera.Resource.UI`. It depends on LiveView
alone and calls nothing of the proxy; the classes it names are in the
proxy's `assets/css/app.css` (`alternera-pill-*`, `alternera-icon-btn`,
`alternera-chevron`), and `mix alternera.plugin_assets` lists its `lib`
among the Tailwind sources, so a utility class named only here is
generated.

    import Alternera.UIKit

    <.callout kind={:warning}>Nothing is configured.</.callout>

# `badge`

A badge or pill: the proxy's `alternera-pill` look in `assets/css/app.css`,
one `alternera-pill-<color>` per colour. The proxy's `<.alternera_badge>` is
this one. Say an outcome in words, never by colour alone: a pass/fail pair
is sky and orange, which red-green colour blindness tells apart.

    <.badge color="sky">Recorded</.badge>
    <.badge color="orange" variant="pill">Not recorded</.badge>

## Attributes

* `color` (`:string`) - Defaults to `"gray"`. Must be one of `"green"`, `"red"`, `"blue"`, `"purple"`, `"yellow"`, `"gray"`, `"indigo"`, `"amber"`, `"orange"`, `"cyan"`, `"sky"`, `"emerald"`, `"teal"`, `"pink"`, or `"fuchsia"`.
* `variant` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, `"pill"`, or `"small"`.
* `class` (`:string`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["title"]`.
## Slots

* `inner_block` (required)

# `badge_colors`

```elixir
@spec badge_colors() :: [String.t()]
```

The colours `badge/1` takes.

# `callout`

The status box for a warning, an error, a notice or a success message shown
as a block: a neutral card with a coloured left stripe, icon and title. A
tinted background turns muddy on the dark theme, so the colour stays in the
stripe, the icon and the title. The proxy's own `<.callout>` is this one.

`size` is `:md` (a banner) or `:sm` (inline, inside a step editor). `icon`
overrides the kind's icon; `nil` drops it. The `title` slot is optional.

    <.callout kind={:warning} size={:sm} id={@prefix <> "-no-hosts"}>
      <:title>No hosts</:title>
      Nothing is configured to call.
    </.callout>

## Attributes

* `kind` (`:atom`) - Defaults to `:info`. Must be one of `:info`, `:warning`, `:error`, or `:success`.
* `size` (`:atom`) - Defaults to `:md`. Must be one of `:sm`, or `:md`.
* `icon` (`:any`) - Defaults to `:default`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `title`
* `inner_block` (required)

# `callout_accent`

```elixir
@spec callout_accent(:info | :warning | :error | :success) :: String.t()
```

The text colour of a callout kind's title and icon, for a line inside the
callout that should read as part of the title.

# `copy_button`

An icon button that copies to the clipboard: `text`, or, with `selector`, that
element's text or a form field's current value. It runs on the proxy's
`CopyContent` hook, which swaps the icon for a check mark once it is done.

    <.copy_button id={@prefix <> "-copy"} selector={"#" <> @prefix <> "-source"} />

## Attributes

* `id` (`:string`) (required)
* `text` (`:string`) - Defaults to `nil`.
* `selector` (`:string`) - Defaults to `nil`.
* `title` (`:string`) - Defaults to `"Copy to clipboard"`.
* `class` (`:string`) - Defaults to `nil`.
* Global attributes are accepted.

# `disclosure`

A collapsible group of fields under a small heading, closed until the
heading is clicked: the proxy's step editors draw their Advanced and
Id & description groups with it. The toggle flips `data-open` on the
group (`<id>`) and `aria-expanded` on itself (`<id>-toggle`) on the
client, so the state survives the re-render every edit brings; the
content (`<id>-fields`) shows while open, while `error?` (the server's)
is set, and while a field inside has focus.

`remember` keeps the open or closed state per browser under that
`localStorage` key (the proxy's `RememberCollapse` hook). `fold` names
the group's kind for a section's ⋮ menu (`"meta"`, `"advanced"`), as the
toggle's `data-fold-kind`. The `heading` slot renders after the label on
the heading's line, for what a host puts there (the proxy: who else is
editing the group's fields).

    <.disclosure id={@prefix <> "-advanced"} label="Advanced" fold="advanced">
      ...fields...
    </.disclosure>

## Attributes

* `id` (`:string`) (required)
* `label` (`:string`) (required)
* `error?` (`:boolean`) - Defaults to `false`.
* `remember` (`:string`) - Defaults to `nil`.
* `fold` (`:string`) - Defaults to `nil`.
* `class` (`:string`) - Defaults to `nil`.
## Slots

* `heading`
* `inner_block` (required)

# `icon`

Renders a [Heroicon](https://heroicons.com), the `hero-*` class on a span.

    <.icon name="hero-x-mark-solid" />
    <.icon name="hero-arrow-path" class="ml-1 w-3 h-3 animate-spin" />

## Attributes

* `name` (`:string`) (required)
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. further attributes for the span.

---

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