# ixfx-transitory-label

An inline text label that animates between values instead of changing instantly. Displays as `inline-block` and inherits text styling from its parent.

```html
<ixfx-transitory-label text="Ready" effect="fade"></ixfx-transitory-label>
```

---

## Properties

| Property   | Type     | Default  | Description |
|------------|----------|----------|-------------|
| `text`     | `string` | `""`     | The displayed text. Changing this triggers the default `effect`. |
| `effect`   | `Effect` | `"fade"` | Transition effect used when `text` changes directly. |
| `duration` | `number` | `300`    | Animation duration in milliseconds. |
| `easing`   | `string` | `"ease"` | Any valid CSS `<easing-function>` value. |

### `setText(msg, effect)`

Set text with a specific effect for this change only, ignoring the component's default `effect` property.

```ts
label.setText('Error!', 'slide-up');
```

If a transition is already running, the new text is queued and plays immediately after.

---

## Effects

| Value            | Description |
|------------------|-------------|
| `fade`           | Old text fades out as new text fades in simultaneously. |
| `slide-right`    | Old text exits right, new text enters from the left. |
| `slide-left`     | Old text exits left, new text enters from the right. |
| `slide-up`       | Old text exits upward, new text enters from below. |
| `slide-down`     | Old text exits downward, new text enters from above. |
| `character-swap` | Characters swap one by one left-to-right with a staggered scale/fade. |

```html
<ixfx-transitory-label text="OK" effect="slide-up"></ixfx-transitory-label>
```

---

## Easing

The `easing` property accepts any CSS timing function. The same value applies to both the outgoing and incoming animations.

| Value | Result |
|-------|--------|
| `ease` | Default — gradual start and end |
| `ease-in` | Slow start, fast end |
| `ease-out` | Fast start, slow end |
| `ease-in-out` | Slow at both ends |
| `linear` | Constant speed |
| `cubic-bezier(0.34, 1.56, 0.64, 1)` | Spring — overshoots slightly before settling |
| `cubic-bezier(0.7, 0, 0.3, 1)` | Sharp — fast in the middle, crisp stop |

```html
<ixfx-transitory-label
  text="Ready"
  effect="slide-right"
  duration="400"
  easing="cubic-bezier(0.34, 1.56, 0.64, 1)"
></ixfx-transitory-label>
```

Easing can also be set via the CSS variable `--transitory-label-easing` without using the property:

```css
ixfx-transitory-label {
  --transitory-label-easing: ease-out;
}
```

---

## Styling

Text font, size, weight, and colour are fully inherited from the parent — no scoped styles are applied to the text content. Size the label by styling its parent or the element directly:

```css
ixfx-transitory-label {
  font-size: 1.4em;
  font-weight: bold;
}
```

---

## Usage examples

### Auto-cycling status label

```ts
const label = document.querySelector('ixfx-transitory-label');
const states = ['Idle', 'Loading', 'Done'];
let i = 0;

setInterval(() => {
  label.text = states[++i % states.length];
}, 2000);
```

### Per-update effect

```ts
label.setText('Connected', 'slide-up');
label.setText('Disconnected', 'fade');
```

### Attribute-only usage

```html
<p>Status: <ixfx-transitory-label text="Waiting" effect="fade" duration="500"></ixfx-transitory-label></p>
```
